mdi子窗体体如何实现只能最大化,不能还原呀?
因为用户总是会点一下还原按钮,这样所有已经打开的mdi子窗体都会变小,非常难看,所以我想限制一下,让mdi子窗体只能最大化,不能还原.禁止最小化可以,可是禁止还原如何实现呀?
经网友提示,我已找到答案,就是设置mdi子窗体的controlbox属性为false即可。
[此贴子已经被multiple1902于2007-8-31 11:54:46编辑过]
''''新建一个模块,COPY 下面的代码:
Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hwnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Declare Function Beep Lib "kernel32" (ByVal dwFreq As Long, ByVal dwDuration As Long) As Long
Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Public Const GWL_WNDPROC = (-4)
Public Const WM_NCLBUTTONDBLCLK = &HA3
Public prevWndProc As Long
Public Function WndProc(ByVal hwnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
On Error GoTo ShowErr
If Msg = WM_NCLBUTTONDBLCLK Then
Exit Function
End If
WndProc = CallWindowProc(prevWndProc, hwnd, Msg, wParam, lParam)
Exit Function
ShowErr:
WndProc = CallWindowProc(prevWndProc, hwnd, Msg, wParam, lParam)
Exit Function
End Function
'在窗体里加如下代码
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 DrawMenuBar 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
Const MF_BYPOSITION = &H400&
Const MF_REMOVE = &H1000&
Private Sub form_Load()
Me.WindowState = 2
Dim hSysMenu As Long, nCnt As Long
hSysMenu = GetSystemMenu(Me.hwnd, False)
If hSysMenu Then
nCnt = GetMenuItemCount(hSysMenu)
If nCnt Then
RemoveMenu hSysMenu, 0, MF_BYPOSITION Or MF_REMOVE
DrawMenuBar Me.hwnd
End If
End If
prevWndProc = GetWindowLong(Me.hwnd, GWL_WNDPROC)
SetWindowLong Me.hwnd, GWL_WNDPROC, AddressOf WndProc
End Sub
Private Sub Form_Unload(Cancel As Integer)
SetWindowLong Me.hwnd, GWL_WNDPROC, prevWndProc
End Sub