vb使关闭按钮不可用?怎样又使其变为可用?
假设有Command1和Command2,当点击Command1时窗体的关闭按钮变为灰色不可用,点击Command2时其又变为可用。...
假设有Command1和Command2,当点击Command1时窗体的关闭按钮变为灰色不可用,点击Command2时其又变为可用。
展开
4个回答
展开全部
建一个COmmand1,Command2。
代码如下。
================
Dim h As Long, l As Long
Private Const MF_BYPOSITION = &H400&
Private Const MF_ENABLED = &H0&
Private Const MF_DISABLED = &H2&
Private Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Long, ByVal bRevert As Long) As Long
Private Declare Function GetMenuItemCount Lib "user32" (ByVal hMenu As Long) As Long
Private Declare Function EnableMenuItem Lib "user32" (ByVal hMenu As Long, ByVal wIDEnableItem As Long, ByVal wEnable As Long) As Long
Private Sub Command1_Click()
EnableMenuItem h, l - 1, MF_BYPOSITION + MF_DISABLED
WindowState = 1
WindowState = 0
End Sub
Private Sub Command2_Click()
EnableMenuItem h, l - 1, MF_BYPOSITION + MF_ENABLED
WindowState = 1
WindowState = 0
End Sub
Private Sub Form_Load()
h = GetSystemMenu(hwnd, 0)
l = GetMenuItemCount(h)
End Sub
代码如下。
================
Dim h As Long, l As Long
Private Const MF_BYPOSITION = &H400&
Private Const MF_ENABLED = &H0&
Private Const MF_DISABLED = &H2&
Private Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Long, ByVal bRevert As Long) As Long
Private Declare Function GetMenuItemCount Lib "user32" (ByVal hMenu As Long) As Long
Private Declare Function EnableMenuItem Lib "user32" (ByVal hMenu As Long, ByVal wIDEnableItem As Long, ByVal wEnable As Long) As Long
Private Sub Command1_Click()
EnableMenuItem h, l - 1, MF_BYPOSITION + MF_DISABLED
WindowState = 1
WindowState = 0
End Sub
Private Sub Command2_Click()
EnableMenuItem h, l - 1, MF_BYPOSITION + MF_ENABLED
WindowState = 1
WindowState = 0
End Sub
Private Sub Form_Load()
h = GetSystemMenu(hwnd, 0)
l = GetMenuItemCount(h)
End Sub
微测检测5.10
2023-05-10 广告
2023-05-10 广告
您好!建议咨 深圳市微测检测有限公司,已建立起十余个专业实验室,企业通过微测检测就可以获得一站式的测试与认 证解决方案;(EMC、RF、MFi、BQB、QI、USB、安全、锂电池、快充、汽车电子EMC、汽车手机互 联、语音通话质量),认证遇...
点击进入详情页
本回答由微测检测5.10提供
展开全部
我只会让关闭按钮变为灰色不可用,不会让关闭按钮由灰色不可用变为可用。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
设置关闭窗体不可用
Private Sub Form_Unload(Cancel As Integer)
Cancel = True
End Sub
Private Sub Form_Unload(Cancel As Integer)
Cancel = True
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
=。=
直接在窗体的Unload事件中添加判断,如:
Private CanClose As Boolean '//能否关闭,TURE为可以关,FALSE为不可以
Priavate Sub Command1_Click()
CanClose = False
End Sub
Priavate Sub Command2_Click()
CanClose = True
End Sub
Private Sub Form_Unload(Cancel As Integer)
Cancel = IIf(CanClose, 0, 1)
End Sub
直接在窗体的Unload事件中添加判断,如:
Private CanClose As Boolean '//能否关闭,TURE为可以关,FALSE为不可以
Priavate Sub Command1_Click()
CanClose = False
End Sub
Priavate Sub Command2_Click()
CanClose = True
End Sub
Private Sub Form_Unload(Cancel As Integer)
Cancel = IIf(CanClose, 0, 1)
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询