关闭铵钮无效.txt
上传用户:albinfu
上传日期:2021-08-24
资源大小:71k
文件大小:1k
- Private Declare Function GetSystemMenu Lib "User32" (ByVal hwnd As Long, ByVal bRevert As Long) As Long
- Private Declare Function RemoveMenu Lib "User32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long
- Private Declare Function DrawMenuBar Lib "User32" (ByVal hwnd As Long) As Long
- Private Declare Function GetMenuItemCount Lib "User32" (ByVal hMenu As Long) As Long
- Private Const MF_BYPOSITION = &H400&
- Private Sub Command1_Click()
- DisableClose Me
- End Sub
- Private Sub DisableClose(Frm As Form)
- Dim hMenu As Long, nCount As Long
- '获取系统菜单的句柄
- hMenu = GetSystemMenu(Frm.hwnd, 0)
- '得到系统菜单的菜单项目
- nCount = GetMenuItemCount(hMenu)
- '将关闭按钮置为无效
- Call RemoveMenu(hMenu, nCount - 1, MF_BYPOSITION)
- '重画系统菜单
- DrawMenuBar Frm.hwnd
- End Sub
- Private Sub Command2_Click()
- End
- End Sub