Access开发的程序打开有Access后面的菜单栏。很多网友都希望像软件一样,只出现一个自己建的窗体界面
所以这里我们说一下如何隐藏Access的所有菜单栏。
一般我们可以通过菜单栏的文件-选项-当前数据库 把功能区和工具栏选项的勾全部去掉。但是这样只能隐藏部分功能栏。后面的主窗口还是会存在的。
在窗体中添加如下源码即可完全隐藏Access菜单栏:
Option Compare Database
Private Declare Function MoveWindow Lib "user32" (ByVal hwnd As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal bRepaint As Long) As Long
Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Private Const SW_SHOWMAXIMIZED = 3
Private Const SW_SHOWNORMAL = 1
Private Sub Form_Load()
ShowWindow Application.hWndAccessApp, SW_SHOWNORMAL
MoveWindow Application.hWndAccessApp, -1000, 0, 400, 500, 1
End Sub
Private Sub Form_Unload(Cancel As Integer)
MoveWindow Application.hWndAccessApp, 0, 0, 400, 500, 1
ShowWindow Application.hWndAccessApp, SW_SHOWMAXIMIZED
End Sub
说明:apiShowWindow(hWndAccessApp, SW_HIDE)办法不易控制,弄不好FORM自身也一起隐藏。并且用apiShowWindow(hWndAccessApp, SW_SHOWMAXIMIZED)还原后菜单不见了。上面的示例就没有这种情况
参考自:tase(Office中国论坛)