VBGood网站全文搜索 Google

搜索VBGood全站网页(全文搜索)
首页 - 经验之谈 - 使关闭、最大、最小化不可用
发表评论(0)作者:, 平台:, 阅读:11380, 日期:2000-03-12
声明:

Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Long, ByVal bRevert As Long) As Long

Declare Function GetMenuItemCount Lib "user32" (ByVal hMenu As Long) As Long

Declare Function DrawMenuBar Lib "user32" (ByVal hwnd As Long) As Long

Declare Function RemoveMenu Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long


Public Const MF_BYPOSITION = &H400&

Public Const MF_REMOVE = &H1000&

使用:

Private Sub Form_Load()

Dim hSysMenu As Long

Dim nCnt As Long

Me.Show

hSysMenu = GetSystemMenu(Me.hwnd, False)

If hSysMenu Then

' 取得系统菜单中的数量

nCnt = GetMenuItemCount(hSysMenu)


If nCnt Then

' 编号 (0, 1, 2, 3...)

RemoveMenu hSysMenu, nCnt - 1, MF_BYPOSITION Or MF_REMOVE

'去掉 关闭 按钮

RemoveMenu hSysMenu, nCnt - 2, MF_BYPOSITION Or MF_REMOVE

' 去掉一个下划线

'注意下面的语句, 请根据不同 Form 类别具体情况进行调试,

' 没个语句将关闭不同的功能!!

'RemoveMenu hSysMenu, nCnt - 3, MF_BYPOSITION Or MF_REMOVE

'RemoveMenu hSysMenu, nCnt - 4, MF_BYPOSITION Or MF_REMOVE

'RemoveMenu hSysMenu, nCnt - 5, MF_BYPOSITION Or MF_REMOVE

DrawMenuBar Me.hwnd

' 重画

End If

End If

End Sub


提供的方法二:

Const MF_REMOVE = &H1000&

Const SC_CLOSE = &HF060

Const SC_MAXIMIZE = &HF030

并在 Sub Form_Load()中加入:

RemoveMenu GetSystemMenu(hwnd, 0), SC_CLOSE, MF_REMOVE

这样就可以使关闭按钮无效。同样加入

RemoveMenu GetSystemMenu(hwnd, 0), SC_MAXIMIZE, MF_REMOVE