VBGood网站全文搜索 Google

搜索VBGood全站网页(全文搜索)
首页 - 经验之谈 - 去掉窗体的X
发表评论(0)作者:不详, 平台:VB6.0+Win98, 阅读:9867, 日期:2001-04-06
Private Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Long, ByVal bRevert As Long) As Long
Private Declare Function GetMenuItemCount Lib "user32" (ByVal hMenu 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 Const MF_BYPOSITION = &H400&
Private Const MF_DISABLED = &H2&

Public Sub DisableX(Frm As Form)
Dim hMenu As Long, nCount As Long

`获得窗口系统菜单的菜单句柄
hMenu = GetSystemMenu(Frm.hwnd, 0)
`得到hMenu指定的菜单的菜单项数目
nCount = GetMenuItemCount(hMenu)

`将系统菜单的最后一个菜单项移走(最后一个菜单项是 `Close`)
Call RemoveMenu(hMenu, nCount - 1, MF_DISABLED Or MF_BYPOSITION)
`重画系统菜单
DrawMenuBar Frm.hwnd
End Sub


Private Sub Command1_Click()
End
End Sub

Private Sub Form_Load()
DisableX Me
End Sub