|
-
December 16th, 1999, 01:08 AM
#1
how to change Button Text Color
How can i change the command button text color , run time also.
-
December 16th, 1999, 06:22 AM
#2
Re: how to change Button Text Color
There are two ways of doing this -
1. Subclassing - lot's of code to write for the handling of painting the button text. I think you can find examples at either http://www.matthart.com or http://www.mvps.org/vbnet
2. Cheat !
You can place a checkbox on a form and set it's style to '1 - Graphical'. This then looks just like a button but you can change it's back and forecolor at runtime. All you need to be careful of is the click event where the button can stay 'clicked' - just paste this code into a form (FORM1) with a graphical check box (Check1) :
private Sub Check1_Click()
Check1.Value = vbUnchecked
Check1.ForeColor = RGB(Rnd(1) * 255, Rnd(1) * 255, Rnd(1) & 255)
Check1.BackColor = RGB(Rnd(1) * 255, Rnd(1) * 255, Rnd(1) & 255)
End Sub
private Sub Form_Load()
'
' Make sure Check1 has style set to '1-Graphical'
'
Check1.ForeColor = vbBlue
End Sub
- The only problem I can see doing it this way is that CheckBoxes can't have the 'default' or 'cancel' properties (although you could use keypreview to do the same things).
Chris Eastwood
CodeGuru - the website for developers
http://codeguru.developer.com/vb
-
December 16th, 1999, 07:02 AM
#3
Re: how to change Button Text Color
BTW, i do precisely that soln of Chris.. use Check Boxes.. and it works quite fine for me
RK
-
December 16th, 1999, 09:01 AM
#4
Re: how to change Button Text Color
If you go to http://www.castlems.com/ammb.html they have a ActiveX control that you can put into your project that allows you to have alot of flexibility in designing all types of buttons etc.
I use this alot in my apps and have never had any problems.
Hope this helps
tcompe
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|