How to draw “on top” of hosted controls in .NET?

I am working on a simple form builder that places .NET "live" objects, and also performs my own drawing for guides (grids), selecting objects, etc. Everything is going well, but, as you see below, the user picture is not entirely optimal, since it always paints the placed controls.

Example selection http://img405.imageshack.us/img405/8572/selectsample01.png

How can I change my drawing logic to draw “on top” of all placed controls?

If the image is not in your SO view, you can see it here:    http://img405.imageshack.us/img405/8572/selectsample01.png

+3
source share
2 answers

This is not a Z-order problem. The problem is that you cannot draw inside the client rectangle of another window. The "Text" window in your case. A window like your form has a WS_CLIPCHILDREN style flag.

I'm not quite sure how a Windows Forms designer can draw selection markers around controls. But when I look at the designer with Spy ++, I see two other invisible windows that are the size of the design area. They are called "OverlayControl" and "AdornerWindow". I assume that the designer is actually drawing pens in one of these windows (possibly OverlayControl) and that the Windows background is transparent.

, . .

+1

, , , .

, z- .

z-, , z-.

z-, .

0

Source: https://habr.com/ru/post/1737181/


All Articles