- 'méthode du Form_QueryUnload
- Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
- Cancel = 1 'cancel est normalement à 0, le changer annule le déchargement.
- End Sub
-
- 'ou avec une msgbox
- Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
- Dim Question As VbMsgBoxResult
- Question = MsgBox("Etes-vous sûr(e) de vouloir quitter ?", vbQuestion + vbYesNo)
- If Question = vbNo Then Cancel = 1
- End Sub
-
- '------------------------------------
-
- 'Pour masquer les controles de la barre de titre, dans la propriété ControlBox de votre form, mettez false
-
- 'Vous pouvez aussi le faire avec des APIs
-
- Private Declare Function GetWindowLongA Lib "User32" _
- (ByVal hWnd As Long, ByVal nIndex As Long) As Long
-
- Private Declare Function SetWindowLongA Lib "User32" _
- (ByVal hWnd As Long, ByVal nIndex As Long, _
- ByVal dwNewLong As Long) As Long
-
- Private Declare Function FindWindowA Lib "User32" _
- (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
-
- Private Sub Form_Initialize()
- Dim hWnd As Long
- hWnd = FindWindowA("ThunderFormDC", Me.Caption)
- SetWindowLongA hWnd, -16, GetWindowLongA(hWnd, -16) And &HFFF7FFFF
- End Sub
-
- '-------------------------------
-
- 'griser la croix, donné par Derrick soft dans le forum
-
- 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
-
- ' Remove the Close menu item and disable the Close button
- ' from a window
-
- Public Sub RemoveCloseMenuItem(ByVal hWnd As Long)
- Const SC_CLOSE = &HF060
- Const MF_BYCOMMAND = 0
-
- Dim hMenu As Long
- ' get the system menu's handle
- hMenu = GetSystemMenu(hWnd, 0)
- ' remove the Close item
- RemoveMenu hMenu, SC_CLOSE, MF_BYCOMMAND
- End Sub
-
- Private Sub Form_Load()
- RemoveCloseMenuItem (Me.hWnd)
- End Sub
'méthode du Form_QueryUnload
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
Cancel = 1 'cancel est normalement à 0, le changer annule le déchargement.
End Sub
'ou avec une msgbox
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
Dim Question As VbMsgBoxResult
Question = MsgBox("Etes-vous sûr(e) de vouloir quitter ?", vbQuestion + vbYesNo)
If Question = vbNo Then Cancel = 1
End Sub
'------------------------------------
'Pour masquer les controles de la barre de titre, dans la propriété ControlBox de votre form, mettez false
'Vous pouvez aussi le faire avec des APIs
Private Declare Function GetWindowLongA Lib "User32" _
(ByVal hWnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLongA Lib "User32" _
(ByVal hWnd As Long, ByVal nIndex As Long, _
ByVal dwNewLong As Long) As Long
Private Declare Function FindWindowA Lib "User32" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Sub Form_Initialize()
Dim hWnd As Long
hWnd = FindWindowA("ThunderFormDC", Me.Caption)
SetWindowLongA hWnd, -16, GetWindowLongA(hWnd, -16) And &HFFF7FFFF
End Sub
'-------------------------------
'griser la croix, donné par Derrick soft dans le forum
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
' Remove the Close menu item and disable the Close button
' from a window
Public Sub RemoveCloseMenuItem(ByVal hWnd As Long)
Const SC_CLOSE = &HF060
Const MF_BYCOMMAND = 0
Dim hMenu As Long
' get the system menu's handle
hMenu = GetSystemMenu(hWnd, 0)
' remove the Close item
RemoveMenu hMenu, SC_CLOSE, MF_BYCOMMAND
End Sub
Private Sub Form_Load()
RemoveCloseMenuItem (Me.hWnd)
End Sub