by [email protected] (1 Submission)
Category: Custom Controls/Forms/Menus
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Sun 10th March 2002
Date Added: Mon 8th February 2021
Rating: (1 Votes)
This code will disable the 'X' button at the top right corner of the form.
API Declarations
Public Const SC_CLOSE = &HF060
Public Const MF_BYCOMMAND = &H0
Public Declare Function GetSystemMenu Lib "user32" _
(ByVal hwnd As Long, ByVal bRevert As Long) As Long
Public Declare Function DeleteMenu Lib "user32" _
(ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long
Declare Function DrawMenuBar Lib "user32" (ByVal hwnd As Long) As Long
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
'and this is to Form_load code:
Private Sub Form_Load()
DisableXbutton (Me.hwnd)
End Sub
No comments have been posted about This code will disable the 'X' button at the top right corner of the form.. Why not be the first to post a comment about This code will disable the 'X' button at the top right corner of the form..