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
| Option Explicit
Private Declare Function FindWindow& Lib "user32" Alias "FindWindowA" (ByVal lpClassName$, ByVal lpWindowName$)
Private Declare Function SetWindowLong& Lib "user32" Alias "SetWindowLongA" (ByVal hWnd&, ByVal lngWinIdx&, ByVal dwNewLong&)
Private Declare Function ShowWindow& Lib "user32" (ByVal hWnd&, ByVal nCmdShow&)
Private Declare Function SendMessage& Lib "user32" Alias "SendMessageA" (ByVal hWnd&, ByVal wMsg&, ByVal wParam%, ByVal lParam As Any)
Private hWnd&
Private Const SC_CLOSE = &HF060&
Private Const MF_BYCOMMAND = &H0&
Private Declare Function GetSystemMenu Lib "user32" (ByVal hWnd As Long, ByVal bRevert As Long) As Long
Private Declare Function RemoveMenu Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long
Private Declare Function FindWindowA Lib "user32" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Sub CommandButton1_Click()
'pour fermer le formulaire et reactiver excel
Me.Hide
Application.Visible = True
End Sub
Private Sub UserForm_Activate()
Application.ScreenUpdating = False
ShowWindow hWnd, 0
SetWindowLong hWnd, -20, &H40101
ShowWindow hWnd, 1
Application.ScreenUpdating = True
End Sub
Private Sub UserForm_Initialize()
hWnd = FindWindow(vbNullString, Me.Caption)
SetWindowLong hWnd, -16, &H84CA0080
'desactive et cache la croix de fermeture:
Dim hSysMenu As Long
Dim MeHwnd As Long
MeHwnd = FindWindowA(vbNullString, Me.Caption)
If MeHwnd > 0 Then
hSysMenu = GetSystemMenu(MeHwnd, False)
RemoveMenu hSysMenu, SC_CLOSE, MF_BYCOMMAND
Else
MsgBox "Handle de " & Me.Caption & " Introuvable", vbCritical
End If
'charger un logo (attention réactiver la ligne de déclaration "sendmessage"):
SendMessage hWnd, &H80, 0, Image1.Picture.Handle
End Sub |
Partager