K
KenR
I need to force users to exit using the button I provided, as several
housekeeping chores get bypassed if users exit using the "X" button in the
upper right corner of the application window. How do I disable this button?
I saw a previous post:
*******************
Private Declare Function GetSystemMenu Lib "user32" (ByVal hWnd As Long, _
ByVal bRevert As Long) As Long
'Disable/Enable the Close Button Option
Public Sub CloseButtonState(boolClose As Boolean)
Dim hWnd As Long
Dim wFlags As Long
Dim hMenu As Long
Dim Result As Long
hWnd = Application.hWndAccessApp
hMenu = GetSystemMenu(hWnd, 0)
If Not boolClose Then
wFlags = MF_BYCOMMAND Or MF_GRAYED
Else
wFlags = MF_BYCOMMAND And Not MF_GRAYED
End If
Result = EnableMenuItem(hMenu, SC_CLOSE, wFlags)
End Sub
Then in your code, maybe in a splash form:
Call CloseButtonState(False) 'Disables X
Call CloseButtonState(True) 'Enables X
***********************
but I get a "Variable not Defined" error when it is called. Where are the
variables MF_BYCOMMAND and MF_GRAYED declared?
Thanks for any help...
housekeeping chores get bypassed if users exit using the "X" button in the
upper right corner of the application window. How do I disable this button?
I saw a previous post:
*******************
Private Declare Function GetSystemMenu Lib "user32" (ByVal hWnd As Long, _
ByVal bRevert As Long) As Long
'Disable/Enable the Close Button Option
Public Sub CloseButtonState(boolClose As Boolean)
Dim hWnd As Long
Dim wFlags As Long
Dim hMenu As Long
Dim Result As Long
hWnd = Application.hWndAccessApp
hMenu = GetSystemMenu(hWnd, 0)
If Not boolClose Then
wFlags = MF_BYCOMMAND Or MF_GRAYED
Else
wFlags = MF_BYCOMMAND And Not MF_GRAYED
End If
Result = EnableMenuItem(hMenu, SC_CLOSE, wFlags)
End Sub
Then in your code, maybe in a splash form:
Call CloseButtonState(False) 'Disables X
Call CloseButtonState(True) 'Enables X
***********************
but I get a "Variable not Defined" error when it is called. Where are the
variables MF_BYCOMMAND and MF_GRAYED declared?
Thanks for any help...