Code: Select all
Enumeration
#Web_0
#Panel_0
#Window_0
EndEnumeration
Declare Main()
Declare WebBrowser_(INT.l)
Declare.l WebBrowser_Scroll(Gadget.l,X.l,Y.l)
;-
Procedure WebBrowser_(INT.l)
Url.s = PeekS(INT)
If OpenWindow(#Window_0,#Null,#Null,1000,700,#NULL$,#PB_Window_SystemMenu)
If CreateGadgetList(WindowID(#Window_0))
PanelGadget(#Panel_0,#Null,#Null,1000,700)
AddGadgetItem(#Panel_0,1,"Ok")
WebGadget(#Web_0,#Null,#Null,WindowWidth(#Window_0)-3,WindowHeight(#Window_0)-22,Url)
CloseGadgetList()
EndIf
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
EndProcedure
;-
Procedure.l WebBrowser_Scroll(Gadget.l,X.l,Y.l)
CoInitialize_(#Null)
Res.l = #False
IWebBrowser2.IWebBrowser2 = GetWindowLong_(GadgetID(Gadget),#GWL_USERDATA)
IDispatch.IDispatch = #Null
IHTMLDocument3.IHTMLDocument3 = #Null
IHTMLElement.IHTMLElement = #Null
IHTMLElement2.IHTMLElement2 = #Null
If IWebBrowser2
If IWebBrowser2\get_Document(@IDispatch) = #S_OK And IDispatch
If IDispatch\QueryInterface(?IID_IHTMLDocument3,@IHTMLDocument3) = #S_OK And IHTMLDocument3
If IHTMLDocument3\get_documentElement(@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
IHTMLDocument3\Release()
EndIf
IHTMLDocument3\Release()
EndIf
;IWebBrowser2\Release()
EndIf
CoUninitialize_()
ProcedureReturn Res
EndProcedure
DataSection
IID_IWebBrowser2:
Data.l $D30C1661
Data.w $CDAF, $11D0
Data.b $8A, $3E, $00, $C0, $4F, $C9, $E2, $6E
IID_IConnectionPointContainer:
Data.l $B196B284
Data.w $BAB4, $101A
Data.b $B6, $9C, $00, $AA, $00, $34, $1D, $07
IID_IDispatch:
Data.l $00020400
Data.w $0000, $0000
Data.b $C0, $00, $00, $00, $00, $00, $00, $46
IID_IUnknown:
Data.l $00000000
Data.w $0000, $0000
Data.b $C0, $00, $00, $00, $00, $00, $00, $46
IID_DWebBrowserEvents2:
Data.l $34A715A0
Data.w $6587, $11D0
Data.b $92, $4A, $00, $20, $AF, $C7, $AC, $4D
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
IID_IHTMLDocument3:
Data.l $3050F485
Data.w $98B5, $11CF
Data.b $BB, $82, $00, $AA, $00, $BD, $CE, $0B
IID_IHTMLElement:
Data.l $3050F1FF
Data.w $98B5, $11CF
Data.b $BB, $82, $00, $AA, $00, $BD, $CE, $0B
EndDataSection
;-
Procedure Main()
While #True
Url.s = "http://www.purebasic.com"
Thread.l = CreateThread(@WebBrowser_(),@Url)
Sleep_(1000*20)
Debug WebBrowser_Scroll(#Web_0,20,20)
Sleep_(1000*10)
KillThread(Thread)
Wend
EndProcedure
WaitThread(CreateThread(@Main(),#Null))