1 Reply Latest reply on Dec 16, 2016 5:14 PM by jru

    fix the background PDI display size as full when I open a new PDI display using a button

    kwon

      Hi,

      I'm building a pop-up style display using a simple code. Below is the coding that I test. but I have one problem. when it opens a new display, the size of original display is changed from full size to a window size. I want to keep the background display as full size.

      how can I do this..?

       

      Private Sub Value2_Click(ByVal lvarX As Long, ByVal lvarY As Long)

      Dim d1 As Display

      Set d1 = Application.Displays.Open("C:\Users\Administrator\Documents\Display1.PDI", True)

      d1.Top = 100

      d1.Left = 100

      d1.Height = 250

      d1.Width = 250

       

      d1.Restore

       

      End Sub

        • Re: fix the background PDI display size as full when I open a new PDI display using a button
          jru

          When you open up a new display in Processbook, the older display is minimized.  When a display is opened, the display is maximized like in the image below:

           

           

          The entire application AND display is maximized here.  When you switch/open another display in the same application, the new display will inherit the size of the original. In the VBA code, the part that does this is the D1.Restore function where it restores the default dimensions from the last save.

           

          This is why it won't work.  We can work around this by not using a maximized display.  This means we need to get the exact proportions of the screen.  Here's how we can do this:

           

          1) Instead of using the maximize button, we drag the boundaries of the display so that it fill the whole screen (note the difference between the 1st screenshot and the 2nd one).  Once set, save the display, this will be the dimensions for when we use the restore function.

           

          2) In VBA Editor, use the properties window to determine the display's dimensions (left, top, height and width).  In my example, left = 0, top = 0, height = 837, width = 1916

           

          3) We then add new lines of code that assigns the dimensions of the display:

           

          Set d2 = Application.Displays(1)

          d2.Left = 0

          d2.Top = 0

          d2.Height = 837

          d2.Width = 1916

           

          4) Now that we got the appropriate dimensions for the original display and the newly opened display, we just need to overlay everything.  The key is the Display.Activate function which determines which display is on top.  Since we need the original display in the background, we want to activate the original display first, restore the saved sizing values then activate the the newly opened display:

           

          d2.Activate

          d2.restore

          d1.Activate

           

          5) The new code will look like this:

           

          Private Sub Value2_Click(ByVal lvarX As Long, ByVal lvarY As Long)

           

               Dim d1 As Display

               Dim d2 As Display

           

               Set d1 = Application.Displays.Open("xxx\Display1.PDI", True)

           

               d1.Top = 100
               d1.Left = 100

               d1.Height = 250

               d1.Width = 250

           

               Set d2 = Application.Displays(1)

               d2.Left = 0

               d2.Top = 0

               d2.Height = 837

               d2.Width = 1916

           

               d2.Activate

               d2.Restore

               d1.Activated

           

          End Sub

           

          This will be the final result after running the code:

           

          ~Jesse

          1 of 1 people found this helpful