View Full Version : win32\C++: Modify dialogbar's color

02-13-2005, 05:06 AM
Given a window's HWND, is there a way to programatically change the color of the dialogbar (the top horizontal bar that has the app title, and the minimize, maximize, and kill buttons)? I can get it's CWnd object executing CWnd::FromWindowHandle(), and muck around there, but apart from changing text properties and size/position I haven't found anything close to what I want to do.


Dr. Evil
02-13-2005, 09:13 AM
I think you can catch the WM_NCPAINT and WM_NCACTIVATE messages. Here are two articles about it, if these help at all.

02-13-2005, 02:58 PM
Didn't read those links, so they probably mention this but I'll say it anyway.

Catch the WM_NCPAINT (NC is the non client area).

case WM_NCPAINT: {
DefWindowProc( hwnd, msg, wParam, lParam );
return paintNonClientArea( hwnd, (HRGN)wParam );

If you don't call DefWindowProc() it will paint over your modifications, I don't know why, the windows documentation contradicts itself on this if I remember correctly.. so it's obviously an algorithm problem on the API side. So what you're doing is painting over their own paint job, slightly slower I guess but it's the only way until we can move to avalon.

Make sure to release the DC.

[edit:] Just noticed you're using MFC. I hate that bloated shemozzle of a library so I wouldn't know if the above code chunk is suitable.