Solved

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

Posted on 2002-06-26
12
218 Views
Last Modified: 2008-02-26
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
Comment
Question by:riaz9
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
12 Comments
 
LVL 3

Expert Comment

by:SirNick
ID: 7110658
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
 

Expert Comment

by:VBGuy91917
ID: 7110698
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
 
LVL 1

Expert Comment

by:Chess
ID: 7110726
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!

 
LVL 5

Accepted Solution

by:
rpai earned 50 total points
ID: 7110730
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
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 7111340
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
 
LVL 1

Author Comment

by:riaz9
ID: 7112818
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
 
LVL 1

Author Comment

by:riaz9
ID: 7112823
Hi rpai,

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

thanks
Riaz
0
 
LVL 1

Author Comment

by:riaz9
ID: 7121130
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
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 7122102
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
 
LVL 1

Author Comment

by:riaz9
ID: 7123871
I'll keep that in mind Richie_Simonetti.

Thanks everybody
0
 

Expert Comment

by:DrSpiriT
ID: 7403879
    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
 
LVL 1

Author Comment

by:riaz9
ID: 7418446
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question