Home » Forms » How to Enable/Disable Close Button in a form
How to Enable/Disable Close Button in a form
Posted on January 4, 2009
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 | 'Forms - How to Enable/Disable Close Button in a form Option Explicit 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 DrawMenuBar Lib "user32" (ByVal hwnd As Long) As Long Private Const MF_BYCOMMAND = &H0& Private Const SC_CLOSE = &HF060& Public Sub SetXState(frm As Form, blnState As Boolean) Dim hMenu As Long hMenu = GetSystemMenu(frm.hwnd, blnState) Call RemoveMenu(hMenu, SC_CLOSE, MF_BYCOMMAND) Call DrawMenuBar(frm.hwnd) End Sub Private Sub Command1_Click() 'To Disable X button in a form Call SetXState(Me, False) 'To Enable X button in a form Call SetXState(Me, True) End Sub |
Related posts:
- How to Enable And Disable The Ctrl+Alt+Del
- How to restrict the user not to move the Form
- How to add a minimize Button to Form that has fixed Border
- How to Enable/Disable Mouse trails
- How to Enable/Disable all Controls in a frame
- How to Enable/Disable Task Manager
- How to add Bitmaps to Menu
- How to enable/disable the frame if checkbox is selected/deselected
- How to enable or disable the Cut, Copy and Paste menus in Edit menu if the text selected or not in a control.
- How to enable/disable submenus of Edit menu (Copy, Cut, Clear, Undo, and so on) based on text selection
Enjoy this article?
Filed under: Forms
Leave a comment
Sponsors
Link Back to us
Donations
If you are benefited from this site, please donate a small contribution to us. It will help to maintain this site better.
July 11th, 2009 - 12:15
thank you very much, it works