• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 686
  • Last Modified:

Why white background of GUI elements on Windows XP/Vista ?

Hi,

I am facelifting the old Windows application. After adding the manifest, I can see some of the GUI elements rendered nicely (buttons), but some of them have white background even though it should be related to the background color of the parent window. How to fix it?

I am using Windows API (C++, ATL, WTL). Is it related to the element styles?

Thanks,
   Petr

P.S. Ready to specify details...
UnwantedWhiteControlBackground.png
0
pepr
Asked:
pepr
  • 5
2 Solutions
 
evilrixSenior Software Engineer (Avast)Commented:
Speculative answer: Controls from modern tecnologies, for example those with WPF, will conform to the current Windows theme. It's possible that if these are older controls (maybe MFC or Win32) they are not aware of theme and so do not honor it's look and feel.
0
 
peprAuthor Commented:
When the same controls are the part of dialogs (i.e. windows constructed from dialog resources) then the look is fine. The controls are the very basic controls that are supported by the windows core (like the "static").
0
 
Lukasz ChmielewskiCommented:
it seems that the background color for the controls is not "supported" with newer systems. i.e. NavyBlue bg color of the control might just not be handled by vista. i had the same issue with my application having black color instead of "palewhite" in windows vista. i changed it simply to "white" and it looks ok
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
peprAuthor Commented:
To Roads_Roads: I did use the, say, CStatic control directly from WTL 8.0. It seem that it defines white background implicitly. After changing the parent window background to white, the controls are placed "seemlessly".

Anyway, I want the opposite. I want the window to look like a dialog window -- with gray background (I guess it is a COLOR_3DFACE background colour).

To evilrix: Good idea. Still, I believe that it should handle standard controls (Win32) nicely. When the buttons can be rendered that nicely, there is no reason not to handle the static text also nicely.

This probably means that I should use explicitly a different WNDCLASS for the controls to define that background color. As the WTL::CStatic is defined as "typedef CStaticT<ATL::CWindow>   CStatic;", it seems that I need to derive new window class from ATL::CWindow, give it the WNDCLASS with the other background, and define say "typedef CStaticT<CWindowGrey> CStaticGrey;".

Meanwhile, if you have any other idea...
   Thanks,
      Petr





0
 
peprAuthor Commented:
I was not successful. Please, have a look at my new question with the related tiny old-looking sample -- http:Q_24348167.html

Petr
0
 
peprAuthor Commented:
I have found the reason. You might never observe the behaviour because it depends on where the window messages go and how they are handled. Because of rather specific redirection of messages in our application, the WM_CTLCOLORSTATIC message was reflected back to the child window. It means that the parent did not care about erasing the backround of the static. The static text (GUI element) received the reflected message and used the white colour. It was fixed by not reflecting the WM_CTLCOLORSTATIC message and having the DefWindowProc() do it correctly (default behaviour).
0
 
peprAuthor Commented:
Fixed. See the actual reason for the behaviour below. Anyway, thak you for trying to help me.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now