Solved

Changing Foreground color on a CommandButton

Posted on 1998-09-03
10
423 Views
Last Modified: 2012-06-27
In VB5 I want to change the colors on a CommandButton to show a White Caption on a Red Backgound.

If  I change the Style property of the CommandButton to 1 (Graphical) and the BackColor property to VBRed then I get the background color I want.  However, there is no ForeColor property listed for a CommandButton, so the Caption letters remain Black, which is hard to read on the Red background.

Is there any way to do this, perhaps with an API call?

dougr
0
Comment
Question by:dougr
  • 6
  • 4
10 Comments
 
LVL 3

Accepted Solution

by:
a111a111a111 earned 50 total points
ID: 1432791
Hi,
Not with Vb properties.
You can make an Icon or a BMP file.

BUT Why not using a simple label to do the job of the command button?


0
 
LVL 3

Expert Comment

by:a111a111a111
ID: 1432792
If you want  example.
I will post it here.
0
 

Author Comment

by:dougr
ID: 1432793
To: a111a111a111

Thank you for your answer.  Can you make a Label look EXACTLY like a CommandBox with the raised 3-D effect etc?  If so, I welcome your code and will award the points. Whenever I have tried it, it either looks "flat" or if you put a border on it it looks like a TextBox".  There is also the little "shadow" effect on a CommandButton when it has the focus which is hard to create.

Otherwise how do you make an icon to look exactly like the text on a CommandButton?

dougr

PS What kind of a name is "a111a111a111".  If it is in HEX, I think it works out to 177,097,088,803,089 in Decimal.  Perhaps this is the distance to the nearest inhabited solar system!

0
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
LVL 3

Expert Comment

by:a111a111a111
ID: 1432794
Well First The name a111a111a111 was registered here because when I tried
to register as Shay It came back as name been use choose a diffrent one
then I tried Shay_E and so and so.

And I got suck with it because The sysytem here not allow you you change user name!!!!

0
 
LVL 3

Expert Comment

by:a111a111a111
ID: 1432795
Hi, I tried with
Option Explicit

Private Sub Form_Load()
Picture1.Picture = LoadPicture("e:\command3-1.gif")
End Sub

Private Sub Picture1_Click()
Picture1.Picture = LoadPicture("e:\command3-2.gif")
End Sub


But it is not the same as you like.

So i guess you have to do some API for this one.
0
 
LVL 3

Expert Comment

by:a111a111a111
ID: 1432796
Hi, I tried with
Option Explicit

Private Sub Form_Load()
Picture1.Picture = LoadPicture("e:\command3-1.gif")
End Sub

Private Sub Picture1_Click()
Picture1.Picture = LoadPicture("e:\command3-2.gif")
End Sub


But it is not the same as you like.

So I guess you have to do some API for this one.
0
 

Author Comment

by:dougr
ID: 1432797
To: a111a111a111

Thanks for the comments you made.  Unfortunately I am not too much closer to solving this puzzle.  Perhaps as you suggest it can't be done using the CommandButton properties, and anything else trying to SIMULATE a CommandButton (with labels, pictures, icons, BMP's etc.) just gets too complicated.

dougr
0
 
LVL 3

Expert Comment

by:a111a111a111
ID: 1432798
Hi I code a small project for you to dwonload from:
http://www.hili.com/~shay/menutest.zip

See if you like it.

Shay.
0
 

Author Comment

by:dougr
ID: 1432799
To: a111a111a111 (Shay)

Thanks for the little project you sent me.  It is heat how you created the little picture boxes with the icons in them.  I assume you have the originals of these little icons (bitmaps) stored on your disk somewhere because they were not in the zip file you sent.

This of course does not directly address the problem I am trying to solve, but I appreciate receiving this example of programming technique.  I am sure I will be able to use it in a future program I write.

I guess it is also possible to put bitmaps on top of Command Buttons to simulate the effect that I want.

dougr
0
 

Author Comment

by:dougr
ID: 1432800
To: a111a111a111

My comment should read "it is neat ...." NOT "it is heat"!
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

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…
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…

803 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