如何禁止Access主窗體右上角的退出按鈕?
用代碼使Access主窗體上的“X”失效
在程序開始的窗體裡加入:
Private Declare Function GetSystemMenu Lib "User32" (ByVal hwnd As Long, ByVal bRevert As Long) As Long
Private Declare Function DeleteMenu Lib "User32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long
Private Sub FORM_Load()
Const MF_BYCOMMAND = &H0&
Const SC_CLOSE = &HF060 ''恢復按鈕的ID是:&HF120
Dim hMenu As Long
hMenu = GetSystemMenu(Application.hWndAccessApp, 0)
Call DeleteMenu(hMenu, SC_CLOSE, MF_BYCOMMAND)
End Sub
還有個最簡單的辦法,不管按鈕id,統統關掉
Private Sub closeAll()
Const MF_BYCOMMAND = &H0&
Dim hMenu As Long
hMenu = GetSystemMenu(Application.hWndAccessApp, 0)
dim I as long
for I=-5000 to 0
DeleteMenu hMenu, I, MF_BYCOMMAND
next I
End Sub