views:

325

answers:

2

Hi! I am having a strange problem ( well, at least i find it strange =) ). I am writing my own GUI library, which is a wrapper around windows api (and yes, i am aware of WTL and frameworks like MFC =) ). At the current stage i have incapsulated common controls in such manner: for example, Edit class consists of a simple window and an standard edit window above it ( MainWindow -> GhostWindow -> EditBox ). That is how i can for example change a background colour of an edit inside an edit class itself:

myedit->SetBkColor ( RGB ( 0, 0, 0 ) );

And it worked fine, until i called InitCommonControlsEx and attached manifest file to my program. After doing this, my edits become capable of changing colours only when they have focus. To be honest, i don't have a comprehensive thoughts about why do the behave like this and what am i doing wrong, so i will appreciate any help.

Thank you, #535.

A: 
  1. When you attach the version 6 manifest, the call to InitcommonControlsEx becomes unnecessary.

  2. Anyway. with the version 6 common controls loaded, XP theming is used even for the standard windows controls. The background colors for the controls are painted using the xp-theme color, so the WM_CTLCOLOR* messages are used less.

  3. You are currently overriding the coolor of various control elements using the WM_CTLCOLOR* messages?

Chris Becke
1. Oh, thank you, i didn't know about that.2. Ok, but is there a way to make a control behaviour more specific. My goal is to make control, that can change background when i hover a mouse over it, and then changes back when mouse cursor leaves. The only reason, why i want to use winXp theming, is that default old-style buttons are extremely ugly.3. Yes.
n535
Other than making the control fully custom paint I don't belive that its possible to override the background color of the control from the xp-theme color.One thing I havnt investigated is actually making a set of theme data, and loading it,using the theme apis, as the current apps theme. I belive its not possible to create new system themes as uxtheme.dll will only load signed (by MS) theme files, I don't know if that applies to a per-app theme. (assuming such a thing is even possible).
Chris Becke
The "Visual Styles Reference" in MSDN is both promising and not: There are a lot of API's for doing all kinds of things with theme data, but no apparent way to generate your own. It basically *seems* to amount to nothing more than a massive document describing how ux-theme, internally, sets about drawing standard windows controls.
Chris Becke
Thank you! As far as i figured out, using xp-themed controls brings some restrictions and unfortunately there is nothing i can do about it.
n535
Hmm... There is actually one more thing i am trying to figure out, is there a way to load only specific controls from version 6 ctrl library, but as far as i know, this is impossible =(
n535
A: 

Well, everything is much easier, than i thought. I was just too inattentive =( When one don't use styling, one cane use ::SetBkColor(...) to change background colour, and return a brush from WM_CTLCOLOR* to change a border colour. Things become different after enabling styling. Now ::SetBkColor(...) correspond to focus colour and returning brush changes background colour. Shame on me =(

n535