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