ACC: Maximizing One Form Maximizes All Forms (95/97)
ID: Q147152
|
The information in this article applies to:
-
Microsoft Access versions 7.0, 97
SYMPTOMS
Advanced: Requires expert coding, interoperability, and multiuser skills.
When you maximize a form, all other forms that are open are also
maximized. You cannot maximize one form independent of the other open
forms.
This article assumes that you are familiar with Visual Basic for
Applications and with creating Microsoft Access applications using the
programming tools provided with Microsoft Access. For more information
about Visual Basic for Applications, please refer to your version of
the "Building Applications with Microsoft Access" manual.
CAUSE
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 (by 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.
RESOLUTION
There are several ways to work around this behavior:
- Microsoft Access 97 introduces the MinMaxButtons Property. Setting
this property in Microsoft Access 97 prevents users from Minimizing
or Maximizing the form. This means the default state of the form is
maintained when the focus is shifted to the form.
The following suggestions work in both Microsoft Access 7.0 and 97
- Set the form's PopUp property to Yes. Forms whose PopUp property is
set to Yes are not MDI child windows. Pop-up forms float on top of
other forms, and are not maximized when an MDI child window is
maximized.
- You can simulate maximizing a form by sizing it as large as possible
in a restored state. The following example demonstrates how to create
and use a sample Sub procedure called MaximizeRestoredForm to restore
a form if it is maximized, and then to move the form to the upper-left
corner of the Microsoft Access client area window and size it as large
as possible.
- Create a module and type the following lines in the Declarations
section:
Option Explicit
Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Declare Function IsZoomed Lib "user32" (ByVal Hwnd As Long) As Long
Declare Function GetWindowRect Lib "user32" (ByVal Hwnd As Long, _
lpRect As RECT) As Long
Declare Function ShowWindow Lib "user32" (ByVal Hwnd As Long, _
ByVal nCmdShow As Long) As Long
Declare Function MoveWindow Lib "user32" (ByVal Hwnd As Long, _
ByVal X As Long, ByVal Y As Long, ByVal nWidth As Long, _
ByVal nHeight As Long, ByVal bRepaint As Long) As Long
Declare Function GetParent Lib "user32" (ByVal Hwnd As Long) As Long
Const SW_MAXIMIZE = 3
Const SW_SHOWNORMAL = 1
- Type the following procedure:
Sub MaximizeRestoredForm(F As Form)
Dim MDIRect As RECT
Dim RetVal As Long
' If the form is maximized, restore it.
If IsZoomed(F.Hwnd) <> 0 Then
RetVal = ShowWindow(F.Hwnd, SW_SHOWNORMAL)
End If
' Get the screen coordinates and window size of the
' MDIClient window.
RetVal = 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.
RetVal = MoveWindow(F.Hwnd, 0, 0, MDIRect.Right - _
MDIRect.Left - 4, MDIRect.Bottom - MDIRect.Top - 4, True)
End Sub
- To test this function, open the Customers form, type the following
line in the Debug window, and then press ENTER.
MaximizeRestoredForm Forms!Customers
Note that the Customers form is resized to cover the entire client
area of the Microsoft Access Window.
STATUS
This behavior is by design.
MORE INFORMATIONSteps to Reproduce Behavior
- Open the sample database Northwind.mdb.
- Open the Customers and Orders forms.
- Maximize the Customers form.
- On the Window menu, click the Orders form. Note that the Orders form
is now maximized.
Additional query words:
Keywords : kbprg kbusage
Version : WINDOWS:7.0,97
Platform : WINDOWS
Issue type : kbprb
|