ðH geocities.com /Heartland/Pond/4805/API4.htm geocities.com/Heartland/Pond/4805/API4.htm .delayed x ¶PÔJ ÿÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÈ Ð®ì un OK text/html `yi un ÿÿÿÿ b‰.H Sun, 20 Jan 2002 12:59:05 GMT 7 Mozilla/4.5 (compatible; HTTrack 3.0x; Windows 98) en, * ´PÔJ un
The
information in this article applies to:
Advanced: Requires expert coding, interoperability, and
multiuser skills. SUMMARYMicrosoft Access has no built-in method for disabling the Close button (X) on the application window or the Close command on the System menu of the application window. This article describes how to programmatically disable both of these. MORE INFORMATIONIn order to disable the application Close button and the Close command on the System menu, you must call the GetSystemMenu and ModifyMenu functions from the Win32 API. Step-by-Step Example
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 Private Declare Function GetMenuItemInfo Lib "user32" Alias _ "GetMenuItemInfoA" (ByVal hMenu As Long, ByVal un As Long, ByVal b As _ Long, lpMenuItemInfo As MENUITEMINFO) As Long Private Type MENUITEMINFO cbSize As Long fMask As Long fType As Long fState As Long wID As Long hSubMenu As Long hbmpChecked As Long hbmpUnchecked As Long dwItemData As Long dwTypeData As String cch As Long End Type Const MF_GRAYED = &H1& Const MF_BYCOMMAND = &H0& Const SC_CLOSE = &HF060&
Public Property Get Enabled() As Boolean Dim hWnd As Long Dim hMenu As Long Dim result As Long Dim MI As MENUITEMINFO MI.cbSize = Len(MI) MI.dwTypeData = String(80, 0) MI.cch = Len(MI.dwTypeData) MI.fMask = MF_GRAYED MI.wID = SC_CLOSE hWnd = Application.hWndAccessApp hMenu = GetSystemMenu(hWnd, 0) result = GetMenuItemInfo(hMenu, MI.wID, 0, MI) Enabled = (MI.fState And MF_GRAYED) = 0 End Property Public Property Let Enabled(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 Property
Function InitApplication() Dim c As CloseCommand Set c = New CloseCommand 'Disable Close menu. c.Enabled = False End Function
Action ------- RunCode Action Arguments ------------------------------- Function Name: InitApplication()
Note that the Close button and the Close command on the System menu of the application window are disabled. UsageThe CloseCommand class module
described in this article allows you to easily enable or disable the Close
button and the Close command of the application window. The class
module also allows you to check the state of these commands to determine if
they are currently enabled or disabled. Before doing either of these, your
code must first create an instance of the CloseCommand class, as demonstrated
in the InitApplication function earlier in this article. Additional query words: inf gray grayed grey greyed out upper right unavailable |