ACC2000: Maximizing One Form Maximizes All Forms
ID: Q210123
|
The information in this article applies to:
Advanced: Requires expert coding, interoperability, and multiuser skills.
This article applies to a Microsoft Access database (.mdb) and a Microsoft Access project (.adp).
SYMPTOMS
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.
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 a document window in Microsoft Excel 2000,
all other document windows will also be maximized.
RESOLUTIONMicrosoft provides programming examples for illustration only, without warranty
either expressed or implied, including, but not limited to, the implied warranties of
merchantability and/or fitness for a particular purpose. This article assumes that you
are familiar with the programming language being demonstrated and the tools used to
create and debug procedures. Microsoft support professionals can help explain the functionality
of a particular procedure, but they will not modify these examples to provide added
functionality or construct procedures to meet your specific needs. If you have limited
programming experience, you may want to contact a Microsoft Certified Solution Provider
or the Microsoft fee-based consulting line at (800) 936-5200. For more information about
Microsoft Certified Solution Providers, please see the following page on the World Wide Web:
http://www.microsoft.com/mcsp/
For more information about the support options available from Microsoft, please see the
following page on the World Wide Web:
http://www.microsoft.com/support/supportnet/overview/overview.asp
There are several ways to work around this behavior:
-
Set the MinMaxButtons property to None. This prevents users from minimizing
or maximizing the form. This also means the default state of the form is maintained when
the focus is shifted to the form.
-
Set the PopUp property of the form 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 use code 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.
-
In a new module, type the following code:
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
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
-
Open the Customers form.
-
Press CTRL+G to open the Immediate window.
-
In the Immediate window, type the following line, 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.
MORE INFORMATIONSteps to Reproduce Behavior
-
Open the sample database Northwind.mdb.
-
Open the Orders and Customers forms.
-
Maximize the Customers form.
-
On the Window menu, click the Orders form.
Note that the Orders form is now maximized.
Additional query words:
prb
Keywords : kbprg kbusage kbdta
Version : WINDOWS:2000
Platform : WINDOWS
Issue type : kbprb
|