views:

110

answers:

1

Hello. I create new desktop with CreateDesktop and want to get it's DC & RC.

   RECT deskRC;
   HDC deskDC;
   HDESK hNewDesktop = CreateDesktop(...);

   GetWindowRect(hNewDesktop, &deskRC);
   deskDC = GetDC(hNewDesktop);

This returns only 0's. What's the problem? Or maybe there's another way of obtaining those values.

P.S.: Desktop creates normally.

Yet another problem:

Thanks. I encountered another problem, with DC this time.

   HDESK hNewDesktop = CreateDesktop("text_here", NULL, NULL, 0, GENERIC_ALL, NULL);
   SetThreadDesktop(hNewDesktop);
   SwitchDesktop(hNewDesktop);

HWND deskHW = GetDesktopWindow();
GetWindowRect(deskHW, &deskRC);
deskDC = GetWindowDC(deskHW);

deskDC is incorrect :( (Tested with original one and it was OK; I use it for drawing stuff)

No idea what's wrong this time.

A: 

GetWindowRect and GetDC work with windows; a desktop is not a window. You could try switching to the desktop via SwitchDesktop then getting its window via GetDesktopWindow; don't forget to switch back to the previous desktop.

Luke
Thanks. New problem appeared. Check the question, please.
Desu_Never_Lies
What do you mean that it is "incorrect"? I just tried and I get a non-NULL DC handle.
Luke