当前位置:编程学习 > VB >>

VB怎样让MDI窗体禁用最大化按钮

追问:如果我把这段代码写到模块里,要在窗体代码中写什么呢?
答案:
写上这些代码最大化就被禁用了..
代码可以先复制到WORD下,之后再WORD下复制一下粘到VB中..之后就可以看到效果.
Option Explicit

Private 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

Private Const WS_SYSMENU = &H80000
Private Const WS_MINIMIZEBOX = &H20000
Private Const WS_MAXIMIZEBOX = &H10000

Private Const GWL_STYLE = (-16)
Private Declare Function FlashWindow Lib "user32" (ByVal hwnd As Long, ByVal bInvert As Long) As Long
'------
Private Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Long, ByVal bRevert 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 SC_MAXIMIZE = &HF030& '最大化

Private Sub MDIForm_Load()
Dim TempLng As Long

TempLng = GetWindowLong(Me.hwnd, GWL_STYLE)
' TempLng = TempLng And Not WS_MINIMIZEBOX
TempLng = TempLng And Not WS_MAXIMIZEBOX
' TempLng = TempLng And Not WS_SYSMENU
SetWindowLong Me.hwnd, GWL_STYLE, TempLng

FlashWindow Me.hwnd, True
FlashWindow Me.hwnd, False
'----------------
Dim R As Integer
Dim MyMenu As Long
MyMenu = GetSystemMenu(Me.hwnd, 0)
RemoveMenu MyMenu, SC_MAXIMIZE, R

End Sub
好像不能吧,一般的窗体可以设它的maxbutton的属性值设为false,但是MDI窗体好像没有吧,但是你可以设计窗体的width和height,让它固定一下大小吧!
呵呵
禁用最大化?
禁用了用户也可以调整MDI窗体大小嘛~~~
你到底要干什么用

上一个:关于VB,帮我写段代码
下一个:VB ShowSave后怎么区分保存的格式

CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,