开发者

is HDC handle valid for another process?

i am creating clipped HDC (Device Context) handle using windows开发者_运维知识库 api, then sending it to another process. Will be this handle valid for drawing in it?


You will need to expose a method of drawing onto the DC from within your application.

The most likely candidates are Windows Messages defined by you (WM_APP or WM_USER).

WM_USER + 1,
WM_USER + 2,
WM_USER + 3,
etc...

then you would handle those in your applications WNDPROC

switch case
{
  WM_USER + 1:
   // draw a circle
  WM_USER + 2:
   // draw a rectangle
  WM_USER + 3:
   // draw a snowman
}

finally from a third party application, they would simple send messages to your application via the SendMessage API:

SendMessage(hWndSergey, WM_USER + 1, 0, 0);

where the LPARAM and WPARAM can be pointers to global shared memory to exchange parameters or simply dword values etc...

http://msdn.microsoft.com/en-us/library/ms644950(v=VS.85).aspx


A Device Context handle is not going to be valid in another process. Consider exposing an interface that the other process can use to draw in your window.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜