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
|
Option Compare Database
Option Explicit
'**************************************************************************
' Formulaire pour atténuation du fond
' Version avec ShowWindow pour agrandissement direct du formulaire
'**************************************************************************
Private Const WS_EX_LAYERED = &H80000
Private Const LWA_ALPHA = &H2
Private Const GWL_EXSTYLE = &HFFEC
Private Const SW_SHOWMAXIMIZED = 3
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" _
(ByVal hwnd As Long, ByVal lngWinIdx As Long, ByVal dwNewLong As Long) As Long
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" _
(ByVal hwnd As Long, ByVal lngWinIdx As Long) As Long
Private Declare Function SetLayeredWindowAttributes Lib "user32" _
(ByVal hwnd As Long, ByVal crKey As Integer, ByVal bAlpha As Integer, ByVal dwFlags As Long) As Long
Private Declare Function ShowWindow Lib "user32" _
(ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
' Au chargement du formulaire
Private Sub Form_Load()
Dim lAlpha As Long
' L'opacité est définie dans l'argument OpenArgs à l'ouverture du formulaire
' De 0 (transparent) à 100 (opaque)
' Si OpenArgs n'est pas défini, l'opacité est de 50
lAlpha = 255 * (Nz(Me.OpenArgs, 50) / 100)
' Rend le formulaire translucide
SetWindowLong Me.hwnd, GWL_EXSTYLE, GetWindowLong(Me.hwnd, GWL_EXSTYLE) Or WS_EX_LAYERED
SetLayeredWindowAttributes Me.hwnd, 0, lAlpha, LWA_ALPHA
' Agrandit le formulaire pour l'avoir en plein écran
ShowWindow Me.hwnd, SW_SHOWMAXIMIZED
End Sub |
Partager