I would like to be able to design something similar to what you see when you get an exception in Visual Studio, a sort of window with a line connecting the window to a point in the code window. I've included a picture of this below:
I notice that whenever the code window loses focus, the exception window disappears. When focused, though, I can move the window around, and the arrow continues to point at the target.
How is this being done? Specifically, how can I draw a line from one window into another?
I'm coding in C# and using Windows Forms.
In your example, the window with the exception will not always disappear if the text box loses focus!
By investigating a little bit with the Spy++ tool (put the find window cursor exactly on the line), you will notice that the line you see between the yellow text and the exception window is contained in a window (with a transparent background) (with a class window of type "WindowsForms10.Window.8.app.0.34f5582_r41_ad1" in VS 2010). This window also has the WS_POPUP style, and is the exact bounding box of the line (its size and position fit exactly the line).
So you can do the same thing: create a transparent popup window, draw a line on it and set its location and size so that the line appears between the controls you want.
I dont know exactly how its done but you may be able to do something similar with this idea.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With