如何使vb中MDI主窗口的最大化、关闭按钮无效

2024-12-01 18:25:14
推荐回答(1个)
回答1:

Const GWL_STYLE = (-16)
'窗口关闭按钮
Private Declare Function GetSystemMenu Lib "USER32" (ByVal hwnd As Long, ByVal bRevert As Long) As Long
Private Declare Function DeleteMenu Lib "USER32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long
Private Declare Function SendMessage Lib "USER32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Const MF_BYCOMMAND = &H0&
Const MF_BYPOSITION = &H400&
Const SC_CLOSE = &HF060&
Const WM_CLOSE = &H10
Private hMenu As Long
Private Sub MDIForm_Load()
Dim lWnd As Long
Me.WindowState = 2 '窗口状态是最大化
lWnd = GetWindowLong(Me.hwnd, GWL_STYLE)
lWnd = lWnd And Not (WS_MAXIMIZEBOX) '样式里去掉最大化按纽
lWnd = SetWindowLong(Me.hwnd, GWL_STYLE, lWnd)
'窗口关闭按钮