How can I change the foreground color of a Command Button and center a picture

I want to change to default color of a Command button from black to anything else.  

I do not want to use any other control to replace this.  Is it also possible to center an image on a command button with style = graphical.

What is happening now is if i increase the font size of the command button, the image gets pushed out.  Any way to center image ?

Thanks in advance.
LVL 1
riaz9Asked:
Who is Participating?
 
rpaiConnect With a Mentor Commented:
riaz9,
What you could do is use the CommandButton object from Microsoft Forms 2.0 Library instead.
(Goto Project --> Components --> Microsoft Forms 2.0 Library)
Select the CommandButton. This CommandButton provides you an in-built ability to change the ForeColor/BackColor and also the PicturePostion.

0
 
SirNickCommented:
Hello riaz9

I know that you have said that you do not want to use any other control apart from a commandbutton, but just try this.

1\  Add a checkbox control onto your form called check1
2\  Set the checkbox style property to graphical
3\  You can now change the font colors

Now in the checkbox click event you have to make sure the button clicks back to look normal and not pressed in, do this by adding 'check1.value = false' after your code.  For example

Private Sub Check1_Click()
    form1.Caption = "This is a test"
    Check1.Value = False
End Sub


Hope this helps...
0
 
VBGuy91917Commented:
You could include the text you want in the button in the image you're using and make the text the color you want that way.
0
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

 
ChessCommented:
Try cmdAdd.BackColor=vbred
0
 
Richie_SimonettiIT OperationsCommented:
I am with sirnick.
If you want to keep with a "real" command button, try this:
http://www.vbthunder.com/source/button/ExtButton.htm
0
 
riaz9Author Commented:
Hi SirNick,

Yours seems to be a smart idea to simulate the functionality of a command button. I'll try that and get back.

thanks
Riaz
0
 
riaz9Author Commented:
Hi rpai,

Yours is also an alternative solution. I'll try that too and get back.

thanks
Riaz
0
 
riaz9Author Commented:
Simple way to achieve what i am looking for.
Would be nice if the image resized too.

I also accept SirNick's answer since this too does what i want with a different control, but results are the same.

I have posted points separtely for SirNick
0
 
Richie_SimonettiIT OperationsCommented:
Yoiu do what you wish, of course but take in mind that you are using an Object of such size just to get a little funcionality. Don't forget to be sure that files required by Microsoft Forms are included in your package when would be deployed it.
Cheers
0
 
riaz9Author Commented:
I'll keep that in mind Richie_Simonetti.

Thanks everybody
0
 
DrSpiriTCommented:
    Your accepted answer, isn't that great of a solution.  It works, but if you plan on distributing any program using the Microsoft Forms 2.0 Library it's a bad idea.  Not everyone has Fm20.dll (Microsoft Forms 2.0 Library) on their computers.  The only way people can get this file installed on their computers is to install a microsoft application that includes the Fm20.dll.  Microsoft Office 97 would be an example.  Also the Microsoft ActiveX Control Pad offers it.  So I wouldn't suggest using the Microsoft Forms 2.0 Library unless it's just for your personal use.
0
 
riaz9Author Commented:
DrSpiriT,

I understand what you have said, this has already been suggested by Richie Simonetti.  I have also accepted the answer proposed by Sirnick - refer my comment dated. 06/30/2002 11:28PM PST.

If you have a better solution, please post it.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.