Maintain visual style for button

Ask your PowerShell-related questions, including questions on cmdlet development!
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Locked
StupidSexyFlanders
Posts: 107
Joined: Sun Nov 27, 2011 9:22 am

Maintain visual style for button

Post by StupidSexyFlanders »

I need to change a button from its inherited color to something else. That's easy enough to do, but it seems to also change the default visual style (i.e. two-tone) to a single color button.

I've poked around and read a few things about resetting the UseVisualStyleBackColor property before setting the BackColor property. But the best I've been able to do so far is change the color of the button text -- the button color itself stays the same.
Mike

StupidSexyFlanders
Posts: 107
Joined: Sun Nov 27, 2011 9:22 am

Maintain visual style for button

Post by StupidSexyFlanders »

I need to change a button from its inherited color to something else. That's easy enough to do, but it seems to also change the default visual style (i.e. two-tone) to a single color button.

I've poked around and read a few things about resetting the UseVisualStyleBackColor property before setting the BackColor property. But the best I've been able to do so far is change the color of the button text -- the button color itself stays the same.
Mike

jvierra
Posts: 14576
Joined: Tue May 22, 2007 9:57 am
Answers: 1
Been upvoted: 1 time
Contact:

Maintain visual style for button

Post by jvierra »

Are you using PrimalForms or PowerShell Studio?

jvierra
Posts: 14576
Joined: Tue May 22, 2007 9:57 am
Answers: 1
Been upvoted: 1 time
Contact:

Maintain visual style for button

Post by jvierra »

Swet UseVisualStyleBackColor and select the color you want from the dropdown.

The colors are limited to what is in the dropdown and that will vary from system to system. ALL are cross compatible. I think Win7 has more variations but I am not sure.


StupidSexyFlanders
Posts: 107
Joined: Sun Nov 27, 2011 9:22 am

Maintain visual style for button

Post by StupidSexyFlanders »

Yeah, I get how the color can be changed. What I can't do is change the color AND maintain the modern look-and-feel of the default. If I set UseVisualStyleBackColor to $true, set the backcolor to something, it stays grey:


If I set the FlatStyle property to Flat or PopUp the new color shows up. But then it loses the visual style:


Here the general idea of what I am hoping to achieve:
Mike

jvierra
Posts: 14576
Joined: Tue May 22, 2007 9:57 am
Answers: 1
Been upvoted: 1 time
Contact:

Maintain visual style for button

Post by jvierra »

You can't have both. VisualStyle limits you to the 'chrome' and teh colors of the 'theme'. Flat and Popup do not use the chrome or them. "Flat' means flat not fancy.

You can get custom controls that will do what you are trying to do.d

StupidSexyFlanders
Posts: 107
Joined: Sun Nov 27, 2011 9:22 am

Maintain visual style for button

Post by StupidSexyFlanders »

Excellent. That's what I needed to know. Thanks a lot!
Mike

Locked