Artifacts From INewLineFeedback

285
2
08-09-2011 02:19 PM
Highlighted
New Contributor
1) Compile in Visual Studio 2010 (I can throw it together in vs08, if someone is interested.)
2) Run.
3) Enable My Extension from the Extensions menu item.
4) From the Customize Menu accessed by right-clicking on the toolbar area, add the NewLineFeedback Tool from the NewLineFeedback category.
5) Click on the tool.
6) You'll notice a line that starts at (0,0) and follows the cursor around.

Previously if I zoomed to full extent, fixed zoom out, fixed zoom in, went to previous extent, went to next extent, or refreshed it left an artifact. I fixed that by using IActiveViewEvents in the extension with the AfterDraw event. See NewLineFeedbackExtension.cs for details. The issue I did not fix is if the user minimizes ArcMap, maximizes ArcMap, switches to a different app, or hovers on an item in the taskbar in Windows 7 to pop-up that particular item, then an artifact is left when ArcMap is refocused and the tool is moved around.

I've tried moving code all around, using IDisplayEvents, IDocumentEvents, and ITransformEvents. The artifact persists. I can get rid of it if I refresh (F5 or the tool). My guess is an old IScreenDisplay used by INewLineFeedback is left on the screen or the old INewLineFeedback object isn't released properly when I create a new one in AfterDraw. I've tried manually releasing the object too.

Any help would be appreciated. Thanks for your time.
Reply
0 Kudos
2 Replies
Highlighted
Regular Contributor III
I don't have time right now to run your code but you shouldn't need any events outside of the ITool implementation.  I'm attaching a sample sketch tool I created for a blog entry a few years back.  You may find something in the code that will help you solve your problem.  This tool uses a custom symbol rather than using the default symbol provided by the feedback object.  One thing to note is the symbol settings in the method that creates the custom symbol object.  There is also code in the ITool.Refresh implementation to refresh the feedback object.
Highlighted
New Contributor
Firstly, thank you. Your code helped.

The ITool.Refresh implementation was the key. Note that some ESRI samples using INewLineFeedback omit this implementation and are broken to a degree. e.g. SelectionCOMSample . Hence my lack of knowledge.

It looks like you use VS2008, but I've posted the solution in VS2010 for anyone else who comes across this thread.
Reply
0 Kudos