Solved

Changing Foreground color on a CommandButton

Posted on 1998-09-03
10
426 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
[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
  • 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
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 
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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…
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…

739 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