How can i disable the 'X' at the top right hand corner of an MDI Form?
Printable View
How can i disable the 'X' at the top right hand corner of an MDI Form?
I'm not sure if you can actually remove it, but you should be able to stop it working...
VB Code:
Private Sub MDIForm_QueryUnload(Cancel As Integer, UnloadMode As Integer) If UnloadMode = 0 then Cancel = 1 End Sub
If unloadmode is 0 then the form's trying to close because the user clicked on the close button.
VB Code:
Option Explicit Private Declare Function RemoveMenu Lib "user32" (ByVal hMenu As Long, _ ByVal nPosition As Long, _ ByVal wFlags As Long) _ As Long Private Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Long, _ ByVal bRevert As Long) _ As Long Private Const MF_BYCOMMAND = &H0& Private Const SC_CLOSE = &HF060& Private Sub MDIForm_Load() Dim hMnu As Long hMnu = GetSystemMenu(Me.hwnd, False) Call RemoveMenu(hMnu, SC_CLOSE, MF_BYCOMMAND) End Sub
its too good man ;)