如何把窗体默认的关闭按扭去掉?

hong0411ren 2003-12-10 03:21:13
同上。
...全文
7 点赞 收藏 9
写回复
9 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
zyl910 2003-12-12
完整的:



Private Declare Function SetWindowPos Lib "user32.dll" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Private Const SWP_FRAMECHANGED = &H20
Private Const SWP_NOACTIVATE = &H10
Private Const SWP_NOMOVE = &H2
Private Const SWP_NOSIZE = &H1
Private Const SWP_NOZORDER = &H4


Public Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Long, _
ByVal bRevert As Long) As Long

Public Declare Function RemoveMenu Lib "user32" (ByVal hMenu As Long, _
ByVal nPosition As Long, ByVal wFlags As Long) As Long



'-----------禁止 ----------------------------
Dim hSysMenu As Long
Private Sub Command1_Click()
'---------- 还原 ------------------------------
GetSystemMenu Form1.hwnd, True
SetWindowPos me.hWnd,0,0,0,0,0,SWP_FRAMECHANGED or SWP_NOACTIVATE or SWP_NOMOVE or SWP_NOSIZE or SWP_NOZORDER
End Sub

Private Sub Form_Load()
hSysMenu = GetSystemMenu(Form1.hwnd, 0)
RemoveMenu hSysMenu, &HF060, 0
SetWindowPos me.hWnd,0,0,0,0,0,SWP_FRAMECHANGED or SWP_NOACTIVATE or SWP_NOMOVE or SWP_NOSIZE or SWP_NOZORDER
End Sub

回复
zyl910 2003-12-12
用“SetWindowPos”可避免me.hide

Private Declare Function SetWindowPos Lib "user32.dll" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Private Const SWP_FRAMECHANGED = &H20
Private Const SWP_NOACTIVATE = &H10
Private Const SWP_NOMOVE = &H2
Private Const SWP_NOSIZE = &H1
Private Const SWP_NOZORDER = &H4

SetWindowPos me.hWnd,0,0,0,0,0,SWP_FRAMECHANGED or SWP_NOACTIVATE or SWP_NOMOVE or SWP_NOSIZE or SWP_NOZORDER


回复
zhangzhijian 2003-12-12
vbgood.com上有实例,去看看
回复
yaya1979 2003-12-10
试了一下,如果在按钮还原前做me.hide,还原后做me.show,就可以解决这个问题了,但是窗体会闪一下,不知道这样的操作对程序的运行有没有影响,我是用在串口通讯软件中的.
回复
da18a 2003-12-10
已经全了
回复
yaya1979 2003-12-10
真是好巧,我今天也要解决同样的问题,只要去掉关闭按钮,最大化最小化按钮保持
to SoHo_Andy(冰)
你的程序,运行后,窗体加载时没有关闭按钮,我单击按钮后,也没有恢复关闭按钮,只有最大化,最小化后才能恢复关闭按钮
回复
SaySorry 2003-12-10
在设计时,将form的controlbox属性改为false
如果是想失效的话
在窗体unload时间里写cancel=0
回复
davidlv 2003-12-10
在设计时,将form的controlbox属性改为false
回复
SoHo_Andy 2003-12-10
Public Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Long, _
ByVal bRevert As Long) As Long

Public Declare Function RemoveMenu Lib "user32" (ByVal hMenu As Long, _
ByVal nPosition As Long, ByVal wFlags As Long) As Long



'-----------禁止 ----------------------------
Dim hSysMenu As Long
Private Sub Command1_Click()
'---------- 还原 ------------------------------
GetSystemMenu Form1.hwnd, True
End Sub

Private Sub Form_Load()
hSysMenu = GetSystemMenu(Form1.hwnd, 0)
RemoveMenu hSysMenu, &HF060, 0
End Sub
回复
发动态
发帖子
VB基础类
创建于2007-09-28

7453

社区成员

VB 基础类
申请成为版主
社区公告
暂无公告