VB icon

_ Disable the X button on your form, or another Windows form at run-time (with HWND) _

Email
Submitted on: 1/1/2015 7:49:00 AM
By: Jon Barker (from psc cd)  
Level: Beginner
User Rating: By 6 Users
Compatibility: VB.NET
Views: 2702
 
     This code will disable the X button on any form you know the HWND (unique number) for. To test this code on your own application, provide the function with ActiveForm.Handle().ToInt32()

 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
				
//**************************************
// Name: _ Disable the X button on your form, or another Windows form at run-time (with HWND)_
// Description:This code will disable the X button on any form you know the HWND (unique number) for.
To test this code on your own application, provide the function with ActiveForm.Handle().ToInt32()
// By: Jon Barker (from psc cd)
//**************************************

Public Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Integer, ByVal bRevert As Integer) As Integer
 Public Declare Function RemoveMenu Lib "user32" (ByVal hMenu As Integer, ByVal nPosition As Integer, ByVal wFlags As Integer) As Integer
Public Const SC_CLOSE = &HF060&
Public Const MF_BYCOMMAND = &H0&
Function RemoveXButton(ByVal iHWND As Integer) As Integer
Dim iSysMenu As Integer
iSysMenu = GetSystemMenu(iHWND, False)
Return RemoveMenu(iSysMenu, SC_CLOSE, MF_BYCOMMAND)
 End Function
'Disable the button on the current form:
RemoveXButton(ActiveForm.Handle().ToInt32())
'Thats it! tHe_cLeanER ownz you...


Other 12 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Beginner category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments


 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.