启用或禁用ACCESS程序的关闭按钮-Big Young
Access软件网QQ交流学习群(群号码198465573),欢迎您的加入!
首页 >技术文章> Access数据库-模块/函数/VBA


启用或禁用ACCESS程序的关闭按钮

发表时间:2018/2/24 16:32:03 评论(0) 浏览(8491)  评论 | 加入收藏 | 复制
   
摘 要:    在模块中用VBA实现启用或禁用ACCESS程序的关闭按钮。
正 文:

    在模块中用VBA实现启用或禁用ACCESS程序的关闭按钮:

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


Public Sub AccessCloseButtonEnabled(pfEnabled As Boolean)
  ' Comments: Control the Access close button.
  '           Disabling it forces the user to exit within the application
  ' Params  : pfEnabled       TRUE enables the close button, FALSE disabled it
  ' Owner   : Copyright (c) FMS, Inc.
  ' Source  : Total Visual SourceBook
  ' Usage   : Permission granted to subscribers of the FMS Newsletter


  On Error Resume Next


  Const clngMF_ByCommand As Long = &H0&
  Const clngMF_Grayed As Long = &H1&
  Const clngSC_Close As Long = &HF060&


  Dim lngWindow As Long
  Dim lngMenu As Long
  Dim lngFlags As Long


  lngWindow = Application.hWndAccessApp
  lngMenu = GetSystemMenu(lngWindow, 0)
  If pfEnabled Then
    lngFlags = clngMF_ByCommand And Not clngMF_Grayed
  Else
    lngFlags = clngMF_ByCommand or clngMF_Grayed
  End If
  Call EnableMenuItem(lngMenu, clngSC_Close, lngFlags)
End Sub


'Disabling the Close Button: Call AccessCloseButtonEnabled(False)


'Enabling the Close Button: Call AccessCloseButtonEnabled(True)



Access软件网交流QQ群(群号:198465573)
 
 相关文章
用代码禁止关闭按钮,即数据库窗口右上角的“X”失效  【竹笛  2007/10/27】
屏蔽access2003主窗体中的关闭按钮方法  【UMVsoft整理  2009/1/23】
快速开发平台--关闭按钮始终在最右边方法  【风行  2015/3/23】
窗体右上角最大最小化和关闭按钮功能如何打开  【杜超  2015/9/29】
利用VBA禁用或启用Access主程序的关闭按钮  【Big Young  2017/12/3】
常见问答
技术分类
相关资源
文章搜索
关于作者

Big Young

文章分类

文章存档

友情链接