如何屏蔽mdiform最大化按钮
如何屏蔽mdiform最大化按钮,保留最小化与关闭按钮
[解决办法]
无法屏蔽,只能禁止,另外还有系统的恢复菜单需要去掉
Private Declare Function RemoveMenu Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As LongPrivate Declare Function DrawMenuBar Lib "user32" (ByVal hwnd As Long) As LongPrivate Declare Function GetMenuItemCount Lib "user32" (ByVal hMenu As Long) As LongPrivate Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Long, ByVal bRevert As Long) As LongPrivate Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As LongPrivate Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As LongPrivate Const MF_BYPOSITION = &H400&Private Const MF_DISABLED = &H2&Private Const MF_ENABLED = &H0&Private Const WS_MINIMIZEBOX = &H20000Private Const WS_MAXIMIZEBOX = &H10000Private Const GWL_STYLE = (-16)Private Sub MDIForm_Load() '以下禁止最大化 Dim L As Long L = GetWindowLong(Me.hwnd, GWL_STYLE) L = L And Not (WS_MAXIMIZEBOX) L = SetWindowLong(Me.hwnd, GWL_STYLE, L) '以下去掉系统菜单中的最大化和还原 Dim nCount As Long hMenu = GetSystemMenu(Me.hwnd, 0) nCount = GetMenuItemCount(hMenu) Call RemoveMenu(hMenu, nCount - 3, MF_DISABLED Or MF_BYPOSITION) DrawMenuBar Me.hwnd Call RemoveMenu(hMenu, nCount - 7, MF_DISABLED Or MF_BYPOSITION) DrawMenuBar Me.hwndEnd Sub