Thanks, Ron, for the thorough explanations.  You've certainly given me a lot to 
think about, and I'm glad I'm not the only one who has struggled to wrap my 
head around this topic.  I'm sure I'll have more questions as I proceed, but 
hopefully I have a good start.  You'll probably be hearing from me soon, but 
thanks again.

-Cory

On Feb 13, 2012, at 9:12 AM, Ron Parker wrote:

> On 2/12/2012 12:06 PM, Cory Samaha wrote:
>> 1.  How do you know when to use the get keyword?
> 
> The short answer: you use get_ (and put_) when the thing you're working with 
> is a property. You don't when it's a method. The documentation should be 
> pretty reliable on which you're dealing with in most cases, but the IDL is 
> the ultimate authority.
> 
> 
>> 2.  Are there any good resources for learning about VARIANT types?  Same for
>> DISPID and the like.
> 
> 
> I don't recommend it, as it's a hard slog, but I learned this stuff from the 
> MSDN documentation on COM Automation:
> 
> http://msdn.microsoft.com/en-us/library/windows/desktop/ms221375%28v=vs.85%29.aspx
> 
> Unfortunately, a lot of that is written from the point of view of someone 
> writing an automation server (like Window-Eyes) rather than an automation 
> client (like a script.)
> 
> For VARIANT types specifically, these helper functions are very useful:
> 
> http://msdn.microsoft.com/en-us/library/windows/desktop/ms221673%28v=vs.85%29.aspx
> 
> DISPID is just a number. It tells IDispatch::Invoke which function you're 
> trying to invoke.
> 
> 
>> Actually, any explanation about how Window-Eyes events
>> are handled in C++ would be nice.
> 
> COM event handling is, unfortunately, right smack in the middle of a vortex 
> of difficult subjects. You need to be able to implement an IDispatch 
> interface, for starters (though for Window-Eyes events specifically you can 
> skimp and only implement Invoke, because we never call any of the other 
> members. Note that that's not a guarantee for the future, and I most 
> certainly don't speak for GW Micro on this matter, but I don't personally see 
> it changing any time soon.)
> 
> After you have an IDispatch interface, you need to connect to the event 
> source. The designers of COM probably could have made that harder, if they'd 
> really applied themselves, but it would have been a lot of work. Personally, 
> I'd start with the documentation for IConnectionPointContainer and 
> IConnectionPoint:
> 
> http://msdn.microsoft.com/en-us/library/windows/desktop/ms683857%28v=vs.85%29.aspx
> 
> 
> 
>> I can make sense out of the external
>> examples on the app developer page, but I'm not sure that I'd be able to
>> write my own event yet.
> 
> 
> The external examples abstract away a lot of the fiddly event-handling stuff 
> into the EventHandler class that's defined in HelperClasses.cpp. (I'm looking 
> at the late-binding example here; the early-binding one is probably 
> different.) If you can understand what *that* class is doing for you, you'll 
> have a pretty good grasp of the intricacies of COM event handling. 
> Unfortunately, we didn't put a lot of documentation into those helper 
> functions because we weren't really considering them user-serviceable parts.
> 
> Another thing you may occasionally need to use that's more complicated than 
> seems reasonable is the collection interface (what VBScript uses when you do 
> a FOR EACH.) I'm not sure whether the examples cover any of that, but the 
> interface you need there is IENUMVariant ( 
> http://msdn.microsoft.com/en-us/library/windows/desktop/ms221053%28v=vs.85%29.aspx
>  ), and you have to know about a hidden property called _NewEnum (or 
> get__NewEnum, because it's a property) that gives you one of those.
> 
>> MSDN documentation doesn't seem to provide a great
>> simple explanation from start to finish on these topics.  Or, if they do, I
>> haven't found them.  Anyone else been successful in self teaching on these
>> topics?
> 
> 
> There isn't any really good documentation on any of this. I'm personally 
> convinced that that's part of why even flagship applications like Internet 
> Explorer and Excel have subtle problems with their Automation support. I did 
> teach myself this stuff, but I did it from the MSDN documentation and it took 
> far, far longer than it should have.
> 
> 
> 

Reply via email to