Modules |
5.86 API - Massimizzare una Form nell'area Client(MDI) Versione 2 |
Alessandro Baraldi |
La Sub FillMDIClientArea che segue ridimensiona la maschera passata calcolando la Client area della MDI_ACCESS sfruttando il ClassName. Option Compare Database Option Explicit Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hwnd As Long, ByVal hWndChild As Long, ByVal lpszClassName As Any, ByVal lpszWindow As Any) As Long Declare Function GetClientRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) 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 Type RECT Left As Long Top As Long Right As Long Bottom As Long End Type Type COORDS Left As Long Top As Long Width As Long Height As Long End Type Public Sub FillMDIClientArea(frm As Access.Form) Dim mC As COORDS Dim lpRect As RECT Dim hwndCli As Long hwndCli = FindWindowEx(Access.hWndAccessApp, 0, "MDIClient", vbNullString) If hwndCli <> 0 Then GetClientRect hwndCli, lpRect End If ' Convertiamo le dimensioni Rettangolari in Coordinate mC = RctToCoords(lpRect) Call MoveWindow(frm.hwnd, 0, 0, mC.Width, mC.Height, 1) End Sub Public Function RctToCoords(rct As RECT) As COORDS ' Convert from a RECT struct to a COORDS struct. ' This seems to come up often. Dim c As COORDS With c .Left = rct.Left .Top = rct.Top .Width = rct.Right - rct.Left .Height = rct.Bottom - rct.Top End With RctToCoords = c End Function |