Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change color of a command button

Status
Not open for further replies.

dvannoy

MIS
May 4, 2001
2,765
US
Is it possible to change the color of a command button to white?..

Thanks in advance
DVannoy
MIS
A+,Network+,CNA
 
The simple answer is no!. But, there is always another way with Access or VB.

You can create a command button and set its Transparent property to Yes. Then Place a label on top of the command button and make it the same shape as the command button - you have to play with it to make the caption work well. Set the color the way you want then go into the code behind the form:

Place this code:

Private sub lblCmdButton_MouseDown(Button as Integer, Shift as integer, X as single, Y as single)
Select Case Button
Case acLeftButton
Me.lblCmdButton.SpecialEffect = 2 'For the sunken effect
Case acRightButton
Me.lblCmdButton.SpecialEffect = 1 'To keep it raised
end select

end sub

Private sub lblCmdButton_MouseUp(Button as Integer, Shift as integer, X as single, Y as single)
Select Case Button
Case acLeftButton
Me.lblCmdButton.SpecialEffect = 1'For the sunken effect
Case acRightButton
Me.lblCmdButton.SpecialEffect = 1 'To keep it raised
end select

end sub

You have to play with it, but it does give you some control over how a button is presented. It ain't perfect, but what is?

Bob


 
I've done something similar to rbowes, but instead all I use is two labels. First you make two labels, make one blank (your button, let's call it lblButton) and have the other with your "button" text (let's call it lblCaption). Size the caption to just big enough to see the text. Now in the mouse down of each (lblButton and lblCaption place this code:

[tt]
lblCommand.SpecialEffect = 2 'sets sunken effect on button
lblCaption.BorderStyle = 4 'puts dotted border around caption
[/tt]

In the MouseUp event of each place this code:

[tt]
lblCommand.SpecialEffect = 1 'sets raised effect on button
lblCaption.BorderStyle = 0 'removes dotted border
[/tt]


Then you just place the code you want to run when your "button" is clicked in the OnClick event of both the caption and the "button". Hope that helps!

Joe Miller
joe.miller@flotech.net
 
PS - If you want to get REAL fance you can also move the caption down and to the left just like a button. Just add the code below to do it.

To the MouseDown events add this:
[tt]
lblCaption.Top = lblCaption.Top + 10
lblCaption.Left = lblCaption.Left + 10
[/tt]

To the MouseUp events add this:
[tt]
lblCaption.Top = lblCaption.Top - 10
lblCaption.Left = lblCaption.Left - 10
[/tt]


It's actually pretty convincing when you do all this, it's a lot of work but it looks good.

Joe Miller
joe.miller@flotech.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top