Option ExplicitPrivate Sub MDIForm_Resize() If Me.WindowState <> 1 Then If Me.WindowState = 2 Then Me.WindowState = 0 Exit Sub End If Me.Width = 4000 Me.Height = 3000 End If End Sub
这样还是可以拖动,虽然不能resize了,能不能用 api 来实现?能的话应该怎么写?
Option ExplicitPrivate Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long Const GWL_STYLE = (-16) Const WS_THICKFRAME = &H40000 Const WS_SIZEBOX = WS_THICKFRAMEPrivate Sub dd_Click() Unload Me End SubPrivate Sub MDIForm_Load() Dim TempLng As Long TempLng = GetWindowLong(Me.hwnd, GWL_STYLE)
SetWindowLong Me.hwnd, GWL_STYLE, TempLng + WS_SIZEBOX End Sub
按照cuizm 的方法的话连最大化最小化和关闭的那个control 按钮都没了在 cuizm 的代码加一句就好了 TempLng = TempLng And Not WS_SIZEBOX 感谢 cuizm !
If Me.WindowState <> 1 Then
If Me.WindowState = 2 Then
Me.WindowState = 0
Exit Sub
End If
Me.Width = 4000
Me.Height = 3000
End If
End Sub
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Const GWL_STYLE = (-16)
Const WS_THICKFRAME = &H40000
Const WS_SIZEBOX = WS_THICKFRAMEPrivate Sub dd_Click()
Unload Me
End SubPrivate Sub MDIForm_Load()
Dim TempLng As Long
TempLng = GetWindowLong(Me.hwnd, GWL_STYLE)
SetWindowLong Me.hwnd, GWL_STYLE, TempLng + WS_SIZEBOX
End Sub
TempLng = TempLng And Not WS_SIZEBOX
感谢 cuizm !