IWebBrowser2 error

Just starting out? Need help? Post your questions and find answers here.
Rascal
User
User
Posts: 30
Joined: Mon Sep 17, 2007 11:06 pm

IWebBrowser2 error

Post by Rascal »

Code: Select all


Enumeration
  #Web_0
  #Window_0
  #String_0
  #Button_0
EndEnumeration

Procedure.l WebBrowser_Scroll(Gadget.l,X.l,Y.l)
If X = #Null And Y = #Null
   ProcedureReturn #False
EndIf
Res.l = #False
IWebBrowser2.IWebBrowser2     = GetWindowLong_(GadgetID(Gadget),#GWL_USERDATA)
IDispatch.IDispatch           = #Null
IHTMLDocument2.IHTMLDocument2 = #Null
IHTMLElement.IHTMLElement     = #Null
IHTMLElement2.IHTMLElement2   = #Null

If IWebBrowser2
 If IWebBrowser2\get_document(@IDispatch) = #S_OK ;And IDispatch
  If IDispatch\QueryInterface(?IID_IHTMLDocument2, @IHTMLDocument2.IHTMLDocument2) = #S_OK And IHTMLDocument2
   If IHTMLDocument2\get_body(@IHTMLElement.IHTMLElement) = #S_OK And IHTMLElement
    If IHTMLElement\QueryInterface(?IID_IHTMLElement2,@IHTMLElement2) = #S_OK And IHTMLElement2
     If IHTMLElement2\put_scrollTop(Y) = #S_OK And IHTMLElement2\put_scrollLeft(X) = #S_OK
        Res = #True
     EndIf
     IHTMLElement2\Release()
    EndIf
    IHTMLElement\Release()
   EndIf
   IHTMLDocument2\Release()
  EndIf
  IDispatch\Release()
 EndIf
 IWebBrowser2\Release()
EndIf
ProcedureReturn Res
EndProcedure



If OpenWindow(#Window_0,#Null,#Null,1000,700,#NULL$,#PB_Window_SystemMenu)
 If CreateGadgetList(WindowID(#Window_0))
    WebGadget(#Web_0,#Null,20,1000, 700, "about:blank")
    ButtonGadget(#Button_0,#Null,#Null,170,20,"Scroll") 
 EndIf
 Repeat
  EventID  = WaitWindowEvent()
   Select EventID
     Case #PB_Event_Gadget
       Select EventGadget()
         Case #Button_0
           For i = 1 To 100
             WebBrowser_Scroll(#Web_0,100,100)
             Debug i
           Next i
       EndSelect  
   EndSelect
 Until EventID = #PB_Event_CloseWindow
EndIf

DataSection 
IID_IHTMLDocument2: 
Data.l $332C4425 
Data.w $26CB, $11D0 
Data.b $B4, $83, $00, $C0, $4F, $D9, $01, $19 
IID_IHTMLElement2: 
Data.l $3050F434 
Data.w $98B5, $11CF 
Data.b $BB, $82, $00, $AA, $00, $BD, $CE, $0B 
EndDataSection

Why circle 24 times after error
User avatar
Fluid Byte
Addict
Addict
Posts: 2336
Joined: Fri Jul 21, 2006 4:41 am
Location: Berlin, Germany

Post by Fluid Byte »

Dude, I won't even bother to look at your code until you stop this kind of moronic behaviour. :x
Windows 10 Pro, 64-Bit / Whose Hoff is it anyway?
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post by PB »

Is this that Chinese guy again? Same big red text. :evil: Wish he'd nick off once and for all.
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

Try this :

Code: Select all

Enumeration
  #Web_0
  #Window_0
  #String_0
  #Button_0
EndEnumeration

Procedure.l WebBrowser_Scroll(Gadget.l,X.l,Y.l)
  If X = #NULL And Y = #NULL
    ProcedureReturn #False
  EndIf
  Res.l = #False
  IWebBrowser2.IWebBrowser2     = GetWindowLong_(GadgetID(Gadget),#GWL_USERDATA)
  IDispatch.IDispatch           = #NULL
  IHTMLDocument2.IHTMLDocument2 = #NULL
  IHTMLElement.IHTMLElement     = #NULL
  IHTMLElement2.IHTMLElement2   = #NULL
  
  If IWebBrowser2
    If IWebBrowser2\get_document(@IDispatch) = #S_OK ;And IDispatch
      If IDispatch\QueryInterface(?IID_IHTMLDocument2, @IHTMLDocument2.IHTMLDocument2) = #S_OK And IHTMLDocument2
        If IHTMLDocument2\get_body(@IHTMLElement.IHTMLElement) = #S_OK And IHTMLElement
          If IHTMLElement\QueryInterface(?IID_IHTMLElement2,@IHTMLElement2) = #S_OK And IHTMLElement2
            If IHTMLElement2\put_scrollTop(Y) = #S_OK And IHTMLElement2\put_scrollLeft(X) = #S_OK
              Res = #True
            EndIf
            IHTMLElement2\Release()
          EndIf
          IHTMLElement\Release()
        EndIf
        IHTMLDocument2\Release()
      EndIf
      IDispatch\Release()
    EndIf
    ;IWebBrowser2\Release()
  EndIf
  ProcedureReturn Res
EndProcedure



If OpenWindow(#Window_0,#NULL,#NULL,1000,700,#NULL$,#PB_Window_SystemMenu)
  If CreateGadgetList(WindowID(#Window_0))
    WebGadget(#Web_0,#NULL,20,1000, 700, "about:blank")
    ButtonGadget(#Button_0,#NULL,#NULL,170,20,"Scroll")
  EndIf
  Repeat
    EventID  = WaitWindowEvent()
    Select EventID
      Case #PB_Event_Gadget
        Select EventGadget()
          Case #Button_0
            For i = 1 To 1000
              WebBrowser_Scroll(#Web_0,100,100)
              Debug i
            Next i
        EndSelect 
    EndSelect
  Until EventID = #PB_Event_CloseWindow
EndIf

DataSection
  IID_IHTMLDocument2:
  Data.l $332C4425
  Data.w $26CB, $11D0
  Data.b $B4, $83, $00, $C0, $4F, $D9, $01, $19
  IID_IHTMLElement2:
  Data.l $3050F434
  Data.w $98B5, $11CF
  Data.b $BB, $82, $00, $AA, $00, $BD, $CE, $0B
EndDataSection
Please avoid the big red text. Thanks !
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
Post Reply