` Printed Icetips Article

Icetips Article



COM: Constructing Interfaces 4
2002-12-29 -- Andy Ireland
 
Newsgroups: comp.lang.clarion

> Thanks very much for your reply - though I am still like trying to get
> a drink of water from a firehose !
> I have posted Oleview cut/paste in the NG, and can post
> complette source code (c++) - It's free.

The C++ is best.

> I have tryed this:
>
> IInterface        interface,com

No, this should be like a class declaration containing the methods (no 
properties) that are shown in OleView. I see the interface in OleView is 
a dispinterface meaning it can only be called using late binding. Is 
there also a dual interface? Most good, well designed controls unless 
coded specifically for VB should use dual interfaces as per the ActiveX 
specification.

An example are these from the WebBrowser control....

shdocvw::IWebBrowser                 interface(IDispatch),com
GoBack                                 procedure,HRESULT,raw
GoForward                              procedure,HRESULT,raw
GoHome                                 procedure,HRESULT,raw
GoSearch                               procedure,HRESULT,raw
Navigate                               procedure(BSTR URL, 
                                                 *tVariant Flags,
                                                 *tVariant TargetFrameName, |
                                                 *tVariant PostData, |
                                                 *tVariant Headers),| 
                                                 HRESULT,raw
Refresh                                procedure,HRESULT,raw
Refresh2                               procedure(*tVariant Level),HRESULT,raw
Stop                                   procedure,HRESULT,raw
get_Application                        procedure(*long pvObject),HRESULT,raw
                                       !**IDispatch pvObject
get_Parent                             procedure(*long pvObject),HRESULT,raw
                                       !**IDispatch pvObject
get_Container                          procedure(*long pvObject),HRESULT,raw  
                                       !**IDispatch pvObject
get_Document                           procedure(*long pvObject),HRESULT,raw  
                                       !**IDispatch pvObject
get_TopLevelContainer                  procedure(*short pVal),HRESULT,raw
get_Type                               procedure(*BSTR pVal),HRESULT,raw
get_Left                               procedure(*long pVal),HRESULT,raw
put_Left                               procedure(long _Left),HRESULT,raw
get_Top                                procedure(*long pVal),HRESULT,raw
put_Top                                procedure(long Top),HRESULT,raw
get_Width                              procedure(*long pVal),HRESULT,raw
put_Width                              procedure(long _Width),HRESULT,raw
get_Height                             procedure(*long pVal),HRESULT,raw
put_Height                             procedure(long Height),HRESULT,raw
get_LocationName                       procedure(*BSTR pVal),HRESULT,raw
get_LocationURL                        procedure(*BSTR pVal),HRESULT,raw
get_Busy                               procedure(*short pVal),HRESULT,raw
                                     end


shdocvw::IWebBrowserApp              interface(shdocvw::IWebBrowser),com
Quit                                   procedure,HRESULT,raw
ClientToWindow                         procedure(*long pcx, |
                                                 *long pcy),HRESULT,raw
PutProperty                            procedure(BSTR Property, |
                                                 tVariant vtValue),HRESULT,raw
GetProperty                            procedure(BSTR Property, |
                                                 *tVariant pVal),HRESULT,raw
get_Name                               procedure(*BSTR pVal),HRESULT,raw
get_HWND                               procedure(*long pVal),HRESULT,raw
get_FullName                           procedure(*BSTR pVal),HRESULT,raw
get_Path                               procedure(*BSTR pVal),HRESULT,raw
get_Visible                            procedure(*short pVal),HRESULT,raw
put_Visible                            procedure(short Visible),HRESULT,raw
get_StatusBar                          procedure(*short pVal),HRESULT,raw
put_StatusBar                          procedure(short StatusBar),HRESULT,raw
get_StatusText                         procedure(*BSTR pVal),HRESULT,raw
put_StatusText                         procedure(BSTR StatusText),HRESULT,raw
get_ToolBar                            procedure(*long pVal),HRESULT,raw
put_ToolBar                            procedure(long ToolBar),HRESULT,raw
get_MenuBar                            procedure(*short pVal),HRESULT,raw
put_MenuBar                            procedure(short MenuBar),HRESULT,raw
get_FullScreen                         procedure(*short pVal),HRESULT,raw
put_FullScreen                         procedure(short FullScreen),HRESULT,raw
                                     end


shdocvw::IWebBrowser2                interface(shdocvw::IWebBrowserApp),com
Navigate2                              procedure(*tVariant URL, |
                                                 *tVariant Flags, |
                                                 *tVariant TargetFrameName, |
                                                 *tVariant PostData, |
                                                 *tVariant Headers),|
                                                 HRESULT,raw
QueryStatusWB                          procedure(OLECMDID cmdID, |
                                                 *OLECMDF pVal),|
                                                 HRESULT,raw  
ExecWB                                 procedure(OLECMDID cmdID, |
                                                 OLECMDEXECOPT cmdexecopt, |
                                                 *tVariant pvaIn, |
                                                 *tVariant pvaOut),|
                                                 HRESULT,raw
ShowBrowserBar                         procedure(*tVariant pvaClsid, |
                                                 *tVariant pvarShow, |
                                                 *tVariant pvarSize),|
                                                 HRESULT,raw
get_ReadyState                         procedure(*tagREADYSTATE pVal),|
                                                 HRESULT,raw
get_Offline                            procedure(*short pVal),HRESULT,raw
put_Offline                            procedure(short Offline),HRESULT,raw
get_Silent                             procedure(*short pVal),HRESULT,raw
put_Silent                             procedure(short Silent),HRESULT,raw
get_RegisterAsBrowser                  procedure(*short pVal),HRESULT,raw
put_RegisterAsBrowser                  procedure(short RegisterAsBrowser),|
                                                 HRESULT,raw
get_RegisterAsDropTarget               procedure(*short pVal),HRESULT,raw
put_RegisterAsDropTarget               procedure(short RegisterAsDropTarget),|
                                                 HRESULT,raw
get_TheaterMode                        procedure(*short pVal),HRESULT,raw
put_TheaterMode                        procedure(short TheaterMode),|
                                                 HRESULT,raw
get_AddressBar                         procedure(*short pVal),HRESULT,raw
put_AddressBar                         procedure(short AddressBar),HRESULT,raw
get_Resizable                          procedure(*short pVal),HRESULT,raw
put_Resizable                          procedure(short Resizable),HRESULT,raw
                                     end

> code
>       IItem &=3D ('A835836A-7519-4BA9-B235-90A5F0211FCF')

No, this is just the GUID that identifies the control. You need to ask 
the Clarion OLE control of the instantiated object for the address of 
the interface that you want to call a method on.

>       Title_ = IItem.Add()

This would be the syntax. But it would return an HRESULT and the return 
value would be an [out] param or one that is passed in by address for 
setting for return.

i.e

hr = IItem.Add(Title) where Title is passed by address for filling. 
For an example, see the get_xxxx and put_xxxx methods in the above 
interfaces. The put methods pass in a value, the get methods receive a 
value via a param passed by address. Where a pointer to a pointer is 
returned a *long is used and the returned pointer is cast to the 
appropriate object type such as an Interface.

Regards

Andy
Plugware Solutions.com Ltd,  taking the puzzle out of I.T
Tel : +44 1249 813335
Fax : +44 1249 813462



Printed May 5, 2024, 1:17 pm
This article has been viewed/printed 35123 times.
Google search has resulted in 300 hits on this article since January 25, 2004.