Lockdesign Diagnostic Tools Aid VB Debugging

AddIn FAQ

This FAQ is, very much, in it's initial stages. It is intended to continue adding useful information relating to the writing of VB AddIns to this section, so please check back from time to time to see if it's been updated. Some of the FAQs will link to code downloads, others will just give the answer within the text of the page.

1. How do I find the current cursor position within the code pane? I've looked at the object model and there doesn't appear to be a suitable method or property.
2. How do I know when a project enters run/pause/stop mode?
3. How do I access the conditional compilation arguments from within my AddIn? I've looked at the ReadProperty/WriteProperty methods but the won't allow me to access the non named section of the VB project file. Reading them from the project file is not satisfactory as they may be changed later via the project properties.
4. Can I get an event when a key is pressed or the mouse is clicked in a code pane window?
5. Are there any newsgroups or forums specifically aimed at VB AddIn developers?

 

1.

The GetSelection method of the CodePane object is used to obtain the start and end coordinates of the current selection. The start line and column gives the position of the cursor even if no text is currently selected.

2. In VB6 this can easily be achieved through the use of the hidden VBBuildEvents object. This is used in the ImmClear addin, the source of which may be downloaded from here.
3.

This has been a question asked many many times on the addin newsgroup and, to which, no ideal solution has yet been given.

I have managed to both read and write the conditional compilation arguments direct via the project properties through the use of SendKeys to send the appropriate key stroke commands. I have wrapped this functionality up into two subroutines GetCondComp and SetCondComp which may be downloaded by clicking here. I have used these methods to write a grid based mechanism for setting the conditional compilation parameters. Hopefully Microsoft will extend the IDE object model for us addin authors in later versions of VB7 to provide better access to such items. If anyone is aware of a better method of accessing this data then please email me.

4.

This is certainly possible, although by no means trivial. It involves sub-classing the IDE. A comprehensive article on this was written by Francesco Balena and published in the October 1998 edition of the Visual Basic Programmers Journal (VBPJ). This is available online (premier club members only) at DevX.

5. Try the newsgroup microsoft.public.vb.addins