Get IConnectionPointContainer interface of the application object, and get connection point to the events you want to catch. In this case, i think you have to deal with WorkBookEvents and DocEvents. Several documentations are available.. catching events from word
oh.. You did exactly as i guessed . xlRange is Range object's IDispatch iterface. If you haven't already done, add a Range class (say CRange) to the project from EXCEL.exe using 'Add MFC Class from Typelib' wizard. Then
See the methods on Range object now by using oRange. ----
well done OLE automation may need some R&D most time.
You can catch SheetCalculate event in much the same way you did for SheetChange event. Mean, all reside in IAppEvent interface, so Advice() for it, and override the SheetCaluclate method.
HRESULT _stdcall SheetCalculate(IDispatch* pSheetDisp)<br />
//let CWorkSheet is the wrapper of _WorkSheet<br />
CWorkSheet oSheet(pSeetDisp);<br />
//do whatever you want to do here.. :) <br />
I got it and do it , but facing one more problem as in case on "change event" I got the cell number i.e its row and column in which value is change . But "calculate event" fire when there is reference of another cell or cell containing formulae and when value change in such cell in this case I am not getting the cell no i.e cell row and column . this is my problem it become very tedious when I have the thousand of such cells having reference of various cells and formulaes. In this case I have to parse every cell to find out the value change . this become very slow for my project .I am searching the way to find out the cell row and column when there is calculate event fire .
Now I am facing one more problem . I have multiple excel file runnig on one system , but I am getting only one excel file using GetActiveObject. when I close this then I am getting second one using get object . so why I am not getting all the excel files ??
Checking the first 4 bytes of the location pointed to by the interface pointer returned by CoCreateInstance() function might give you the address of vtable (I have not tried it). But why do you want to do this?
I need to call all the functions of COM Interface exposed methods at runtime.
For this I need to access vtable of COM coclass where all addresses of exposed methods of its interfaces are stored.
Math is COM object
and its exposed interface is "Operations"
and "Sum" is the method of this interface.
I need the address of "Sum", so that I can call it on run time. Just like you use loadlibrary for DLL and adter passing functional address, using GetProcAddress we can call function at runtime.
Here in COM same I need to do. But here no LoadLibrary , and no GetProcAddress. Just we need to iterate vtable and one by one we'll get the addresses of methods and we'll call these methods on run time.
Even if you get the function pointers this way, how to get the function signature (arguments and types)? You may have to use type library to get more details about the interface functions and supported interfaces.
a coclass will always have pointers to virtual tables (of all interfaces it implements) as its instance data. In CreateObject() function, coclass is instantiated, type casted to the interface ptr which we demands through CoCreaInstance and returned. so the returned ptr will be pointing to the virtual table of that interface. This virtual table ptr is used later in function calls to locate the correct implemented functions. Pls correct me if iam wrong..
size of the returned interface ptr will be size of a pointer (4 bytes as any pointer). so in order to call the functions using that ptr, u need to have their declarations. Also for all com interfaces, first few entries in vtable will point to the implementation of functions from the base interfaces, such as QueryInterface, AddRef ... of IUnknown. So think whether ur plan is going to work our or not..
You're going about things the wrong way. Getting the v-table's address is no problem. Doing something useful with it will be. All it is an array of function pointers. The pointers have no type information associated with them. It sounds like you should look into type libraries (see the ITypeLib[^] interface) or automation[^].
Last Visit: 31-Dec-99 19:00 Last Update: 28-Feb-24 7:37