Getting Graphics of the text editor window
-
Friday, July 11, 2008 9:10 PMI want to extend the mouse gestures add-in for visual studio, so that when you perform a gesture with the mouse, a red line is drawn (like the Firefox mouse gestures add-on).
The problem is, I am unable to get a Graphics object for the active document window. I am able to get a Window object, but the HWnd param is NULL, so I can't use Graphics.FromHWnd().
Is there any way to accomplish what I am trying to do here?
Thanks,
Rob.
All Replies
-
Saturday, July 12, 2008 1:48 AMModerator
Hi Rob,
Drawing directly to the code window's HWND is not supported. The only mechanism that is supported is text markers (glyphs in the widget bar, squiggly lines, code highligted in a different color, etc).
Given that you can retrieve the IVsTextLines interface on the text buffer the editor is using, you can create these programatically using IVsTextLines.CreateLineMarker.
Creating your own marker type is fairly involved, and it's currently pretty limited as to the number of custom markers that can be registered. But there's an old Dr. eX post here that describes how to do this.
Sincerely,
Ed Dore- Marked As Answer by Feng ChenModerator Sunday, July 13, 2008 2:59 AM
-
Tuesday, February 21, 2012 7:58 AMModerator
Hi Ed,
I have found the interesting question here - http://stackoverflow.com/questions/8831401/draw-something-in-vsx
If you open this link you will see this picture there (see below).
What way the similar formatting could be implemented in VS? Could you point me to the right direction?

Thank you in advance!
Don't forget to vote for useful replies and/or mark answers for your questions - that helps other guys to find the answer faster.
-
Monday, February 27, 2012 1:02 PMModeratorDoes anybody could suggest the way to inmplement such thing?
Don't forget to vote for useful replies and/or mark answers for your questions - that helps other guys to find the answer faster.
-
Wednesday, February 29, 2012 3:25 AMModerator
Hi Dmitry,
This is done through the use of editor extensions in VS 2010. In VS 2010, the code editor was rewritten with WPF. There are quite a few examples and documentation on authoring editor extensions like this for VS 2010. But this cannot be done with earlier versions of the VS code editor.
Getting Started with Editor Extensions
VSX Code Gallery SamplesSincerely,
Ed Dore
- Proposed As Answer by Ed DoreMicrosoft Employee, Moderator Wednesday, February 29, 2012 3:25 AM
- Marked As Answer by Dmitry PavlovMVP, Moderator Wednesday, February 29, 2012 1:42 PM
-
Wednesday, February 29, 2012 1:43 PMModerator
Hi Ed,
Ok. I see. I will let guys know about your reply on stackoverflow
Thank you!
Don't forget to vote for useful replies and/or mark answers for your questions - that helps other guys to find the answer faster.

