How can I center Access 2007 switchboard opened to full screen?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32633

    #16
    I just found out that maximised form windows keep the same values for height and width as when in restored view. I'm just seeing if I can find out how to determine the actual values for the form window. I know it will involve a Windows API call, I just don't know which yet ;-)

    Comment

    • NeoPa
      Recognized Expert Moderator MVP
      • Oct 2006
      • 32633

      #17
      It seems like you will need some code in your Form_Open() event I would suggest. It needs to determine the size of the form and its sections. The form object (Switchboard) has a Width property but only the sections have Height properties. This is worth remembering even though we won't be using these values due to their being unfit for purpose (See post #16). They remind us of the structure though. If you have multiple sections you will need to handle this in your logic. How you move things around within that, and what logic you use, is up to you (and we can't really comment as you haven't shared that with us), but you will almost certainly want to cycle through your controls to process each one. Here is a stub of code you can work with (I assume just a Detail section) :

      Code:
      Option Compare Database
      Option Explicit
      
      Private Declare Function GetWindowRect Lib "user32" _
                                   (ByVal hWnd As Long, recWnd As Rect) As Long
      Private Type Rect
          Left As Long
          Top As Long
          Right As Long
          Bottom As Long
      End Type
      
      Private Sub Form_Open()
          Dim lngWidth As Long, lngHeight As Long
          Dim recForm As Rect
          Dim ctl As Control
      
          Call GetWindowRect(Me.hWnd, recForm)
          With recForm
              lngWidth = .Right - .Left
              lngHeight = .Bottom - .Top
          End With
          For Each ctl In Me.Detail.Controls
              '...  Your logic
          Next ctl
      End Sub

      Comment

      • JAGster
        New Member
        • Sep 2011
        • 26

        #18
        NeoPa, All functioning controls (the Quarterly Audit button has no logic/function currently assigned to it) have an On Click event that calls a macro. All macros were included in the attached macro. Except for the macro triggered by the Exit "button" all other macros close the main switchboard and open another form. The macro for the Exit button saves and closes the database.

        ADezii, I have attached a 2002 version of the sample database.
        Attached Files

        Comment

        • Rabbit
          Recognized Expert MVP
          • Jan 2007
          • 12517

          #19
          Use a subform as a container and then center the subform in the form's on load event.

          Comment

          • JAGster
            New Member
            • Sep 2011
            • 26

            #20
            Rabbit, What settings/code is needed for the subform to be centered on the form no matter the screen resolution?

            As a brief recap of what I'm trying to accomplish - I want to open a switchboard to full screen size, not maximized in the Access window, but full screen so none of the access toolbars, buttons, etc are visible. And have the controls on the switchboard centered no matter what computer/monitor or monitor resolution on which the database is running.

            Comment

            • ADezii
              Recognized Expert Expert
              • Apr 2006
              • 8834

              #21
              @JAGster:
              1. To perfect Scaling, you must know specific information regarding the Screen Resolution that is active at the time you created the Form and its Controls. This info is used to create specific Ratios for Scaling all Objects. The info needed is:
                1. Horizontal Screen Resolution in Pixels
                2. Vertical Screen Resolution in Pixels
                3. Logical Dots/Inch X
                4. Logical Dots/Inch Y
              2. Download the Attachment that I have provided for you and Open frmScreenInfo. All the information that you need for proper Scaling is generated within. Copy the Call to the SetDesignCoords () Method generated at the bottom of the Screen, it will look something like this:
                Code:
                Call frmResize.SetDesignCoords(1152, 830, 96, 96)
              3. Paste this Method Call and overwrite the comparable Line in the Load() Event of frmCentered (Line #9).
                Code:
                Private Sub Form_Open(Cancel As Integer)
                'Instantiate the Class to handle all resizing.
                Set mfr = New FormResize
                    
                'Tell the new Object what form you want it to work with.
                Set mfr.Form = Me
                
                'For 1152 x 864 Screen Resolution at the Kimmel Center
                Call mfr.SetDesignCoords(1152, 830, 96, 96)
                  
                'Set certain Properties
                With mfr
                  .ScaleForm = False
                  .ScaleColumns = True
                  .ScaleFonts = True
                  .ScaleControls = scYes
                End With
                End Sub
              4. Open Demo.mdb in any Screen Resolution. You should find that the Form covers the entire Screen and Scales all Controls/Fonts/Columns accordingly in any Screen Resolution, making it truly independent.
              5. If this actually works, I'll tell you what to do to incorporate this into your Database.
              Attached Files

              Comment

              • JAGster
                New Member
                • Sep 2011
                • 26

                #22
                ADezii,

                After pasting the resolution information from the frmScreenInfo Call frmResize.SetDe signCoords(1280 , 772, 96, 96)

                I got compile error "variable not defined" and showing frmResize highlighted, when I tried to open the frmCentered.

                Comment

                • ADezii
                  Recognized Expert Expert
                  • Apr 2006
                  • 8834

                  #23
                  Try Call mfr.SetDesignCo ords(1280, 772, 96, 96) first,

                  then

                  Paste mfr.SetDesignCo ords(1280, 772, 96, 96) over the corresponding Line in the Open() Event of frmCentered in the Demo Database, not yours. Test the Demo at various Resolutions. If this works, then we can migrate to your DB. If you are still having trouble, I can modify the Demo at this end, then Upload the Revision to you for testing.

                  Comment

                  • JAGster
                    New Member
                    • Sep 2011
                    • 26

                    #24
                    It appears to be working. One questions regarding scaling. One monitor I am using is set at resolution 1280x772 (the display settings say 1280x800). The other one 1024x768. When I opened frmCenter on the second one the layout looks exactly the same as on the first one, but the picture of the globe is taller and narrower. Is this because of the scaling from the first resolution to the other?

                    Comment

                    • ADezii
                      Recognized Expert Expert
                      • Apr 2006
                      • 8834

                      #25
                      Is this because of the scaling from the first resolution to the other?
                      I would image so.

                      Don't forget that mfr.SetDesignCo ords(1280, 772, 96, 96) must correspond to the Screen Data where the Form was created.

                      Test at various Resolutions, and try substituting the reported resolution instead of the actual ==> mfr.SetDesignCo ords(1280, 800, 96, 96)

                      Comment

                      • JAGster
                        New Member
                        • Sep 2011
                        • 26

                        #26
                        I've tested on a number of different resolutions and it does work on all of them. So, I'm now ready migrate it to my database.

                        Comment

                        • ADezii
                          Recognized Expert Expert
                          • Apr 2006
                          • 8834

                          #27
                          1. The vast majority of the Code is encapsulated within 3 Class Modules, Import them into your DB from the Demo. The Class Modules are: ControlResize, FormResize, and SectionResize.
                          2. In the Declarations Section of your Form's Code Module, place the following Declaration which will Declare a variable to represent a New Instance of the Class.
                            Code:
                            Private mfr As FormResize
                          3. In the Open() Event of the Form, Copy-N-paste the Code in the Demo's Form Open() Event to your Form:
                            Code:
                            Private Sub Form_Open(Cancel As Integer)
                            'Instantiate the Class to handle all resizing.
                            Set mfr = New FormResize
                                
                            'Tell the new Object what form you want it to work with.
                            Set mfr.Form = Me
                            
                            'For JAGster's Screen, Form Developement, Resolution 
                            Call mfr.SetDesignCoords(1280, 772, 96, 96)
                              
                            'Set certain Properties
                            With mfr
                              .ScaleForm = False
                              .ScaleColumns = True
                              .ScaleFonts = True
                              .ScaleControls = scYes
                            End With
                            End Sub

                          Comment

                          • JAGster
                            New Member
                            • Sep 2011
                            • 26

                            #28
                            It works!

                            ADezii, Thanks for all the help! Very much appreciated.

                            Comment

                            • ADezii
                              Recognized Expert Expert
                              • Apr 2006
                              • 8834

                              #29
                              Glad it all worked out for you.

                              Comment

                              Working...