?
Solved

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

Posted on 2002-06-26
12
Medium Priority
?
223 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 5

Accepted Solution

by:
rpai earned 200 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses

719 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