ACC: Maximizing One Form Maximizes All FormsID: Q121410
|
Moderate: Requires basic macro, coding, and interoperability skills.
When you maximize a form, all other open forms are also maximized. You
cannot maximize one form independent of the other open forms.
Microsoft Access is a multiple document interface (MDI) application. The default behavior for an MDI document is for all child windows to be maximized when one is maximized. This behavior occurs in many applications. For example, if you maximize one group window in Windows Program Manager, any other group window that you select (using the Window menu) will also be maximized. Or, if you maximize a document window in Microsoft Word for Windows, all other document windows will be maximized as well.
This article assumes that you are familiar with Access Basic and with
creating Microsoft Access applications using the programming tools provided
with Microsoft Access. For more information on Access Basic, please refer
to the "Introduction to Programming" manual in Microsoft Access version
1.x, or the "Building Applications" manual in version 2.0.
There are two ways to work around this behavior:
Option Explicit
Type Rect
x1 As Integer
y1 As Integer
x2 As Integer
y2 As Integer
End Type
Declare Sub GetWindowRect Lib "User" (ByVal hWnd As Integer, _
lpRect As Rect)
Declare Function IsZoomed Lib "User" (ByVal hWnd As Integer) _
As Integer
Declare Sub ShowWindow Lib "User" (ByVal hWnd%, ByVal nCmdShow%)
Declare Sub MoveWindow Lib "User" (ByVal hWnd As Integer, _
ByVal X As Integer, ByVal Y As Integer, ByVal nWidth As _
Integer, ByVal nHeight As Integer, ByVal bRepaint As Integer)
Declare Function GetParent Lib "User" (ByVal hWnd As Integer) _
As Integer
Const SW_MAXIMIZE = 3
Const SW_SHOWNORMAL = 1
Sub MaximizeRestoredForm (F As Form)
Dim MDIRect As Rect
' If the form is maximized, restore it.
If IsZoomed(F.hWnd) <> 0 Then
ShowWindow F.hWnd, SW_SHOWNORMAL
End If
' Get the screen coordinates and window size of the
' MDIClient window.
GetWindowRect GetParent(F.hWnd), MDIRect
' Move the form to the upper left corner of the MDIClient
' window (0,0) and size it to the same size as the
' MDIClient window.
MoveWindow F.hWnd, 0, 0, MDIRect.x2 - MDIRect.x1, _
MDIRect.y2 - MDIRect.y1, True
End Sub
Sub Form_Load()
MaximizeRestoredForm Me
End Sub
MaximizeRestoredForm Forms!MyForm
This behavior is by design.
For more information about pop-up forms, search for "PopUp" then "Creating Pop-Up Forms and Dialog Boxes" using the Microsoft Access version 2.0 Help menu.
Keywords : kbusage FmsProp
Version : 1.0 1.1 2.0
Platform : WINDOWS
Issue type : kbprb
Last Reviewed: April 7, 1999