Click to See Complete Forum and Search --> : Visual C++ Extensibility


ashwin
July 22nd, 2003, 09:04 PM
Hi,
I'm trying to use the Visual C++ Extensibility VCProjectEngine model to automate project building. As per the doc I need to sink VCProjectEngineEvents to handle the build start/build end events.

Has anyone played around with this ?

I tried to write a simple app to do this but I keep getting 0x80040200 which is FACILITY_ITF. (MS Specific?)

More info about implementation:

As per the IDL :
dispinterface _dispVCProjectEngineEvents {
properties:
methods:
[id(0x0000011a)] void ProjectBuildStarted([in] IDispatch* Cfg);
[id(0x0000011b)] void ProjectBuildFinished([in] IDispatch* Cfg, [in] long Warnings, [in] long errors, [in] VARIANT_BOOL Cancelled);
...
coclass VCProjectEngineEvents {
[default] interface _VCProjectEngineEvents;
[default, source] dispinterface _dispVCProjectEngineEvents;
};


Implementation of the events interface:

class CBuildEvents:
public IDispEventSimpleImpl<0, CBuildEvents, &DIID__dispVCProjectEngineEvents>
{

public:
BEGIN_SINK_MAP(CBuildEvents)
SINK_ENTRY_EX(0, DIID__dispVCProjectEngineEvents, 0x0000011a, ProjectBuildStarted)
SINK_ENTRY_EX(0, DIID__dispVCProjectEngineEvents, 0x0000011b, ProjectBuildFinished)
END_SINK_MAP()

public:

void __stdcall ProjectBuildStarted(...){}
void __stdcall ProjectBuildFinished(...){}
};

main implementation:
...
{
CoInitialize(NULL);
CComPtr<VCProjectEngine> ptrVCProjectEngine;
hr = ::CoCreateInstance(CLSID_VCProjectEngineObject, NULL, CLSCTX_SERVER, IID_VCProjectEngine, (void**) &ptrVCProjectEngine);


CBuildEvents BuildEvents;
hr = BuildEvents.DispEventAdvise(ptrVCProjectEngine);
....
....
hr = BuildEvents.DispEventUnadvise(ptrVCProjectEngine);
ptrVCProjectEngine.Release();
CoUninitialize();
}

Any suggestions/pointers appreciated. I'm able to successfully handle events using C# and VB. Not sure what wrong with the C++/ATL implementation.

Thanks in advance.

rdparker
September 4th, 2003, 04:51 PM
I don't know if this will be of any help, but I had a similar issue. When I stepped deep into DispEventAdvise I discovered that the GUID I had used for my IDispEventSimpleImpl template did not match the object for which I was calling DispEventAdvise. This was causing AtlAdvise to fail when calling FindConnectionPoint.

My specific case was using the Outlook::DIID_ItemEvents GUID against a Outlook::Items object. What I needed was DIID_ItemsEvents.