OnNcPaint blocks XP visual styles
-
I have an application that places a custom button on the window caption bar. However I am having a problem when running on Windows XP. I am finding that simply handling the WM_NCPAINT message causes XP to render the caption bar with the old Windows 2000 style. If I comment out ON_WM_NCPAINT() in the message map the caption bar is then drawn with the current XP style, put it back and the Windows 2000 style is used. To make matters worse GetSystemMetrics returns caption icon sizes that match the XP theme, even when it is rendering the Windows 2000 style. This means I have no way of calculating the icon size and position. I feel like I am trapped, I can't have the XP style because handling WM_NCPAINT automatically disables it, and I can't have the Windows 2000 style because GetSystemMetrics won't tell me the correct sizes. How does Microsoft expect people to now put icons on the caption bar? Has anybody put a custom icon on the caption bar of XP and retained the themed style, how did you do it? P.S. Popup dialog windows are render with the XP style regardless of what I do with the main window.
-
I have an application that places a custom button on the window caption bar. However I am having a problem when running on Windows XP. I am finding that simply handling the WM_NCPAINT message causes XP to render the caption bar with the old Windows 2000 style. If I comment out ON_WM_NCPAINT() in the message map the caption bar is then drawn with the current XP style, put it back and the Windows 2000 style is used. To make matters worse GetSystemMetrics returns caption icon sizes that match the XP theme, even when it is rendering the Windows 2000 style. This means I have no way of calculating the icon size and position. I feel like I am trapped, I can't have the XP style because handling WM_NCPAINT automatically disables it, and I can't have the Windows 2000 style because GetSystemMetrics won't tell me the correct sizes. How does Microsoft expect people to now put icons on the caption bar? Has anybody put a custom icon on the caption bar of XP and retained the themed style, how did you do it? P.S. Popup dialog windows are render with the XP style regardless of what I do with the main window.
'simply' handling WM_NCPAINT does not turn off visual styles as you claim. You are probably calling DrawFrameCtrl / some other API in your nc-paint handler - this is what is turning off the visual styles for the window. Replace all your drawing with a BitBlt and it'll work fine.
-
I have an application that places a custom button on the window caption bar. However I am having a problem when running on Windows XP. I am finding that simply handling the WM_NCPAINT message causes XP to render the caption bar with the old Windows 2000 style. If I comment out ON_WM_NCPAINT() in the message map the caption bar is then drawn with the current XP style, put it back and the Windows 2000 style is used. To make matters worse GetSystemMetrics returns caption icon sizes that match the XP theme, even when it is rendering the Windows 2000 style. This means I have no way of calculating the icon size and position. I feel like I am trapped, I can't have the XP style because handling WM_NCPAINT automatically disables it, and I can't have the Windows 2000 style because GetSystemMetrics won't tell me the correct sizes. How does Microsoft expect people to now put icons on the caption bar? Has anybody put a custom icon on the caption bar of XP and retained the themed style, how did you do it? P.S. Popup dialog windows are render with the XP style regardless of what I do with the main window.
-
'simply' handling WM_NCPAINT does not turn off visual styles as you claim. You are probably calling DrawFrameCtrl / some other API in your nc-paint handler - this is what is turning off the visual styles for the window. Replace all your drawing with a BitBlt and it'll work fine.
Yes you are right :-D I have confirmed that it is the drawing part of OnNcPaint that is stopping the visual style. Since I do my drawing after the default window processing completes, Windows must work out that I will be calling DrawFrameControl in the future and then render using the old Windows 2000 style. I think all I have to do now is replace DrawFrameControl with some theme based drawing when running on XP. I have just added to code to load the uxtheme.dll library and get pointers to theme functions I need to call. I think I just need to do the following with appropriate parameters to draw my icon... if (uxthemeloaded) { pOpenThemeData(...); pGetThemeBackgroundContentRect(...); if (pIsThemeBackgroundPartiallyTransparent(...)) { pDrawThemeParentBackground(...); } pDrawThemeBackground(...); pCloseThemeData(...); }