|
Заблокировать кнопку X на форме |
|
|
'Вариант 1
Private Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Long, ByVal
bRevert As Long) As Long
Private Declare Function DeleteMenu Lib "user32" (ByVal hMenu As Long, ByVal
nPosition As Long, ByVal wFlags As Long) As Long
Private Declare Function DrawMenuBar Lib "user32" (ByVal hwnd As Long) As Long
Const SC_CLOSE = &HF060
Const MF_BYCOMMAND = &H0
Public Sub DisableXbutton(ByVal frmHwnd As Long)
Dim hMenu As Long
hMenu = GetSystemMenu(frmHwnd, 0&)
If hMenu Then
Call DeleteMenu(hMenu, SC_CLOSE, MF_BYCOMMAND)
DrawMenuBar (frmHwnd)
End If
End Sub
Private Sub Form_Load()
DisableXbutton (Me.hwnd)
End Sub 'Вариант 2
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
Const MF_BYPOSITION = &H400&
Public Sub DisableCloseButton(F As Form)
Dim hSysMenu As Long
hSysMenu = GetSystemMenu(F.hwnd, 0)
RemoveMenu hSysMenu, 6, MF_BYPOSITION
RemoveMenu hSysMenu, 5, MF_BYPOSITION
End Sub
Private Sub Command1_Click()
Call DisableCloseButton(Form1)
End Sub
|
|
|
|
|
|
|