Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 226
  • Last Modified:

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.
0
riaz9
Asked:
riaz9
1 Solution
 
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
 
ChessCommented:
Try cmdAdd.BackColor=vbred
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
rpaiCommented:
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
 
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

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now