> This method uses the IDispatch part of the interface, which is less
> efficient than direct virtual function calls you can use on a dual
> interface.

OK.

> First of all, beware of the namespace problem.  Unless you
> use #import with
> no_namespace, it declares and defines everything inside namespace
> TYPELIBRARY_NAME.

Understood: I'm using no_namespace to remove this. That's probably the one
and only part of it that I got right {:v)

> The MyControl class forward declaration is only there to
> enable __uuidof().
> It should look like this:
>
>  class __declspec(uuid("...")) MyControl;
>
> Which enables you to write __uuidof(MyControl) instead of
> CLSID_MyControl.
> This is useful in template coding, but I personally prefer
> #import with
> named_guids which creates the CLSID_MyControl variant as well.

OK. This explains Phil's code, which I found very much a surprise, but I'm
beginning to realise is simply because I didn't understand this mechanism
enough before I tried to use it.

> _DMyControl should be like this (correct me if I'm wrong):
>
>  struct _DMyControl : IDispatch {};

Correct.

>
> It's not very useful, I guess.

Agreed {:v)

>  // example:
>  IMyControlPtr ptr;
>  // somehow point it to your control (see below)  // access the Name
> property  _bstr_t theName = ptr->Name;  // set it  ptr->Name
> = "my name";
> // access the Foo method (taking a BSTR and an int param, and
> returning a
> float):
>  float result = ptr->Foo( "string", 0 );

Ahhhh... this was more like what I was expecting / hoping for.

>
> All HRESULT error codes will be converted to _com_error
> exceptions, so you
> should wrap these calls in a try/catch block.

OK.

>
> Now, how you're supposed to point an IMyControlPtr to your
> control?  Just
> act like before: obtain an IDispatch pointer to your control
> in whatever way
> you used to, and QueryInterface( ) it for IMyControl, and
> then, pass in in
> the IMyControlPtr's ctor, or as a param to
> IMyControlPtr::Attach( ) method.
> See, it's just as simple as what you were doing by the
> ClassWizard-generated
> class.

And this IXXXPtr method is more direct than the ClassWizard wrapper class
method? Then this is what I was looking for. I resorted to wrapper class in
the end since I wanted to move on, but I will definitely be going this route
next time.

Thanks Ehsan and Phil.

--
Jason Teagle
[EMAIL PROTECTED]



Reply via email to