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
展开全部
我只会让关闭按钮变为灰色不可用,不会让关闭按钮由灰色不可用变为可用。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
设置关闭窗体不可用
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
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询