Access开发培训
网站公告
·Access专家课堂QQ群号:151711184    ·Access快速开发平台下载地址及教程    ·欢迎加入Access专家课堂微信群!    ·如何快速搜索本站文章|示例|资料    
您的位置: 首页 > 技术文章 > Access数据库-模块/函数/VBA

禁用主窗口最大化和最小化按钮

时 间:2018-01-24 22:56:48
作 者:林岚   ID:3651  城市:中卫
摘 要:禁用主窗口最大化和最小化按钮
让主窗口最大化和最小化按钮消失
隐藏当前激活的工具条
显示和隐藏自定义的工具条
主窗口最小化
正 文:

禁用主窗口最大化和最小化按钮

'声明
Private Declare Function GetSystemMenu Lib "user32.dll" _
(ByVal hwnd As Long, ByVal bRevert As Long) As Long
Private Declare Function RemoveMenu Lib "user32.dll" _
(ByVal hMenu As Long, ByVal uPosition As Long, ByVal uFlags As Long) As Long


'使用
Private Sub Form_Load()
Dim hSysMenu As Long
Dim retval As Long
hSysMenu = GetSystemMenu(hWndAccessApp, 0)
retval = RemoveMenu(hSysMenu, &HF120, &H0)
hSysMenu = GetSystemMenu(Me.hwnd, 0)
retval = RemoveMenu(hSysMenu, &HF120, &H0)
End Sub

让主窗口最大化和最小化按钮消失

'声明:
Private Declare Function SetWindowLong Lib "user32" _
Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal _
nIndex As Long, ByVal dwNewLong As Long) As Long

Private Declare Function GetWindowLong Lib "user32" _
Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal _
nIndex As Long) As Long
Const WS_MINIMIZEBOX = &H20000
Const WS_MAXIMIZEBOX = &H10000
Const GWL_STYLE = (-16)


'使用:
Private Sub Form_Load()
Dim lWnd As Long
lWnd = GetWindowLong(hWndAccessApp, GWL_STYLE)

lWnd = lWnd And Not (WS_MINIMIZEBOX)
lWnd = lWnd And Not (WS_MAXIMIZEBOX)
lWnd = SetWindowLong(hWndAccessApp, GWL_STYLE, lWnd)
End Sub

计时器触发

Me.Text4.Value = Now()

隐藏当前激活的工具条:

 

Dim dqgjt As Variant

Set dqgjt = CommandBars.ActiveMenuBar

dqgjt.Enabled = False

 

显示和隐藏自定义的工具条

DoCmd.ShowToolbar "你的工具条名称", acToolbarYes

 

DoCmd.ShowToolbar "你的工具条名称", acToolbarNo

 

隐藏主程序窗口:(详见示例库)

Option Compare Database

Option Explicit

Private Const SW_HIDE = 0

Private Const SW_SHOWNORMAL = 1

Private Declare Function apiShowWindow Lib "user32" _

                                       Alias "ShowWindow" (ByVal hWnd As Long, _

                                                           ByVal nCmdShow As Long) As Long

 

 

Private Sub Command0_Click()

    If Me.Command0.Caption = "隐藏窗体" Then

        Me.Command0.Caption = "显示窗体"

        Call apiShowWindow(hWndAccessApp, SW_HIDE)

        DoCmd.Restore

    Else

        Me.Command0.Caption = "隐藏窗体"

        Call apiShowWindow(hWndAccessApp, SW_SHOWNORMAL)

       

        DoCmd.Close acForm, "frm_main"

        DoCmd.ShowToolbar "菜单栏", acToolbarYes

        DoCmd.Restore

    End If

End Sub

主窗口最小化:

DoCmd.RunCommand acCmdAppMinimize



Access软件网QQ交流群 (群号:54525238)       Access源码网店

常见问答:

技术分类:

相关资源:

专栏作家

关于我们 | 服务条款 | 在线投稿 | 友情链接 | 网站统计 | 网站帮助