I was trying to use an activX control in a standatd window. I found documentation on ATL and
was pleased when my knoledge of COM bore fruit in producing a very simple peice of code displaying
an html file. The ms ATL documents are all c++ based and as I have no talent for this, I am finding it
dificult to to get on any further.
can anyone help?

    problem: I am wanting to use the HostWindow methods
                CreateControl and AttachControl.  - I cannot find any vtable refrence to these
                or a CLSID.

I hope I am on the right track. This is the main part of code as far as Ive got.


;having run AtlAxWinInit
;  .
;  .
;  .
.if uMsg == WM_CREATE
        ; will display the html page pointed to by the window text.
        invoke CreateWindowEx,0,SADD("AtlAxWin"),SADD("c:\win32.html"),WS_CHILD or WS_VISIBLE,
                                120,20,512,384,hWin,NULL,hInstance,NULL
        mov hWeb,eax                      ; this window has no scroll, edges or borders

; section 1 ------------
        invoke RegisterWindowMessage,SADD("WM_ATLGETCONTROL")
        invoke SendMessage,hWeb,eax,0,0                                ; get loaded object
        mov browserObject,eax
        ole32 browserObject,0,offset IID_IWebBrowser2,offset pIweb2obj ; QueryInterface
                                                                        ; to IWebBrowser2 vtable
  ; I now can access methods in IWebBrowser2 successfuly,
  ;            ole32 pIweb2obj,IWebBrowser2_Navigate,offset uStringFullPath,0,0,0,0
  ;            ole32 pIweb2obj,IWebBrowser2_GoBack
  ;            ole32 pIweb2obj,IWebBrowser2_GoForward        ...etc

; section 2 ------------                                               
        invoke RegisterWindowMessage,SADD("WM_ATLGETHOST")
        invoke SendMessage,hWeb,eax,0,0                                ; get the host object
        mov HostObject,eax

  ; my problem ***
  ;        ole32 HostObject,0,offset 'Missing_GUID_?',offset pIwebHost  ; QueryInterface
                                                                        ; to 'missing vtable' ?
  ;        I want to access the methods ,
  ;                  **  CreateControl and AttachControl  **


thanks,
dougiem
Posted on 2005-10-18 15:15:50 by dougiem
I have found the missing bits:

sIID_IAxWinHostWindow  MGUID (B6EA2050-048A-11d1-82B9-00C04FB9942E)
IID_IAxWinHostWindow  GUID sIID_IAxWinHostWindow

;== IAxWinHostWindow ============================================
IAxWinHostWindow_QueryInterface            equ 000h      ;riid,ppvObject
IAxWinHostWindow_AddRef                    equ 004h
IAxWinHostWindow_Release                    equ 008h
IAxWinHostWindow_CreateControl              equ 00ch      ;lpTricsData,hWnd,pStream
IAxWinHostWindow_CreateControlEx            equ 010h      ;lpTricsData,hWnd,pStream,ppUnk,riidAdvise,punkAdvise
IAxWinHostWindow_AttachControl              equ 014h      ;pUnkControl,hWnd
IAxWinHostWindow_QueryControl              equ 018h      ;riid,ppvObject
IAxWinHostWindow_SetExternalDispatch        equ 01ch      ;pDisp
IAxWinHostWindow_SetExternalUIHandler      equ 020h      ;pDisp

.data
WSTR uStringFullPath, "c:\win32.html"
.code
;having run AtlAxWinInit
;  .
;  .SADD("c:\win32.html")
;  .
;.if uMsg == WM_CREATE
        ; will display the html page pointed to by unicode string uStringFullPath.
        invoke CreateWindowEx,0,SADD("AtlAxWin"),0,WS_CHILD or WS_VISIBLE,
                                120,20,512,384,hWin,NULL,hInstance,NULL
        mov hWeb,eax                      ; this window has no scroll, edges or borders
                                           
        invoke RegisterWindowMessage,SADD("WM_ATLGETHOST")
        invoke SendMessage,hWeb,eax,0,0                                ; get the host object
        mov HostObject,eax

        ole32 HostObject,0,offset IID_IAxWinHostWindow,offset pIwebHost ; QueryInterface
                                                                        ; to IAxWinHostWindow vtable

        ole32 pIwebHost,IAxWinHostWindow_CreateControl,offset uStringFullPath,0

        invoke RegisterWindowMessage,SADD("WM_ATLGETCONTROL")
        invoke SendMessage,hWeb,eax,0,0                                ; get loaded object
        mov browserObject,eax
        ole32 browserObject,0,offset IID_IWebBrowser2,offset pIweb2obj  ; QueryInterface
                                                                        ; to IWebBrowser2 vtable

dougiem
Posted on 2005-10-20 09:21:51 by dougiem