How to change backcolor for Command Buttons 
Author Message
 How to change backcolor for Command Buttons

I've tried to change the backcolor of a command button to something other
than the default gray.  All other controls seem to change.  I've tried
changing the backcolor at design time and through code - to no avail. I
even tried this code:

Private Sub Form_Load()
For Each Control In Controls()
    Control.BackColor = vbBlue
Next
End Sub

The backcolor of every control on the form changes to blue EXCEPT the
command buttons.

Any ideas?



Sat, 12 Jun 1999 03:00:00 GMT  
 How to change backcolor for Command Buttons

There are two "solutions" to this problem.  

One is to create buttonUp, buttonDown, and buttonDisabled pictures, and
load them into an image control.  Use the mouseDown/mouseUp messages to
press and raise the button.  The advantage of this method is that you can
make any image you want act like a button.  The disadvantage is that you
have to create the pictures.

The second solution is to subclass the button control using a subclassing
control.  Intercept the paint message and paint the button with anything
you want.



Quote:
> I've tried to change the backcolor of a command button ...



Sat, 12 Jun 1999 03:00:00 GMT  
 How to change backcolor for Command Buttons

Quote:

> I've tried to change the backcolor of a command button to something other
> than the default gray.  All other controls seem to change.  I've tried
> changing the backcolor at design time and through code - to no avail. I
> even tried this code:

> Private Sub Form_Load()
> For Each Control In Controls()
>     Control.BackColor = vbBlue
> Next
> End Sub

> The backcolor of every control on the form changes to blue EXCEPT the
> command buttons.

> Any ideas?

Im kinda new at this too, but why not trynig to change the NAME of each
command button in the form. Not having them all be "Command1". Try
something like: cmdCancel and then try your method.

This could be occuring because the names of all commands are Command1,
no?

Well, hope this helps.



Sat, 12 Jun 1999 03:00:00 GMT  
 How to change backcolor for Command Buttons

Quote:

>>> I've tried to change the backcolor of a command button to something other

than the default gray.<<<

The BackColor property of a command buttone isn't what you
think it is. It's actually the 4 corner pixels on the button.
If you place a button on a black background, you can see them
clearly.

What you're looking for was previously called the Button Face color.
It is now called "3D Objects" in the Win95/NT4 Display control panel.
This is a user defined setting that a programmer shouldn't tamper with
except under very specific situations (such as an info kiosk app or
point of sale).

If you need different button colors, then you can use various third
party programs that provide this feature or build 'fake' buttons with
other standard controls like the picture box or label.

Frank Carr



Sun, 13 Jun 1999 03:00:00 GMT  
 How to change backcolor for Command Buttons

Quote:


>> I've tried to change the backcolor of a command button to something other
>> than the default gray.  All other controls seem to change.  I've tried
>> changing the backcolor at design time and through code - to no avail. I
>> even tried this code:

>> Private Sub Form_Load()
>> For Each Control In Controls()
>>     Control.BackColor = vbBlue
>> Next
>> End Sub

>> The backcolor of every control on the form changes to blue EXCEPT the
>> command buttons.

>> Any ideas?
>Im kinda new at this too, but why not trynig to change the NAME of each
>command button in the form. Not having them all be "Command1". Try
>something like: cmdCancel and then try your method.

>This could be occuring because the names of all commands are Command1,
>no?

>Well, hope this helps.

You can't.  It won't.  Give it up.

There is a bug in VB4 (carried over from VB3 I'm told) that won't
allow you to change the backcolor of a control button, even though
that option is indeed there.

Maybe somebody has written a custom control for this?



Wed, 30 Jun 1999 03:00:00 GMT  
 How to change backcolor for Command Buttons



Quote:


> >> I've tried to change the backcolor of a command button to something
other
> >> than the default gray.  All other controls seem to change.  I've tried
> >> changing the backcolor at design time and through code - to no avail.
I
> >> even tried this code:

> >> Private Sub Form_Load()
> >> For Each Control In Controls()
> >>     Control.BackColor = vbBlue
> >> Next
> >> End Sub

> >> The backcolor of every control on the form changes to blue EXCEPT the
> >> command buttons.

> >> Any ideas?
> >Im kinda new at this too, but why not trynig to change the NAME of each
> >command button in the form. Not having them all be "Command1". Try
> >something like: cmdCancel and then try your method.

> >This could be occuring because the names of all commands are Command1,
> >no?

> >Well, hope this helps.

> You can't.  It won't.  Give it up.

> There is a bug in VB4 (carried over from VB3 I'm told) that won't
> allow you to change the backcolor of a control button, even though
> that option is indeed there.

> Maybe somebody has written a custom control for this?

If you have VB3 or 4 Pro, use the SScommand button.
Make a small bitmap in Paint or whatever, then
you can put this bitmap picture on this button using LoadPicture
in the form's Load event.
This way you can put textures or whatever on your buttons.
The backcolor property of the command buttons only refers
to the four corner pixels of the button!

HTH

Bengt.



Thu, 01 Jul 1999 03:00:00 GMT  
 How to change backcolor for Command Buttons



Quote:

>>> I've tried to change the backcolor of a command button to something other
>>> than the default gray.  All other controls seem to change.  I've tried
>>> changing the backcolor at design time and through code - to no avail.Well, hope this helps.

>You can't.  It won't.  Give it up.

>There is a bug in VB4

Piffle!  Poppycock!  Balderdash!  This has cropped up innumerable times
on this newsgroup.

1.  The background colour property does not refer to the button colour:
it refers to 4 pixcels, one in each corner of the button, which you can
make equal to the form's background colour, so that the button appears
to have rounded corners.

2.  Mircosoft deliberately disallow differently-coloured buttons so that
the look-and-feel of all applications is the same.

--
Peter Hesketh, Mynyddbach, Gwent, UK
"Pas d'elle yeux Rhone que nous",  Sam Lloyd



Fri, 02 Jul 1999 03:00:00 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. can't change command button backcolor

2. backcolor command button problem

3. BackColor of Command button

4. Command Button Backcolor (VB3)

5. Wordwrap and BackColor in Command Buttons?

6. Command Button Backcolor

7. BackColor Property on Command Button

8. Backcolor of Command-Button

9. Setting Backcolor on Command Buttons

10. Setting Backcolor on Command Buttons

11. Visual Basic 4.0 - 2 Questions - Command Button Backcolor, Public Statement

12. Command button BackColor

 

 
Powered by phpBB® Forum Software