Microsoft KB Archive/210299

= ACC2000: Maximized Form Shows Control Box and Minimize, Maximize, and Restore Buttons =

Article ID: 210299

Article Last Modified on 6/23/2005

-

APPLIES TO


 * Microsoft Access 2000 Standard Edition

-



This article was previously published under Q210299





Notice


For a Microsoft Access 2.0 version of this article, see 128196.

This article applies to a Microsoft Access database (.mdb) and to a Microsoft Access project (.adp).

Advanced: Requires expert coding, interoperability, and multiuser skills.



SYMPTOMS
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. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers 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 requirements.



CAUSE
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.



RESOLUTION
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.   Create a new module and type the following lines in the Declarations section: 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   Type the following Sub procedure in the module: 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   To simulate maximizing a form automatically when it is opened, set the OnLoad property of the form to the following event procedure: Sub Form_Load MaximizeRestoredForm Me End Sub   To simulate maximizing a form called MyForm, use the following statement in a function or subroutine: MaximizeRestoredForm Forms!MyForm </ol>

Additional query words: prb

Keywords: kbprb kbusage KB210299

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.