Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. OnNcPaint blocks XP visual styles

OnNcPaint blocks XP visual styles

Scheduled Pinned Locked Moved C / C++ / MFC
wpfregexhelpquestion
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    John Saunders
    wrote on last edited by
    #1

    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.

    J N 2 Replies Last reply
    0
    • J John Saunders

      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.

      J Offline
      J Offline
      James Brown
      wrote on last edited by
      #2

      '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.


      http://www.catch22.net

      J 1 Reply Last reply
      0
      • J John Saunders

        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.

        N Offline
        N Offline
        Naveen
        wrote on last edited by
        #3

        John Saunders wrote:

        This means I have no way of calculating the icon size and position.

        U can get the title bar height by taking the difference in the top of the window rect and client rect( do forget to call the ClientToScreen of the client rect ).

        nave

        1 Reply Last reply
        0
        • J James Brown

          '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.


          http://www.catch22.net

          J Offline
          J Offline
          John Saunders
          wrote on last edited by
          #4

          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(...); }

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups