Solved

Changing Foreground color on a CommandButton

Posted on 1998-09-03
10
420 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
Comment Utility
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
Comment Utility
If you want  example.
I will post it here.
0
 

Author Comment

by:dougr
Comment Utility
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
 
LVL 3

Expert Comment

by:a111a111a111
Comment Utility
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
Comment Utility
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 3

Expert Comment

by:a111a111a111
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
To: a111a111a111

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

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

772 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

10 Experts available now in Live!

Get 1:1 Help Now