By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,480 Members | 771 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,480 IT Pros & Developers. It's quick & easy.

Disable X

P: n/a
Hi Guys,

When my database opens it run the following code.

Private Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As
Long, ByVal bRevert As Long) As Long
Private Declare Function EnableMenuItem Lib "user32" (ByVal hMenu As
Long, ByVal wIDEnableItem As Long, ByVal wEnable As Long) As Long

Const MF_GRAYED = &H1&
Const MF_BYCOMMAND = &H0&
Const SC_CLOSE = &HF060&

Public Function SetEnabledState(blnState As Boolean)
CloseButtonState blnState
ExitMenuState blnState
End Function

'Disable the Menu Option
Sub ExitMenuState(blnExitState As Boolean)
Application.CommandBars("File").Controls("Exit").E nabled =
blnExitState
End Sub

'Disable the Close Button Option
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

This greys out both the close button on the access window and the exit
command on the file menu. What I want to know is how to disable the X
in the database window.

TIA

Nick

Aug 7 '06 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.