• Advertisement
Sign in to follow this  

Using Theming with GDI

This topic is 1981 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey everyone

Im currently experimenting a bit with theming provided with windows. Before i explain my problem in detail ill post the code, that makes it a lot easier to understand:

Version 1:
[source lang="cpp"]
IDirect3DSurface9* surf;
gTexture->GetSurfaceLevel(0, &surf);

HDC hDc = 0;
surf->GetDC(&hDc);
renderDC = CreateCompatibleDC(hDc);

auto bmp = CreateCompatibleBitmap(renderDC, widht, height);
SelectObject(renderDC, bmp);

RECT theRect = { 0, 0, widht, height };
FillRect(renderDC, &theRect, (HBRUSH)GetStockObject(WHITE_BRUSH));

HTHEME theme = OpenThemeData(hWindow, L"BUTTON;Edit;Progress");
RECT rc = { 0, 100, 100, 120 };
DrawThemeBackground(theme, renderDC, BP_CHECKBOX, CBS_CHECKEDNORMAL, &rc, nullptr);
CloseThemeData(theme);

surf->ReleaseDC(hDc);
surf->Release();
[/source]
Later i BitBlt the content of the renderDC into a aquired DC of the surface and render the texture. What happens:
The screen ist completely white, nothing is drawn by DrawThemeBackground! If i use functions like TextOut or again FillRect with another rect everything is drawn, except the part with DrawThemeBackground.

Version 2:
I replace renderDC in FillRect and DrawThemeBackground with hDc (the DC of the surface). Result: The checkbox gets drawn as it should.

Version 3:
i do the Theme drawing (DrawThemeBackground) right where the frame rendering happens. Again i render into renderDC, and then BitBlt it to the texture. Excatly the same as version 1.

Why are versions 1 and 3 not working? renderDC is a compatible DC and all drawing works except for the stuff with theming!

Greetings
Plerion

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement