|
APIs: Enlever le bouton de fermeture (X) des formulaires maximisés |
Author(s) Dev Ashish |
|
(Q) Quand on maximise un formulaire, son bouton Close apparaît,
même si on a expressément assigné la propriété voulue à Faux. Comment s'en
débarrasser?
(A) L'apparence de ce bouton Close sur les formulaires maximisés est
un comportement standard des fenêtres maximisées. Une solution est alors de soit ne pas maximiser le formulaire, ou, au lieu d'utiliser DoCmd.Maximize, utiliser la fonction suivante fournie par Terry Kreft.
Type Rect
x1 As Long
y1 As Long
x2 As Long
y2 As Long
End Type
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
Declare Function GetClientRect Lib "user32" (ByVal hWnd As Long, lpRect _
As Rect) As Long
Public Const SW_MAXIMIZE = 3
Public Const SW_SHOWNORMAL = 1
Sub MaximizeRestoredForm(F As Form)
Dim MDIRect As Rect
If IsZoomed(F.hWnd) <> 0 Then
ShowWindow F.hWnd, SW_SHOWNORMAL
End If
GetClientRect GetParent(F.hWnd), MDIRect
MoveWindow F.hWnd, 0, 0, MDIRect.x2 - MDIRect.x1, MDIRect.y2 - MDIRect.y1, True
End Sub
|