Solved

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

Posted on 2002-06-26
12
213 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
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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

920 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now