HIDE WINDOWS CLOSE BUTTON

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi All,
How can I hide Windows close (X) button so that a user is forced to use the
coded buttons I provide instead?
 
Dear Glint:

There is a property of the form under the Format tab called "Close Button".
That's it!

Tom Ellison
 
hey, Jeff, thanks for posting the ready-to-go code on your page, and thanks
to MVP Terry Kreft for sharing it - way cool!! :)
 
Sorry Jeff, I apply this code to access2007 but the application close(X)
button still there. Do you know how to fix it ?
 
Hi Guys,
Everything has been working fine since I got the solution to how to disable
the CLOSE button of Access through this forum.
Now however, I found that I get the error message: INVALID PROCEDURE CALL OR
ARGUMENT when I run the application on Access 2007.

The code on the module of the application goes thus:

Option Compare Database

Option Explicit

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)
Call CloseButtonState(blnState)
Call ExitMenuState(blnState)
End Function

'Disable the Menu Option
Sub ExitMenuState(blnExitState As Boolean)
Application.CommandBars("File").Controls("Exit").Enabled = 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

On the opening form of the application, I make a call:
Call SetEnabledState(False)

On Access 2007, the code stops at this point and returns the error message
while it works well with my Access 2003.

How can I solve this problem?
 
Back
Top