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 ;-)
How can I center Access 2007 switchboard opened to full screen?
Collapse
X
-
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
-
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.Comment
-
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
-
@JAGster:- 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:
- Horizontal Screen Resolution in Pixels
- Vertical Screen Resolution in Pixels
- Logical Dots/Inch X
- Logical Dots/Inch Y
- 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)
- 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
- 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.
- If this actually works, I'll tell you what to do to incorporate this into your Database.
Attached FilesComment
- 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:
-
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
-
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
-
Is this because of the scaling from the first resolution to the other?
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
-
- 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.
- 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
- 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
Comment