0

I like to add some annotation features on a existing window. So I get the window handler, but now I like to create a drawing layer for drawing some text and so on the top of this window.

So what's the best practice? I need a new layer because sometimes I like to clear the drawing items on this layer. Currently, I'm using this:

Graphics newGraphics = Graphics.FromHwnd(hwnd);

but I like to delete these drawed graphic objects, so the original image will be displayed.

I could save the original image part before, but maybe there is still a solution which handles this.

Sinatr
  • 20,892
  • 15
  • 90
  • 319
Kinimod
  • 166
  • 1
  • 15
  • 'existing window' means another application for which you don't have or want to modify the sources? – TaW Feb 09 '17 at 14:19
  • You can [draw on desktop](http://stackoverflow.com/q/14385838/1997232). To *delete* what you've drawn you have to invalidate corresponding region, that would cause windows to redraw their content. Small note: windows will redraw themselves (thus deleting your annotations), you can draw periodically (flickering). Another idea is to create maximized transparent window without nonclient area (without tittle, border, etc.) and make it topmost and draw annotation there. See [this](http://stackoverflow.com/a/33531201/1997232) answer. – Sinatr Feb 09 '17 at 14:23
  • Right, the window is part of another application. I can get this by the hwnd. Now, I like to add a layer of top for drawing some things. So I like to add new layer of graphic objects for beeing able to delete them seperate. – Kinimod Feb 09 '17 at 14:24
  • Good idea. Tried to use InvalidateRect(IntPtr hWnd) of user32.dll for a specific window, but it works not in all windows. I guess it's not working because the feature is not implemented in this corresponding window application. – Kinimod Feb 09 '17 at 14:58
  • Acutally I would expect you need to call Invalidate on your drawing overlay. After deleting the draw data, of course.. – TaW Feb 09 '17 at 16:27

0 Answers0