超高分!!VB的 MDI 窗体怎样 禁用还原按钮!!!!!!

要求:1.还原按钮变成灰色.2.系统菜单也不能出现还原命令!只要解决总是,本人从不吝啬,立即给分!!!在最大化后,最大化按钮失效也可以各位高手,窗口启动后就最大化,然后,... 要求:
1.还原按钮变成灰色.
2.系统菜单也不能出现还原命令!

只要解决总是,本人从不吝啬,立即给分!!!
在最大化后,最大化按钮失效也可以

各位高手,窗口启动后就最大化,然后,按钮失效!
展开
 我来答
iq0050
2007-08-14 · TA获得超过119个赞
知道答主
回答量:154
采纳率:0%
帮助的人:0
展开全部
' 去除系统菜单里还原项用常量
Const SC_MAXIMIZE = &HF030
Const SC_MINIMIZE = &HF020
Const SC_MOVE = &HF010
Const SC_RESTORE = &HF120
Const SC_SIZE = &HF000
Const SC_CLOSE = &HF060

Const MF_BYCOMMAND = 0

' 去掉窗口的还原按钮常量
Const WS_MAXIMIZE = &H1000000
Const WS_MAXIMIZEBOX = &H10000
Const WS_MINIMIZE = &H20000000
Const WS_MINIMIZEBOX = &H20000
Const GWL_STYLE = -16

' 得到系统菜单句柄
Private Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Long, ByVal bRevert As Long) As Long
' 删除系统菜单项
Private Declare Function DeleteMenu Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long

' 得到窗口样式句柄
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 Sub MDIForm_Load()
' 去除菜单项里的还原
Dim hMenu As Long
hMenu = GetSystemMenu(Me.hwnd, 0)
Call DeleteMenu(hMenu, SC_RESTORE, MF_BYCOMMAND)

' 灰显还原按钮(可根据时机进行运行,如在最大化后)
Dim WindowStyle As Long
WindowStyle = GetWindowLong(Me.hwnd, GWL_STYLE)
WindowStyle = WindowStyle And Not (WS_MAXIMIZEBOX)
Call SetWindowLong(Me.hwnd, GWL_STYLE, WindowStyle)
End Sub

----------------------------------------------------------

加上一句话就可以保证启动最大化:
Me.WindowState = 2
把这句话加到Form的Load事件中就行了.
百度网友6b6835fd2
2007-08-06 · TA获得超过182个赞
知道小有建树答主
回答量:388
采纳率:0%
帮助的人:0
展开全部
Private Sub Form_Resize()

'如果最大化
Static bs As Integer
If Me.WindowState = 2 Then
bs = 1
End If
'如果已最大化 并且将要还原
If bs = 1 And Me.WindowState = 0 Then
Me.WindowState = 2
End If

End Sub
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
云霞散人
2007-08-08 · 超过17用户采纳过TA的回答
知道答主
回答量:34
采纳率:0%
帮助的人:54.2万
展开全部
把代码放到MDI窗体中即可,这个可以使窗体的最大化按钮失效,菜单没有最大化,且窗体不可以调整大小

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 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

Private Const MF_REMOVE = &H1000&
Private Const SC_MAXIMIZE = &HF030&
Private Const GWL_STYLE = (-16)
Private Const WS_MAXIMIZEBOX = &H10000
Private Const WS_SIZEBOX = &H40000

Private Sub MDIForm_Load()
Dim hMenu As Long, lWnd As Long
lWnd = GetWindowLong(Me.hwnd, GWL_STYLE)
lWnd = lWnd And Not (WS_MAXIMIZEBOX)
lWnd = lWnd And Not (WS_SIZEBOX)
lWnd = SetWindowLong(Me.hwnd, GWL_STYLE, lWnd)

hMenu = GetSystemMenu(Me.hwnd, 0)
RemoveMenu hMenu, SC_MAXIMIZE, MF_REMOVE
End Sub
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
emoingIJ
2007-08-06 · TA获得超过234个赞
知道小有建树答主
回答量:216
采纳率:0%
帮助的人:0
展开全部
Private Declare Function SetWindowLong Lib "USER32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function GetWindowLong Lib "USER32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Sub DisableX()
Dim hMenu, nCount, LO As Long
hMenu = GetSystemMenu(Me.hwnd, 0)
nCount = GetMenuItemCount(hMenu)
LO = RemoveMenu(hMenu, nCount - 3, MF_REMOVE Or MF_BYPOSITION)
LO = RemoveMenu(hMenu, nCount - 4, MF_REMOVE Or MF_BYPOSITION)
End Sub

Private Sub MDIForm_Load()

Dim lWnd As Long
DisableX
lWnd = GetWindowLong(Me.hwnd, GWL_STYLE)
'lWnd = lWnd And Not (WS_MINIMIZEBOX)
lWnd = lWnd And Not (WS_MAXIMIZEBOX)
lWnd = SetWindowLong(Me.hwnd, GWL_STYLE, lWnd)

End Sub
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
俊心风12
2007-08-06 · TA获得超过226个赞
知道答主
回答量:73
采纳率:0%
帮助的人:0
展开全部
Option Explicit

Const SC_MAXIMIZE = &HF030
Const SC_MINIMIZE = &HF020
Const SC_MOVE = &HF010
Const SC_RESTORE = &HF120
Const SC_SIZE = &HF000
Const SC_CLOSE = &HF060

Const MF_BYCOMMAND = 0

Private Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Long, ByVal bRevert As Long) As Long
Private Declare Function DeleteMenu Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long
Private Sub Form_Load()

Dim hMenu As Long

hMenu = GetSystemMenu(Me.hwnd, 0)
Call DeleteMenu(hMenu, SC_RESTORE, MF_BYCOMMAND)

End Sub
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
zjw139
2007-08-06 · TA获得超过804个赞
知道小有建树答主
回答量:645
采纳率:0%
帮助的人:0
展开全部
SubForm sub = new SubForm();
sub.Show();
sub.Dock = DockStyle.Fill;
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 更多回答(5)
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式