Public Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Public Const GWL_STYLE = (-16)
Public Const WS_MAXIMIZEBOX = &H10000
Private Sub MDIForm_Load()
Dim Win_Style As Long
Win_Style = GetWindowLong(hwnd, GWL_STYLE) And Not WS_MAXIMIZEBOX
SetWindowLong hwnd, GWL_STYLE, Win_Style
End Sub
'''''''''''''窗体
Private Sub MDIForm_Load()
Dim lWnd As Long
'lWnd = GetWindowLong(ljfrm_MDImain.hWnd, GWL_STYLE)
lWnd = lWnd And Not (WS_MINIMIZEBOX)
lWnd = lWnd And Not (WS_MAXIMIZEBOX)
lWnd = SetWindowLong(MDI.hWnd, GWL_STYLE, lWnd)
'最大化和最小化无效
Dim hSysMenu As Long
Dim nCnt As Long
hSysMenu = GetSystemMenu(MDI.hWnd, False)
If hSysMenu Then
'nCnt = GetMenuItemCount(hSysMenu)
RemoveMenu hSysMenu, nCnt - 1, MF_BYPOSITION Or MF_REMOVE
RemoveMenu hSysMenu, nCnt - 2, MF_BYPOSITION Or MF_REMOVE
RemoveMenu hSysMenu, nCnt - 3, MF_BYPOSITION Or MF_REMOVE
RemoveMenu hSysMenu, nCnt - 4, MF_BYPOSITION Or MF_REMOVE
'DrawMenuBar MDI.hWnd
End If
End Sub
'''''''''''''''''模块
Option Explicit
Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Public Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
Public Declare Function GetSystemMenu Lib "user32" (ByVal hWnd As Long, ByVal bRevert As Long) As Long
Public Const WS_MINIMIZEBOX = &H20000
Public Const WS_MAXIMIZEBOX = &H10000
Public Const GWL_STYLE = (-16)
Public Declare Function GetMenuItemCount Lib "user32" (ByVal hWnd As Long)
Public Declare Function RemoveMenu Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long
Public Declare Function DrawMenuBar Lib "user32" (ByVal hWnd As Long)
Option Explicit
Private Declare Function GetMenu Lib "user32" (ByVal hWnd 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 GetSystemMenu Lib "user32" (ByVal hWnd As Long, ByVal bRevert As Long) As Long
Const MF_BYPOSITION = &H400&
-------------------------------------
Private Sub MDIForm_Load()
Dim hMenu As Long
hMenu = GetSystemMenu(Me.hWnd, 0)
RemoveMenu hMenu, 4, MF_BYPOSITION
End Sub
虽然最大化按钮仍然在窗体上显示,但是已经不起作用了。
'在模块中声明
'********使最大化和最小化按钮消失*****
Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Public Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
Public Const WS_MINIMIZEBOX = &H20000
Public Const WS_MAXIMIZEBOX = &H10000
Public Const GWL_STYLE = (-16)
在需要屏蔽的窗体from_load中加入
Dim lWnd As Long
'lWnd = GetWindowLong(ljfrm_MDImain.hWnd, GWL_STYLE)
lWnd = lWnd And Not (WS_MINIMIZEBOX)
lWnd = lWnd And Not (WS_MAXIMIZEBOX)
lWnd = SetWindowLong(ljfrm_MDImain.hWnd, GWL_STYLE, lWnd)
'最大化和最小化无效
Dim hSysMenu As Long
Dim nCnt As Long
hSysMenu = GetSystemMenu(ljfrm_MDImain.hWnd, False)
If hSysMenu Then
nCnt = GetMenuItemCount(hSysMenu)
RemoveMenu hSysMenu, nCnt - 1, MF_BYPOSITION Or MF_REMOVE
RemoveMenu hSysMenu, nCnt - 2, MF_BYPOSITION Or MF_REMOVE
RemoveMenu hSysMenu, nCnt - 3, MF_BYPOSITION Or MF_REMOVE
RemoveMenu hSysMenu, nCnt - 4, MF_BYPOSITION Or MF_REMOVE
DrawMenuBar ljfrm_MDImain.hWnd
End If