VB中怎样使窗口右上角的关闭按钮失效?ALT+F4也失效!

并且在点击关闭按钮或按ALT+F4时弹出MSGBOX~需要加入什么语句?能粘贴的最好~... 并且在点击关闭按钮或按ALT+F4时弹出MSGBOX~
需要加入什么语句?能粘贴的最好~
展开
 我来答
zaqryu
2006-02-11 · 超过14用户采纳过TA的回答
知道答主
回答量:78
采纳率:0%
帮助的人:0
展开全部
我晕,看以下代码,绝对没问题!
Option Explicit

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

Private Const MF_BYPOSITION = &H400&

Private ReadyToClose As Boolean
Private Sub RemoveMenus(frm As Form, _
remove_restore As Boolean, _
remove_move As Boolean, _
remove_size As Boolean, _
remove_minimize As Boolean, _
remove_maximize As Boolean, _
remove_seperator As Boolean, _
remove_close As Boolean)
Dim hMenu As Long
hMenu = GetSystemMenu(hwnd, False)
If remove_close Then DeleteMenu hMenu, 6, MF_BYPOSITION
If remove_seperator Then DeleteMenu hMenu, 5, MF_BYPOSITION
If remove_maximize Then DeleteMenu hMenu, 4, MF_BYPOSITION
If remove_minimize Then DeleteMenu hMenu, 3, MF_BYPOSITION
If remove_size Then DeleteMenu hMenu, 2, MF_BYPOSITION
If remove_move Then DeleteMenu hMenu, 1, MF_BYPOSITION
If remove_restore Then DeleteMenu hMenu, 0, MF_BYPOSITION
End Sub

Private Sub cmdClose_Click()
ReadyToClose = True
Unload Me
End Sub

Private Sub Form_Load()
RemoveMenus Me, False, False, False, False, False, True, True
End Sub

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
Cancel = Not ReadyToClose
End Sub
mwcui
2006-02-10 · 超过64用户采纳过TA的回答
知道小有建树答主
回答量:274
采纳率:0%
帮助的人:237万
展开全部
把Form的属性中BorderStyle改为0-None
不用语句也可以。在属性面板中选择就可以了
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

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

类别

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

说明

0/200

提交
取消

辅 助

模 式