如何去掉子窗体的关闭按钮.右上角的那个X
如何去掉子窗体的关闭按钮.右上角的那个X
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
-------------------------------------------------------------------------------------------------------------------------
在窗體的屬性窗口中,有一項為controlbox設置為false即可