开发者

Get DC & RC from new desktop

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜