flat assembler
Message board for the users of flat assembler.

Index > Windows > COM IWebBrowser2 programing

Author
Thread Post new topic Reply to topic
tutenhamon



Joined: 16 Jan 2010
Posts: 27
Location: Polska (Poland)
tutenhamon
During compilation this

Code:
 format PE GUI

 include 'win32ax.inc'

    INV  equ INVOKE
  MOM  equ MOVM
       
  macro MOVM  dokad, skad
  {
   push   skad
   pop     dokad
  }

  macro MOP   dokad, co
  {
    mov  eax,dokad
    MOVM [eax],co
  }

  interface IWebBrowser2,\
   GetTypeInfoCount,\
   GetTypeInfo,\
   GetIDsOfNames,\
   xInvoke,\
   GoBack,\
   GoForward,\
   GoHome,\
   GoSearch,\
   Navigate,\
   Refresh,\
   Refresh2,\
   Stop,\
   get_Application,\
   get_Parent,\
   get_Container,\
   get_Document,\
   get_TopLevelContainer,\
   get_Type,\
   get_Left,\
   put_Left,\
   get_Top,\
   put_Top,\
   get_Width,\
   put_Width,\
   get_Height,\
   put_Height,\
   get_LocationName,\
   get_LocationURL,\
   get_Busy,\
   Quit,\
   ClientToWindow,\
   PutProperty,\
   GetProperty,\
   get_Name,\
   get_HWND,\
   get_FullName,\
   get_Path,\
   get_Visible,\
   put_Visible,\
   get_StatusBar,\
   put_StatusBar,\
   get_StatusText,\
   put_StatusText,\
   get_ToolBar,\
   put_ToolBar,\
   get_MenuBar,\
   put_MenuBar,\
   get_FullScreen,\
   put_FullScreen,\
   Navigate2,\
   QueryStatusWB,\
   ExecWB,\
   ShowBrowserBar,\
   get_ReadyState,\
   get_Offline,\
   put_Offline,\
   get_Silent,\
   put_Silent,\
   get_RegisterAsBrowser,\
   put_RegisterAsBrowser,\
   get_RegisterAsDropTarget,\
   put_RegisterAsDropTarget,\
   get_TheaterMode,\
   put_TheaterMode,\
   get_AddressBar,\
   put_AddressBar,\
   get_Resizable,\
   put_Resizable
 
 struct OLEINPLACEFRAMEINFO
 {
   cb           dd ?
   fMDIApp      dd ?
   hwndFrame    dd ?
   haccel       dd ?
   cAccelEntries dd ?
 }  

 struc GUID def
 {
   match d1-d2-d3-d4-d5, def
    \{
      .Data1 dd 0x\#d1
      .Data2 dw 0x\#d2
      .Data3 dw 0x\#d3
      .Data4 db 0x\#d4 shr 8,0x\#d4 and 0FFh
      .Data5 db 0x\#d5 shr 40,0x\#d5 shr 32 and 0FFh,0x\#d5 shr 24 and 0FFh,0x\#d5 shr 16 and 0FFh,0x\#d5 shr 8 and 0FFh,0x\#d5 and 0FFh
    \}
 }
 
 ID_DLG_MAIN   = 100
 ID_CHANGE     = 1002

.data                              ; dane zainicjalizowane
 hInstance dd ?
 hMainWnd dd ?

; identyfikatory GUID
 CLSID_WebBrowser      GUID  8856F961-340A-11D0-A96B-00C04FD705A2
 IID_IWebBrowser2      GUID  D30C1661-CDAF-11D0-8A3E-00C04FC9E26E
 IID_IOleObject        GUID  00000112-0000-0000-C000-000000000046
 IID_IOleInPlaceObject GUID  00000113-0000-0000-C000-000000000046
 IID_IOleInPlaceSite   GUID  00000119-0000-0000-C000-000000000046
 IID_IOleClientSite    GUID  00000118-0000-0000-C000-000000000046

 bJestOLE   dd FALSE 
 szPokaz    db 'Dodaj...',NULL
 szUkryj    db 'UsuD... ',NULL
 
 uniNULL du 0
 navURL du "http://www.gogle.com"
 
 vnavFlags    dw VT_I4,0,0,0
             dw FALSE 
 vnavTarget   dw VT_BSTR,0,0,0
         dd NULL
 vnavPostData dw 0,0,0,0 
        dd 0
 vnavHeaders  dw VT_BSTR,0,0,0
              dd NULL
 
 rcOLE RECT 0,0,100,100
 
.code                            ; segment kodu (sekcja kodu)
  proc cmpGUID uses esi edi guid1,guid2:DWORD
    mov esi,guid1
    mov edi,guid2
    mov eax,[esi]
    cmp eax,[edi]
    jne cmpGUID_ret1
    mov eax,[esi+4]
    cmp eax,[edi+4]
    jne cmpGUID_ret1
    mov eax,[esi+8]
    cmp eax,[edi+8]
    jne cmpGUID_ret1
    mov eax,[esi+12]
    cmp eax,[edi+12]
    jne cmpGUID_ret1
   cmpGUID_ret0:  
    xor eax,eax
    ret
   cmpGUID_ret1:
    xor eax,eax
    inc eax
    ret
  endp

;-- IOleClientSite

  proc mIOleClientSite_QueryInterface  t,riid,ppvObject:DWORD
    INV cmpGUID,[riid],IID_IOleInPlaceSite 
    .if eax=0
      MOP ppvObject,pmIOleInPlaceSite 
      mov eax,S_OK
    .else
      MOP ppvObject,NULL
      mov eax,E_NOINTERFACE
    .endif
    ret
  endp

  proc mIOleClientSite_AddRef t:DWORD
    xor eax,eax
    inc eax
    ret
  endp

  proc mIOleClientSite_Release t:DWORD
    xor eax,eax
    ret
  endp

  proc mIOleClientSite_SaveObject  t:DWORD
    mov eax,S_OK
    ret
  endp

  proc mIOleClientSite_GetMoniker  t,dwAssign,\
                            dwWhichMoniker,ppmk:DWORD
    mov eax,E_NOTIMPL
    ret
  endp

  proc mIOleClientSite_GetContainer t,ppContainer:DWORD
    MOP ppContainer,NULL
    mov eax,E_NOINTERFACE
    ret
  endp

  proc mIOleClientSite_ShowObject   t:DWORD
    mov eax,S_OK
    ret
  endp

  proc mIOleClientSite_OnShowWindow t,fShow:DWORD 
    mov eax,S_OK
    ret
  endp

  proc mIOleClientSite_RequestNewObjectLayout t:DWORD
    mov eax,E_NOTIMPL
    ret
  endp
  
;-- IOleInPlaceSite

  proc mIOleInPlaceSite_QueryInterface t,riid,ppvObject:DWORD
    MOP ppvObject,NULL
    mov eax,E_NOINTERFACE
    ret
  endp
  
  proc mIOleInPlaceSite_AddRef t:DWORD
    xor eax,eax
    inc eax
    ret
  endp
  
  proc mIOleInPlaceSite_Release t:DWORD
    xor eax,eax
    ret
  endp

  proc mIOleInPlaceSite_GetWindow t,phwnd:DWORD
    MOP phwnd,hMainWnd  
    mov eax,S_OK
    ret
  endp

  proc mIOleInPlaceSite_ContextSensitiveHelp t,fEnterMode:DWORD
    mov eax,S_OK
    ret
  endp

  proc mIOleInPlaceSite_CanInPlaceActivate t:DWORD
    mov eax,S_OK
    ret
  endp

  proc mIOleInPlaceSite_OnInPlaceActivate t:DWORD
    mov eax,S_OK
    ret
  endp

  proc mIOleInPlaceSite_OnUIActivate t:DWORD
    mov eax,S_OK    
    ret
  endp

  proc mIOleInPlaceSite_GetWindowContext t,ppFrame,ppDoc,\
                             lprcPosRect,lprcClipRect,\
                                 lpFrameInfo:DWORD
    MOP ppFrame,NULL
    MOP ppDoc,NULL

    INV  GetClientRect,[hMainWnd],rcOLE
    add  rcOLE.top,1
    add  rcOLE.left,1 
    sub  rcOLE.bottom,40 
    sub  rcOLE.right,2
    mov  eax,lprcPosRect
    MOM  [eax.RECT.left],[rcOLE.left]
    MOM  [eax.RECT.top],[rcOLE.top]
    MOM  [eax.RECT.right],[rcOLE.right]
    MOM  [eax.RECT.bottom],[rcOLE.bottom]
    mov  eax,lprcClipRect
    MOM  [eax.RECT.left],[rcOLE.left]
    MOM  [eax.RECT.top],[rcOLE.top]
    MOM  [eax.RECT.right],[rcOLE.right]
    MOM  [eax.RECT.bottom],[rcOLE.bottom]  

    mov  eax,lpFrameInfo
    mov [eax.OLEINPLACEFRAMEINFO.fMDIApp],FALSE
    MOM [eax.OLEINPLACEFRAMEINFO.hwndFrame],[hMainWnd]
    mov [eax.OLEINPLACEFRAMEINFO.haccel],NULL
    mov [eax.OLEINPLACEFRAMEINFO.cAccelEntries],0
     
    mov eax,S_OK
    ret
  endp

  proc mIOleInPlaceSite_Scroll t,scrollExtant:DWORD
    mov eax,S_OK    
    ret
  endp

  proc mIOleInPlaceSite_OnUIDeactivate t,fUndoable:DWORD
    mov eax,S_OK    
    ret
  endp

  proc mIOleInPlaceSite_OnInPlaceDeactivate t:DWORD
    mov eax,S_OK    
    ret
  endp

  proc mIOleInPlaceSite_DiscardUndoState t:DWORD
    mov eax,S_OK    
    ret
  endp

  proc mIOleInPlaceSite_DeactivateAndUndo t:DWORD
    mov eax,S_OK    
    ret
  endp

  proc mIOleInPlaceSite_OnPosRectChange t,lprcPosRect:DWORD
    mov eax,S_OK    
    ret
  endp
  
.data          
;-- tablice metod wirtualnych
  label mIOleClientSite :dword ; IOleClientSite
   dd mIOleClientSite_QueryInterface
   dd mIOleClientSite_AddRef
   dd mIOleClientSite_Release
   dd mIOleClientSite_SaveObject
   dd mIOleClientSite_GetMoniker
   dd mIOleClientSite_GetContainer
   dd mIOleClientSite_ShowObject
   dd mIOleClientSite_OnShowWindow
   dd mIOleClientSite_RequestNewObjectLayout

  label mIOleInPlaceSite :dword ; IOleInPlaceSite
   dd mIOleInPlaceSite_QueryInterface
   dd mIOleInPlaceSite_AddRef
   dd mIOleInPlaceSite_Release
   dd mIOleInPlaceSite_GetWindow
   dd mIOleInPlaceSite_ContextSensitiveHelp
   dd mIOleInPlaceSite_CanInPlaceActivate
   dd mIOleInPlaceSite_OnInPlaceActivate
   dd mIOleInPlaceSite_OnUIActivate
   dd mIOleInPlaceSite_GetWindowContext
   dd mIOleInPlaceSite_Scroll
   dd mIOleInPlaceSite_OnUIDeactivate
   dd mIOleInPlaceSite_OnInPlaceDeactivate
   dd mIOleInPlaceSite_DiscardUndoState
   dd mIOleInPlaceSite_DeactivateAndUndo
   dd mIOleInPlaceSite_OnPosRectChange
   
  pmIOleClientSite   dd mIOleClientSite
  pmIOleInPlaceSite  dd mIOleInPlaceSite

  ppw IWebBrowser2   ;<0>
  ppo IOleObject     ;<0>

.code 
   proc CreateOLEControl_WebBrowser2 bWhat:DWORD
    .if bWhat = TRUE

      INV CoCreateInstance,OFS CLSID_WebBrowser,NULL,\
        CLSCTX_INPROC,IID_IWebBrowser2,ppw
      .if eax=S_OK

      cominvk  ppw,QueryInterface,\
           IID_IOleObject,ppo

 .if eax=S_OK
          INV  OleSetContainedObject,[ppw],TRUE         
      cominvk  ppo,SetClientSite,pmIOleClientSite
         cominvk  ppo,DoVerb,OLEIVERB_INPLACEACTIVATE,\
          NULL,pmIOleClientSite,NULL,[hMainWnd],rcOLE
                
        cominvk  ppw,Navigate,navURL,\
          vnavFlags,vnavTarget,\
             vnavPostData,vnavHeaders
      .endif

       .endif 
 
     .else
       .if ppw!=0 && ppo!=0
      cominvk  ppw,Stop
   cominvk  ppo,Close,FALSE
    cominvk  ppo,Release
        cominvk  ppw,Release
        mov  ppw,0
  mov  ppo,0
       .endif
     .endif
     ret
   endp

   proc DlgProc hDlg,uMsg,wParam,lParam:DWORD
     pushad

     .if  uMsg=WM_CLOSE
       INV CreateOLEControl_WebBrowser2,FALSE
       INV OleUninitialize         
       INV EndDialog,[hDlg],0

     .elseif uMsg=WM_INITDIALOG
       INV OleInitialize,NULL
       INV SetDlgItemText,[hDlg],ID_CHANGE,szPokaz
       MOM hMainWnd,[hDlg]

     .elseif uMsg=WM_COMMAND
       .IF wParam=IDOK
          INV SendMessage,[hDlg],WM_CLOSE,0,0

       .elseif wParam=ID_CHANGE
          inc   [bJestOLE]     ; \ na przemian widoczna/
     and   [bJestOLE],1    ; / niewidoczna

   mov   eax,[bJestOLE]  ; eax=0 lub 1
         lea   eax,[eax*8+eax+szPokaz]

   INV SetDlgItemText,[hDlg],ID_CHANGE,eax

         INV CreateOLEControl_WebBrowser2,[bJestOLE]
       .endif

     .endif

     popad
     xor eax,eax
     ret
   endp

   Start:                     ; pocztek programu

     INV GetModuleHandle,NULL
     mov [hInstance],eax

     INV DialogBoxParam,[hInstance],ID_DLG_MAIN,0,DlgProc,0

     INV ExitProcess,0              ; powrót z programu


.end Start                       ; tu zaczyna si program

; section '.rsrc' resource data readable

  ; directory RT_DIALOG,dialogs

  ; resource dialogs,\
         ; ID_DLG_MAIN,LANG_ENGLISH+SUBLANG_DEFAULT,DlgProc

  ; dialog DlgProc,'Taskbar item control'0, 0, 268, 174,DS_SETFONT | DS_CENTER | WS_POPUP | 
    ; WS_CAPTION | WS_SYSMENU
    ; dialogitem 'BUTTON','OK',IDOK,211,154,50,14,WS_VISIBLE+WS_TABSTOP
    ; dialogitem 'BUTTON','',ID_CHANGE,90,153,86,15,WS_VISIBLE+WS_TABSTOP
  ; enddialog
    

I get message (from FASM)

Code:
flat assembler  version 1.69.14  (782910 kilobytes memory)
error: out of memory.    


J try rewrite (from MASM to FASM) example from a book.
J don't know that is a problem?

Original code from book

Code:
 ;
 ; ===========================================================
 ;  \Win32ASM\Src\COMIWebBrowser2\COMIWebBrowser2.asm
 ; ===========================================================
 ;                      Adam BBaszczyk
 ;              "Win32ASM. Asembler w Windows"
 ;                Wydawnictwo Helion, 2004
 ; ===========================================================
 ;  Kompilacja : "r.bat", "d.bat", "nmake"
 ;  Opis       : Wykorzystanie technologii COM w Win32ASM
 ;               - osadzanie kontrolki OLE na przykBadzie
 ;               kontrolki WebBrowser2 - czyli najmniejsza
 ;               przegldarka [wiata! 
 ; ===========================================================

 include ..\..\makro.inc       ; doBczamy definicje makr

 INCLUDEX kernel32             ; u|ywamy KERNEL32
 INCLUDEX user32               ; u|ywamy USER32
 INCLUDEX ole32                ; u|ywamy OLE32

 ID_DLG_MAIN   = 100
 ID_CHANGE     = 1002

.data?                         ; dane niezainicjalizowane
 hInstance dd ?
 hMainWnd dd ?

.data                          ; dane zainicjalizowane
; identyfikatory GUID
 XID CLSID_WebBrowser     ,'8856F961-340A-11D0-A96B-00C04FD705A2'
 XID IID_IWebBrowser2     ,'D30C1661-CDAF-11D0-8A3E-00C04FC9E26E'
 XID IID_IOleObject       ,'00000112-0000-0000-C000-000000000046'
 XID IID_IOleInPlaceObject,'00000113-0000-0000-C000-000000000046'
 XID IID_IOleInPlaceSite  ,'00000119-0000-0000-C000-000000000046'
 XID IID_IOleClientSite   ,'00000118-0000-0000-C000-000000000046'

 bJestOLE   dd FALSE 
 szPokaz    db 'Dodaj...',NULL
 szUkryj    db 'UsuD... ',NULL
 
 UNI uniNULL,<>
 UNI navURL,<file://C:/Win32ASM/Src/COMIWebBrowser2/Strona.html>
 
 vnavFlags    dw VT_I4,0,0,0
              dw FALSE 
 vnavTarget   dw VT_BSTR,0,0,0
              dd NULL
 vnavPostData dw 0,0,0,0 
              dd 0
 vnavHeaders  dw VT_BSTR,0,0,0
              dd NULL
 
 rcOLE RECT <0,0,100,100>
 
.code                          ; segment kodu (sekcja kodu)
  cmpGUID proc uses esi edi guid1,guid2:DWORD
    mov esi,guid1
    mov edi,guid2
    mov eax,[esi]
    cmp eax,[edi]
    jne cmpGUID_ret1
    mov eax,[esi+4]
    cmp eax,[edi+4]
    jne cmpGUID_ret1
    mov eax,[esi+8]
    cmp eax,[edi+8]
    jne cmpGUID_ret1
    mov eax,[esi+12]
    cmp eax,[edi+12]
    jne cmpGUID_ret1
   cmpGUID_ret0:  
    xor eax,eax
    ret
   cmpGUID_ret1:
    xor eax,eax
    inc eax
    ret
  cmpGUID endp

;-- IOleClientSite

  mIOleClientSite_QueryInterface  proc t,riid,ppvObject:DWORD
    DEBUGGUID "mIOleClientSite::QueryInterface"
    INV cmpGUID,riid,OFS IID_IOleInPlaceSite 
    .IF eax==0
      DEBUG "req mIOleClientSite_QueryInterface:IOleInPlaceSite"
      MOP ppvObject,OFS pmIOleInPlaceSite 
      mov eax,S_OK
    .ELSE
      MOP ppvObject,NULL
      mov eax,E_NOINTERFACE
    .ENDIF
    ret
  mIOleClientSite_QueryInterface  endp

  mIOleClientSite_AddRef proc t:DWORD
    DEBUG "mIOleClientSite_AddRef"
    xor eax,eax
    inc eax
    ret
  mIOleClientSite_AddRef endp

  mIOleClientSite_Release proc t:DWORD
    DEBUG "mIOleClientSite_Release"
    xor eax,eax
    ret
  mIOleClientSite_Release endp

  mIOleClientSite_SaveObject  proc t:DWORD
    DEBUG "mIOleClientSite_SaveObject"
    mov eax,S_OK
    ret
  mIOleClientSite_SaveObject  endp

  mIOleClientSite_GetMoniker  proc t,dwAssign,\
                              dwWhichMoniker,ppmk:DWORD
    DEBUG "mIOleClientSite_GetMoniker"
    mov eax,E_NOTIMPL
    ret
  mIOleClientSite_GetMoniker  endp

  mIOleClientSite_GetContainer proc t,ppContainer:DWORD
    DEBUG "mIOleClientSite_GetContainer"
    MOP ppContainer,NULL
    mov eax,E_NOINTERFACE
    ret
  mIOleClientSite_GetContainer endp

  mIOleClientSite_ShowObject   proc t:DWORD
    DEBUG "mIOleClientSite_ShowObject"
    mov eax,S_OK
    ret
  mIOleClientSite_ShowObject   endp

  mIOleClientSite_OnShowWindow proc t,fShow:DWORD 
    DEBUG "mIOleClientSite_OnShowWindow"
    mov eax,S_OK
    ret
  mIOleClientSite_OnShowWindow endp

  mIOleClientSite_RequestNewObjectLayout proc t:DWORD
    DEBUG "mIOleClientSite_RequestNewObjectLayout"
    mov eax,E_NOTIMPL
    ret
  mIOleClientSite_RequestNewObjectLayout endp
  
;-- IOleInPlaceSite

  mIOleInPlaceSite_QueryInterface proc t,riid,ppvObject:DWORD
    DEBUGGUID "mIOleInPlaceSite::QueryInterface"
    MOP ppvObject,NULL
    mov eax,E_NOINTERFACE
    ret
  mIOleInPlaceSite_QueryInterface endp
  
  mIOleInPlaceSite_AddRef proc t:DWORD
    DEBUG "mIOleInPlaceSite_AddRef"
    xor eax,eax
    inc eax
    ret
  mIOleInPlaceSite_AddRef endp
  
  mIOleInPlaceSite_Release proc t:DWORD
    DEBUG "mIOleInPlaceSite_Release"
    xor eax,eax
    ret
  mIOleInPlaceSite_Release endp

  mIOleInPlaceSite_GetWindow proc t,phwnd:DWORD
    DEBUG "mIOleInPlaceSite_GetWindow"
    MOP phwnd,hMainWnd   
    mov eax,S_OK
    ret
  mIOleInPlaceSite_GetWindow endp

  mIOleInPlaceSite_ContextSensitiveHelp proc t,fEnterMode:DWORD
    DEBUG "mIOleInPlaceSite_ContextSensitiveHelp"
    mov eax,S_OK
    ret
  mIOleInPlaceSite_ContextSensitiveHelp endp

  mIOleInPlaceSite_CanInPlaceActivate proc t:DWORD
    DEBUG "mIOleInPlaceSite_CanInPlaceActivate"
    mov eax,S_OK
    ret
  mIOleInPlaceSite_CanInPlaceActivate endp

  mIOleInPlaceSite_OnInPlaceActivate proc t:DWORD
    DEBUG "mIOleInPlaceSite_OnInPlaceActivate"
    mov eax,S_OK
    ret
  mIOleInPlaceSite_OnInPlaceActivate endp

  mIOleInPlaceSite_OnUIActivate proc t:DWORD
    DEBUG "mIOleInPlaceSite_OnUIActivate"
    mov eax,S_OK    
    ret
  mIOleInPlaceSite_OnUIActivate endp

  mIOleInPlaceSite_GetWindowContext proc t,ppFrame,ppDoc,\
                                    lprcPosRect,lprcClipRect,\
                                    lpFrameInfo:DWORD
    DEBUG "mIOleInPlaceSite_GetWindowContext"
    MOP ppFrame,NULL
    MOP ppDoc,NULL

    INV  GetClientRect,hMainWnd,OFS rcOLE
    add  rcOLE.top,1
    add  rcOLE.left,1 
    sub  rcOLE.bottom,40 
    sub  rcOLE.right,2
    mov  eax,lprcPosRect
    MOM  [eax.RECT.left],rcOLE.left
    MOM  [eax.RECT.top],rcOLE.top
    MOM  [eax.RECT.right],rcOLE.right
    MOM  [eax.RECT.bottom],rcOLE.bottom
    mov  eax,lprcClipRect
    MOM  [eax.RECT.left],rcOLE.left
    MOM  [eax.RECT.top],rcOLE.top
    MOM  [eax.RECT.right],rcOLE.right
    MOM  [eax.RECT.bottom],rcOLE.bottom   

    mov  eax,lpFrameInfo
    mov [eax.OLEINPLACEFRAMEINFO.fMDIApp],FALSE
    MOM [eax.OLEINPLACEFRAMEINFO.hwndFrame],hMainWnd
    mov [eax.OLEINPLACEFRAMEINFO.haccel],NULL
    mov [eax.OLEINPLACEFRAMEINFO.cAccelEntries],0
     
    mov eax,S_OK
    ret
  mIOleInPlaceSite_GetWindowContext endp

  mIOleInPlaceSite_Scroll proc t,scrollExtant:DWORD
    DEBUG "mIOleInPlaceSite_Scroll"
    mov eax,S_OK    
    ret
  mIOleInPlaceSite_Scroll endp

  mIOleInPlaceSite_OnUIDeactivate proc t,fUndoable:DWORD
    DEBUG "mIOleInPlaceSite_OnUIDeactivate"
    mov eax,S_OK    
    ret
  mIOleInPlaceSite_OnUIDeactivate endp

  mIOleInPlaceSite_OnInPlaceDeactivate proc t:DWORD
    DEBUG "mIOleInPlaceSite_OnInPlaceDeactivate"
    mov eax,S_OK    
    ret
  mIOleInPlaceSite_OnInPlaceDeactivate endp

  mIOleInPlaceSite_DiscardUndoState proc t:DWORD
    DEBUG "mIOleInPlaceSite_DiscardUndoState"
    mov eax,S_OK    
    ret
  mIOleInPlaceSite_DiscardUndoState endp

  mIOleInPlaceSite_DeactivateAndUndo proc t:DWORD
    DEBUG "mIOleInPlaceSite_DeactivateAndUndo"
    mov eax,S_OK    
    ret
  mIOleInPlaceSite_DeactivateAndUndo endp

  mIOleInPlaceSite_OnPosRectChange proc t,lprcPosRect:DWORD
    DEBUG "mIOleInPlaceSite_OnPosRectChange"
    mov eax,S_OK    
    ret
  mIOleInPlaceSite_OnPosRectChange endp
  
.data           
;-- tablice metod wirtualnych
  mIOleClientSite label dword ; IOleClientSite
   dd OFS mIOleClientSite_QueryInterface
   dd OFS mIOleClientSite_AddRef
   dd OFS mIOleClientSite_Release
   dd OFS mIOleClientSite_SaveObject
   dd OFS mIOleClientSite_GetMoniker
   dd OFS mIOleClientSite_GetContainer
   dd OFS mIOleClientSite_ShowObject
   dd OFS mIOleClientSite_OnShowWindow
   dd OFS mIOleClientSite_RequestNewObjectLayout

  mIOleInPlaceSite label DWORD ; IOleInPlaceSite
   dd OFS mIOleInPlaceSite_QueryInterface
   dd OFS mIOleInPlaceSite_AddRef
   dd OFS mIOleInPlaceSite_Release
   dd OFS mIOleInPlaceSite_GetWindow
   dd OFS mIOleInPlaceSite_ContextSensitiveHelp
   dd OFS mIOleInPlaceSite_CanInPlaceActivate
   dd OFS mIOleInPlaceSite_OnInPlaceActivate
   dd OFS mIOleInPlaceSite_OnUIActivate
   dd OFS mIOleInPlaceSite_GetWindowContext
   dd OFS mIOleInPlaceSite_Scroll
   dd OFS mIOleInPlaceSite_OnUIDeactivate
   dd OFS mIOleInPlaceSite_OnInPlaceDeactivate
   dd OFS mIOleInPlaceSite_DiscardUndoState
   dd OFS mIOleInPlaceSite_DeactivateAndUndo
   dd OFS mIOleInPlaceSite_OnPosRectChange
        
  pmIOleClientSite   dd OFS mIOleClientSite
  pmIOleInPlaceSite  dd OFS mIOleInPlaceSite

  ppw IWebBrowser2   <0>
  ppo IOleObject     <0>

.code 
   CreateOLEControl_WebBrowser2 proc bWhat:DWORD
    .IF bWhat==TRUE

      INV CoCreateInstance,OFS CLSID_WebBrowser,NULL,\
          CLSCTX_INPROC,OFS IID_IWebBrowser2,ADDR ppw
      DEBUG "CoCreateInstance:%d",eax
      .if eax==S_OK

        COM  ppw,IWebBrowser2::QueryInterface,\
             OFS IID_IOleObject,OFS ppo

        .if eax==S_OK
          INV  OleSetContainedObject,DPTR [ppw],TRUE         
          COM  ppo,IOleObject::SetClientSite,OFS pmIOleClientSite
          COM  ppo,IOleObject::DoVerb,OLEIVERB_INPLACEACTIVATE,\
               NULL,OFS pmIOleClientSite,NULL,hMainWnd,OFS rcOLE
          .IF eax==S_OK
            DEBUG "IOleObject::DoVerb:S_OK"
          .ENDIF
                      
          COM  ppw,IWebBrowser2::Navigate,OFS navURL,\
               OFS vnavFlags,OFS vnavTarget,\
               OFS vnavPostData,OFS vnavHeaders
          .IF eax==S_OK
            DEBUG "IWebBrowser2::Navigate:S_OK"
          .ENDIF
         .endif

       .endif 
 
     .ELSE
       .IF ppw!=0 && ppo!=0
         COM  ppw,IWebBrowser2::Stop
         COM  ppo,IOleObject::Close,FALSE
         COM  ppo,IOleObject::Release
         COM  ppw,IWebBrowser2::Release
         mov  ppw,0
         mov  ppo,0
       .ENDIF
     .ENDIF
     ret
   CreateOLEControl_WebBrowser2 endp

   DlgProc proc hDlg,uMsg,wParam,lParam:DWORD
     pushad

     .IF  uMsg==WM_CLOSE
       INV CreateOLEControl_WebBrowser2,FALSE
       INV OleUninitialize       
       INV EndDialog,hDlg,0

     .ELSEIF uMsg==WM_INITDIALOG
       INV OleInitialize,NULL
       INV SetDlgItemText,hDlg,ID_CHANGE,OFS szPokaz
       MOM hMainWnd,hDlg

     .ELSEIF uMsg==WM_COMMAND
       .IF wParam==IDOK
          INV SendMessage,hDlg,WM_CLOSE,0,0

       .ELSEIF wParam==ID_CHANGE
          inc   bJestOLE      ; \ na przemian widoczna/
          and   bJestOLE,1    ; / niewidoczna

          mov   eax,bJestOLE  ; eax=0 lub 1
          lea   eax,[eax*8+eax+OFS szPokaz]

          INV SetDlgItemText,hDlg,ID_CHANGE,eax

          INV CreateOLEControl_WebBrowser2,bJestOLE
        .ENDIF

     .ENDIF

     popad
     xor eax,eax
     ret
   DlgProc endp

   Start:                       ; pocztek programu

     INV GetModuleHandle,NULL
     mov hInstance,eax

     INV DialogBoxParam,hInstance,ID_DLG_MAIN,0,ADDR DlgProc,0

     INV ExitProcess,0          ; powrót z programu

END Start                       ; tu zaczyna si program
    


Last edited by tutenhamon on 03 Jul 2010, 15:25; edited 1 time in total
Post 03 Jul 2010, 14:36
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
There are more errors but this fix will stop the problem you talk about:

Replace what it is in red here: struct OLEINPLACEFRAMEINFO

Also note that by including win32ax.inc you are provided with struct macro which you may find more easy to use for Windows development. Check its documentation here: http://flatassembler.net/docs.php?article=win32#1.1

[edit]I better point out something more that may be not obvious:
Replace
Code:
    INV  equ invoke
        MOM  equ MOVM    
With
Code:
    INV  fix invoke
        MOM  fix MOVM    
Because you'll get "invalid instruction" error otherwise ("invoke" and "MOVM" are passed to the assembler when you actually need the preprocessor to expand the macro invocations)
Post 03 Jul 2010, 15:14
View user's profile Send private message Reply with quote
uor99



Joined: 04 Dec 2014
Posts: 42
uor99
The following fasm for webbrowse2 has no error, but without ideal results.

Any help,please. Thanks in advance.


Description:
Download
Filename: web_fasm.asm
Filesize: 9.78 KB
Downloaded: 78 Time(s)

Post 04 Dec 2014, 04:16
View user's profile Send private message ICQ Number Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar.

Powered by rwasa.