Well im approaching the great IUnknown again (get it ~ bad pun).

Im will need to create an event handler for both Excel and Autocad. I have the interfaces described to me (thanx to Japheth's ComView tool), however, I've never tried to create one before.

So in the interest of perhaps starting a conversation, I was wondering if anyone has any advice, examples, or pitfalls from bad experinces that they might want to share..

Anywho, for now its time to burry by head in a book ;)
Thanx again...
:alright:
NaN
Posted on 2003-02-10 18:31:54 by NaN
Advice? Hehehe, use VB :grin:

Nah, don't do that... But, Good luck in your journeys.. and don't forget to inform us on your way so we can learn from it cause I know I will have to jump into COM one day.....
Posted on 2003-02-10 19:34:49 by Gunner
Nan, might I humbly refer you to my tuts on sinking and sourcing events?

You sink an event if you want to know when an event happens. You source it if you're the blob that controls the event.

One warning, I have a dim memory of a bug lurking inside the code, something like if you use multiple instances of the source code they will all share the same event sink list, and each should have its own list.
Posted on 2003-02-10 19:57:02 by Ernie
NaN,
Maybe I'm way off base on what you are asking but,
have you looked at the WebBrowserSample that comes with
ComView. It supports events. I figure I must be off base here because I know of the detailed conversations you and Japheth have had. Just my 2cents.

Wayne
Posted on 2003-02-10 21:54:28 by Wayne
Hi,

the macros handling events in the webbrowser sample hide most of COM's event stuff. In fact a whole class (CEvents, inheriting from IDispatch) is defined. So if you really want to know how COM handles these things and want to understand connection points I would suggest NOT to use the macros and do it the "hard" way. Anyway it is much more fun :) .

Japheth
Posted on 2003-02-11 03:39:33 by japheth
Thanx for the tips.. i knew about Japheth's source, but i didnt realize it was conclusively tanken care of. Typically you get only pieces to the puzzle by studying other's software cause rarely does the software use *all* that a topic can offer.

I was aimin to learn it all first, then review what Japheth is up to...

As well, i totally forgot about your tutorials Ernie, thanks for reminding me of them ;)

:alright:
NaN
Posted on 2003-02-12 17:25:34 by NaN
Well i feel i have a good understanding now. I was surprised its really not to complicated to understand.. However, i will admit Japheth's macros make no sense to me. All those '??Interface' and "&" statements get hard on the head after a while. From what i can tell he is making a CEvent com object, and a registry table of events used... or something..

So while im sure they work well, but i think i will develop my own set from here..

Oh ya, i discovered by accident the other day something that might make COM objects simpler to design...

I was wondeing how, if possible, i could make virtual structrue entries. After some digging around I found this to work:
Obj struc

struc
TestSample TestSampleVal ?
TestSample2 TestSample2Val ?
TestSample3 TestSample2Val ?
org 0
ends
pObject dd ?
data1 dd ?
data2 dd ?
data3 dd ?
Obj ends


The neat thing is the "org 0" at the end of the first structure nested structure. When you ask the sizeof Obj it will return = 16. The first three function pointer definitions are still 0,4,8 offsets, while pObject, data1, data2, data3 are 0,4,8,12.

I was pretty excited about it until i discovered masm gets grumpy about instanciating this structure in memory. Which is ok, you can still do it manually:



Object LABEL Obj
dd offset vTable
dd data1
dd data2
dd data3


As well an added bonus you can have two lables to the same memory table:



vtObject LABEL PTR
Object LABEL Obj
dd offset vTable
dd data1
dd data2
dd data3


I sucessfully desgined an object with a vtable and used this structure, however it only discovered this last night, so i dont know how well, or if there is any real savings from other schemes. I guess the savings is being able to allocate memory by SIZEOF Obj now, since it will ignore the first 3 entries due to the org rested command.

Anywho, if you figure anything out with this please pass it on. ;) (as i will)

:alright:
NaN
Posted on 2003-02-22 15:21:53 by NaN
Hi NaN,

this "org 0" thingy in a structurce looks very strange to me. Are you able to explain us the benefits of using that compared to unions for example?

Japheth
Posted on 2003-02-23 17:36:31 by japheth
Right now i dont know what the benifits are. I only just discovered this "property". I found it when i reading thru Hutch's MASM32 help file under structures (i was origionally looking up their alignment properties). It has a one liner saying something like "and ORG has a special purpose when used in structures". But nothing more, so i piddled around and found that the i can make structures look bigger or smaller than they are by adding an "ORG" into the structure. Im not sure if this is the "Specail" aspect refered to, or if it can do something better... which is why i presented the idea for others to tinker with..

:NaN:
Posted on 2003-02-23 22:03:45 by NaN