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. Mixing UxTheme calls with GDI+

Mixing UxTheme calls with GDI+

Scheduled Pinned Locked Moved C / C++ / MFC
graphicsc++helpwinformscom
1 Posts 1 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.
  • W Offline
    W Offline
    WarnerYoung
    wrote on last edited by
    #1

    I have a set of custom controls (for pushbutton, checkbox and radiobutton) originally written in C++ and using standard GDI. Last year I added support for UxTheme API, and everything seems to work okay. Right now, I'm adding GDI+ support, and most things seem to work fine. The only problem is that I can't get UxTheme API and GDI+ to work together perfectly. It's *almost* right, but not quite. The code for this looks roughly like: hdcScrn = BeginPaint( hwnd, &ps ); hdcOffscreen = CreateCompatibleDC( hdcScrn ); hbmpBuffer = CreateCompatibleBitmap( hdcScrn, nWidth, nHeight ); SelectObject( hdcOffscreen, hbmpBuffer ); // Some code to blit the current window background // to the offscreen buffer in hbmpBuffer first. DrawThemeBackground( hTheme, hdcOffscreen, BP_PUSHBUTTON, nState, lprcClient, NULL ); BitBlt( hdcScrn, 0, 0, nWidth, nHeight, hdcOffscreen, 0, 0, SRCCOPY ); The new GDI+ version is pretty similar, except that I'm using Graphics* and Bitmap* objects. When I get to the part for DrawThemeBackground, I'm doing this: hdcReal = hGrfx->GetHDC(); DrawThemeBackground( hTheme, hdcReal, BP_PUSHBUTTON, nState, lprcClient, NULL ); hGrfx->ReleaseHDC( hdcReal ); The problem is, when I draw the offscreen buffer back to the screen, the edges of the pushbutton are too dark. It looks almost as if UxTheme call is not using alpha correctly, so the outer edges are too dark. I'm not sure if there's a good way to post screenshots on the site, so I've posted them on my own site. std GDI version GDI+ version As you can see, the dialog background is a custom texture, so I don't think I can call DrawThemeParentBackground. Anyone hints or help on this would be greatly appreciated. -- Warner Young

    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