CISA FotoGallery

Statistiche

Tot. visite contenuti : 928010
Home Articoli tecnici API Massimizzare una Form nell'area Client(MDI) Vers.2

Massimizzare una Form nell'area Client(MDI) Vers.2

MASSIMIZZARE UNA FORM ALLA ACCESS MDI_CLIENT AREA

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

' Questa funzione ridimensiona la Form passata calcolando la Client area della
' MDI_ACCESS sfruttando il ClassName

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


Alessandro Baraldi