1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
| ' ---------------------------------------------------------
' Section Déclarations
' (Général) (Déclarations)
' ---------------------------------------------------------
Private Type RECT
left As Long
top As Long
right As Long
bottom As Long
End Type
' Device context
Private Declare Function GetDC Lib "user32.dll" ( _
ByVal hWnd As Long) As Long
'
Private Declare Function ReleaseDC Lib "user32.dll" ( _
ByVal hWnd As Long, ByVal hDc As Long) As Integer
Private Const LOGPIXELSX As Long = 88 ' pixels dans 1 inch
Private Const LOGPIXELSY As Long = 90 ' pixels dans 1 inch
Private Declare Function GetDeviceCaps Lib "Gdi32.dll" ( _
ByVal hDc As Long, ByVal nIndex As Integer) As Integer
' Informations système
Private Const SPI_GETWORKAREA As Long = 48
Private Declare Function SystemParametersInfo Lib "user32" Alias "SystemParametersInfoA" ( _
ByVal uiAction As Long, ByVal uiParam As Long, _
pvParam As Any, ByVal fWinIni As Long) As Long
' ---------------------------------------------------------
' Fin Section Déclarations
' ---------------------------------------------------------
Sub AgrandirAuMaximum()
Dim rectWkArea As RECT, lgRetVal As Long
Dim hDc As Long
Dim TwipPerPixH As Single, TwipPerPixV As Single
Dim lgWidthTwip As Long, lgHeightTwip As Long
' Taille de l'écran en pixel moins la barre des tâches
lgRetVal = SystemParametersInfo(SPI_GETWORKAREA, 0, rectWkArea, 0)
If lgRetVal <> 0 Then
hDc = GetDC(0)
' twip/inch divisé par pixel par inch -> twip/pixel
TwipPerPixH = 1440 / GetDeviceCaps(hDc, LOGPIXELSX)
TwipPerPixV = 1440 / GetDeviceCaps(hDc, LOGPIXELSY)
ReleaseDC 0, hDc
' Taille (largeur/hauteur) max en twips
lgWidthTwip = rectWkArea.right * TwipPerPixH
lgHeightTwip = rectWkArea.bottom * TwipPerPixV
End If
DoCmd.MoveSize 0, 0, lgWidthTwip, lgHeightTwip
End Sub |
Partager