Click here to Skip to main content
15,915,702 members
Home / Discussions / COM
   

COM

 
GeneralRe: Any Idea? Pin
1-Jul-02 7:31
suss1-Jul-02 7:31 
AnswerRe: Any Idea? Pin
Amit Dey27-Aug-02 13:49
Amit Dey27-Aug-02 13:49 
GeneralRe: Any Idea? Pin
Anonymous28-Aug-02 3:04
Anonymous28-Aug-02 3:04 
GeneralExcel events inside a DLL Pin
Zizilamoroso19-Jun-02 23:48
Zizilamoroso19-Jun-02 23:48 
GeneralRe: Excel events inside a DLL Pin
soptest20-Jun-02 7:54
soptest20-Jun-02 7:54 
GeneralInterlocked increment failed Pin
sefip19-Jun-02 20:56
sefip19-Jun-02 20:56 
GeneralRe: Interlocked increment failed Pin
Dudi Avramov20-Jun-02 2:05
Dudi Avramov20-Jun-02 2:05 
Generallock-up catching excel events Pin
Zizilamoroso18-Jun-02 23:54
Zizilamoroso18-Jun-02 23:54 
I'm controlling excel from another app: create sheets, set ranges, modify properties and so on.

Now, I've implemented an eventlistener like described as on the msdn-website, automation, creating our own IDispatch for catching events.

The strange thing is that it handles pretty well events like WINDOW_ACTIVATE, SHEET_CALCULATE, ... if those things are modified from the outside-application. BUT if we select a range or double click on the sheet, excel blocks. Our app doesn't block, but it doesn't receive anymore events. We still can close excel though.

Is this a common problem? Anybody solved it yet? Or where to look?

initialising:
CEventsDispatch g_XLEventDispatch;
IConnectionPoint *m_pConnectionPoint;
DWORD m_adviseCookie;


	static const GUID IID_IExcel8AppEvents = 
	{0x00024413,0x000,0x0000,{0xc0,0x00,0x0,0x00,0x00,0x00,0x00,0x46 } };

	HRESULT hr;

	IConnectionPointContainer *pConnPtContainer;
	hr = m_pXlApp->QueryInterface(IID_IConnectionPointContainer,(void **)&pConnPtContainer);
	if(hr!=0)
		return;
	hr = pConnPtContainer->FindConnectionPoint(IID_IExcel8AppEvents,&m_pConnectionPoint);
	if(hr!=0)
		return;
	hr = m_pConnectionPoint->Advise(&g_XLEventDispatch, &m_adviseCookie);
	if(hr!=0)
		return;
	pConnPtContainer->Release();


our idispatch:
class CEventsDispatch : public IDispatch
{
	public:
		ULONG refCount;

	CEventsDispatch::CEventsDispatch()
	{
		refCount=1;
	}

	CEventsDispatch::~CEventsDispatch()
	{
	}

	virtual HRESULT __stdcall QueryInterface(REFIID riid, void **ppvObject)
	{
		if(IsEqualGUID(riid, IID_IDispatch) || IsEqualGUID(riid, IID_IUnknown))
		{
			this->AddRef();
			*ppvObject = this;
			return S_OK;
		}
		
		*ppvObject = NULL;
		return E_NOINTERFACE;
	}

	virtual ULONG _stdcall AddRef(void) 
	{
		return ++refCount;
	}

	virtual ULONG _stdcall Release(void) 
	{
		if(--refCount <= 0)
		{
			//Delete this;
			return 0;
		}

		return refCount;
	}

	// IDispatch methods.
	virtual HRESULT _stdcall GetTypeInfoCount(UINT *pctinfo) 
	{
		if(pctinfo) *pctinfo = 0;
		return E_NOTIMPL;
	}

	virtual HRESULT _stdcall GetTypeInfo(UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo) 
	{
		return E_NOTIMPL;
	}

	virtual HRESULT _stdcall GetIDsOfNames(REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid,DISPID *rgDispId) 
	{
		return E_NOTIMPL;
	}

	virtual HRESULT _stdcall Invoke(DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags,DISPPARAMS *pDispParams, VARIANT *pVarResult,EXCEPINFO *pExcepInfo, UINT *puArgErr) 
	{
		// do something with the event;
		return S_OK;
	}
};




[VISUAL STUDIO 6.0] [MFC] [WIN98/2]

Dead | X| Bluute tette! Dead | X|
GeneralRe: lock-up catching excel events Pin
Zizilamoroso19-Jun-02 1:20
Zizilamoroso19-Jun-02 1:20 
GeneralRe: lock-up catching excel events Pin
soptest20-Jun-02 7:52
soptest20-Jun-02 7:52 
GeneralLegacy COM calling .NET DLL: LPArray problem Pin
bad_english18-Jun-02 21:01
bad_english18-Jun-02 21:01 
GeneralCatching Events Pin
18-Jun-02 4:48
suss18-Jun-02 4:48 
GeneralRe: Catching Events Pin
Amit Dey18-Jun-02 11:14
Amit Dey18-Jun-02 11:14 
GeneralRe: Catching Events Pin
19-Jun-02 4:37
suss19-Jun-02 4:37 
GeneralRe: Catching Events Pin
20-Jun-02 6:32
suss20-Jun-02 6:32 
GeneralRe: Catching Events Pin
Anonymous27-Aug-02 9:15
Anonymous27-Aug-02 9:15 
GeneralRe: Catching Events Pin
Amit Dey27-Aug-02 13:52
Amit Dey27-Aug-02 13:52 
GeneralException Handling Error Pin
soup15-Jun-02 6:00
soup15-Jun-02 6:00 
GeneralRe: Exception Handling Error Pin
Tim Smith15-Jun-02 6:20
Tim Smith15-Jun-02 6:20 
GeneralRe: Exception Handling Error Pin
soup15-Jun-02 14:25
soup15-Jun-02 14:25 
GeneralRe: Exception Handling Error Pin
Tim Smith15-Jun-02 14:58
Tim Smith15-Jun-02 14:58 
QuestionHow to pass out an array from a com+ object? Pin
Lizp13-Jun-02 23:43
Lizp13-Jun-02 23:43 
AnswerRe: How to pass out an array from a com+ object? Pin
soptest14-Jun-02 9:40
soptest14-Jun-02 9:40 
GeneralRe: How to pass out an array from a com+ object? Pin
Lizp14-Jun-02 16:09
Lizp14-Jun-02 16:09 
GeneralPlease help (Events) Pin
Jason Troitsky (was Hattingh)13-Jun-02 21:30
Jason Troitsky (was Hattingh)13-Jun-02 21:30 

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.