如何实现VB的命令按钮command1单击后按钮上的文字变成红色,再单击变成默认的颜色?
3个回答
展开全部
代码是跟右下角的属性一样的。属性是什么名称,你代码就写什么名称,属性值有什么,你就填什么。
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Private Declare Function SetSysColors Lib "user32 " (ByVal nChanges As Long, lpSysColor As Long, lpColorValues As Long) As Long
Private Declare Function GetSysColor Lib "user32 " (ByVal nIndex As Long) As Long
Dim OriginalColor As Long
Dim NewColor As Long
Private Const COLOR_BTNTEXT = 18
Private Sub Command1_Click()
If NewColor = vbRed Then NewColor = OriginalColor Else NewColor = vbRed
SetSysColors 1, COLOR_BTNTEXT, NewColor
End Sub
Private Sub Form_Load()
OriginalColor = GetSysColor(COLOR_BTNTEXT)
End Sub
Private Sub Form_Unload(Cancel As Integer)
NewColor = OriginalColor
SetSysColors 1, COLOR_BTNTEXT, NewColor
End Sub
Private Declare Function GetSysColor Lib "user32 " (ByVal nIndex As Long) As Long
Dim OriginalColor As Long
Dim NewColor As Long
Private Const COLOR_BTNTEXT = 18
Private Sub Command1_Click()
If NewColor = vbRed Then NewColor = OriginalColor Else NewColor = vbRed
SetSysColors 1, COLOR_BTNTEXT, NewColor
End Sub
Private Sub Form_Load()
OriginalColor = GetSysColor(COLOR_BTNTEXT)
End Sub
Private Sub Form_Unload(Cancel As Integer)
NewColor = OriginalColor
SetSysColors 1, COLOR_BTNTEXT, NewColor
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询