Option Explicit
'API Declarations
Const MF_BYPOSITION = &H400&
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
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhUH53VL4pVP2tZtMlAVtzUr81XYl666u__aCRB9X5pqz6OMRNYih-xf6WhYie-RnXh35vmc24tCjqkNSE8a0lOaCvi5k25bSkjCB2wrIAQpj6HReNTcFyNLYGXBYO2f7DN0jby/s400/Disable_Close_Button.gif)
Public Sub DisableCloseWindowButton(frm As Form)
Dim hSysMenu As Long
'Get the handle of the Window
hSysMenu = GetSystemMenu(frm.hwnd, 0)
'Disable the close button of the Form
RemoveMenu hSysMenu, 6, MF_BYPOSITION
'Remove the seperator bar
RemoveMenu hSysMenu, 5, MF_BYPOSITION
End Sub
It Works fine.. thank you :)
ReplyDeleteI get a Compile error: User-defined type not defined.
ReplyDeleteThe error appears to be in the line:
Public Sub DisableCloseWindowButton(frm As Form)
Apparently there is no such thing as a Form type...
I receive the same message:
ReplyDeleteUser-defined type not defined.
Public Sub DisableCloseWindowButton(frm As Form)