ACC2000: Maximized Form Shows Control Box and Minimize, Maximize, and Restore ButtonsID: Q210299
|
A form whose ControlBox, MinMaxButtons, and CloseButton properties are set to No still displays the Restore and Close buttons when you maximize the form.
Microsoft 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
Microsoft Access is a multiple document interface (MDI) application. The default behavior for an MDI application is for all maximized child windows to display a Control menu box and a Restore button.
You can use the following technique to simulate maximizing a window
by sizing it as large as possible in the restored, windowed
(non-maximized), 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 it to the upper-left corner of the Microsoft Access client area window and to size it as large as possible.
NOTE: This technique produces a blank section at the top of the form that is approximately the height and width of a toolbar if the form is
opened in Design view and then switched to Form view. This code works best
when the form is opened from the Database window or through code while
running the application.
Type Rect
x1 As Long
y1 As Long
x2 As Long
y2 As Long
End Type
Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, _
lpRect As Rect) As Long
Declare Function IsZoomed Lib "user32" (ByVal hwnd As Long) 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
Public Const SW_MAXIMIZE = 3
Public 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 + 4, _
MDIRect.y2 - MDIRect.y1 + 4, True
End Sub
Sub Form_Load()
MaximizeRestoredForm Me
End Sub
MaximizeRestoredForm Forms!MyForm
Additional query words: prb
Keywords : kbusage kbdta AccCon FmsProp
Version : WINDOWS:2000
Platform : WINDOWS
Issue type : kbprb
Last Reviewed: August 10, 1999