Click here to Skip to main content
15,913,100 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Processor or Mainboard's Serial Number Pin
Toni7815-Feb-04 19:10
Toni7815-Feb-04 19:10 
GeneralRe: Processor or Mainboard's Serial Number Pin
David Crow16-Feb-04 3:13
David Crow16-Feb-04 3:13 
GeneralConvert virtual key code to human readable format Pin
User 665815-Feb-04 1:30
User 665815-Feb-04 1:30 
GeneralRe: Convert virtual key code to human readable format Pin
Antti Keskinen15-Feb-04 3:08
Antti Keskinen15-Feb-04 3:08 
QuestionWhy this code never works???!?? Pin
YaronNir15-Feb-04 1:26
YaronNir15-Feb-04 1:26 
AnswerRe: Why this code never works???!?? Pin
Antti Keskinen15-Feb-04 3:33
Antti Keskinen15-Feb-04 3:33 
GeneralRe: Why this code never works???!?? Pin
YaronNir15-Feb-04 5:33
YaronNir15-Feb-04 5:33 
GeneralRe: Why this code never works???!?? Pin
Antti Keskinen15-Feb-04 7:10
Antti Keskinen15-Feb-04 7:10 
If you are writing an add-in, your add-in must implement an interface called IDTExtensibility2. OnConnection is a method on this interface. This method has one interesting parameter, called IDispatch* pDispatch. This is a pointer to the IDispatch interface of the running IDE.

The IDispatch interface pointer is used in combination with the COleDispDriver class to implement an easy and flexible way to communicate with the IDE. When creating an add-in, use the ClassView/ClassWizard to add a new MFC class from type library. Select 'Microsoft Development Environment' as the type library source. If you cannot find this entry in the registry, search your machine for the earlier mentioned dte.olb file, and implement the class from there.

Now, the wizard creates a wrapper class for you, based on the type library. The most interesting member of our newly created class is m_lpDispatch implemented in the base class. Now, assuming you have the OnConnection method implemented (you MUST have, otherwise your add-in will not work), here is a code extract on how to put it into use:
HRESULT __stdcall MyDispatchInterface::OnConnection( IDispatch* Application, ext_ConnectMode ConnectMode, IDispatch* AddInInst, SAFEARRAY** custom
)
{
   // Attach into the dispatch class
   m_ptrMyDTEDispatchClass->AttachDispatch( (LPDISPATCH) Application );
}
In the above example, m_ptrMyDTEDispatchClass is a pointer to the wizard-generated wrapper class, which is a static object in the actual add-in application class. You must create a pointer to this type of class as a member of MyDispatchInterface, thus allowing the interface class to access the object on the other class. Then we just attach the dispatch class to the provided IDispatch interface, that is coming from the IDE when the add-in is loaded.

Unfortunately I cannot give you a more concrete example right now, as I don't have any add-in source code available. Also, the example I am providing here applies for sure in the .NET versions of VS. I am unsure how it works on the VS 6.0/5.0 IDE, you must see the IDE-specific documentations.

-Antti Keskinen



----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
GeneralRe: Why this code never works???!?? Pin
Antti Keskinen15-Feb-04 7:51
Antti Keskinen15-Feb-04 7:51 
GeneralRe: Why this code never works???!?? Pin
YaronNir15-Feb-04 20:58
YaronNir15-Feb-04 20:58 
GeneralRe: Why this code never works???!?? Pin
Antti Keskinen15-Feb-04 22:06
Antti Keskinen15-Feb-04 22:06 
GeneralRe: Why this code never works???!?? Pin
YaronNir15-Feb-04 22:10
YaronNir15-Feb-04 22:10 
GeneralRe: Why this code never works???!?? Pin
Antti Keskinen16-Feb-04 2:03
Antti Keskinen16-Feb-04 2:03 
GeneralRe: Why this code never works???!?? Pin
YaronNir16-Feb-04 2:15
YaronNir16-Feb-04 2:15 
GeneralRe: Why this code never works???!?? Pin
Antti Keskinen16-Feb-04 2:54
Antti Keskinen16-Feb-04 2:54 
GeneralRe: Why this code never works???!?? Pin
YaronNir16-Feb-04 3:19
YaronNir16-Feb-04 3:19 
GeneralRe: Why this code never works???!?? Pin
Antti Keskinen16-Feb-04 5:53
Antti Keskinen16-Feb-04 5:53 
GeneralRe: Why this code never works???!?? Pin
YaronNir16-Feb-04 6:12
YaronNir16-Feb-04 6:12 
QuestionHow to Insert Table in Rich Text Box Control Pin
Sumit Kapoor15-Feb-04 0:18
Sumit Kapoor15-Feb-04 0:18 
AnswerRe: How to Insert Table in Rich Text Box Control Pin
CodeBrain15-Feb-04 21:57
CodeBrain15-Feb-04 21:57 
GeneralDatabase Problem Pin
Ghasrfakhri14-Feb-04 23:00
Ghasrfakhri14-Feb-04 23:00 
GeneralRe: Database Problem Pin
Manfred Staiger16-Feb-04 0:37
Manfred Staiger16-Feb-04 0:37 
GeneralRe: Database Problem Pin
David Crow16-Feb-04 3:23
David Crow16-Feb-04 3:23 
Generalneed help for sound recording and play back in C/C++ Pin
wenfoo14-Feb-04 22:14
wenfoo14-Feb-04 22:14 
GeneralRe: need help for sound recording and play back in C/C++ Pin
elza14-Feb-04 22:46
elza14-Feb-04 22:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.