Code: Select all
; Freak from German forum
Enumeration
#Web_0
#Window_0
#String_0
#Button_0
EndEnumeration
Procedure WebGadget_Scroll(Gadget.l, x.l, y.l)
Protected Browser.IWebBrowser2
Protected Window.IHTMLWindow2
Protected DocumentDispatch.IDispatch
Protected Document.IHTMLDocument2
; Protected Element.IHTMLElement2
Browser.IWebBrowser2 = GetWindowLong_(GadgetID(Gadget), #GWL_USERDATA)
If Browser
If Browser\get_Document(@DocumentDispatch.IDispatch) = #S_OK
If DocumentDispatch\QueryInterface(?IID_IHTMLDocument2, @Document.IHTMLDocument2) = #S_OK
If Document\get_parentWindow(@Window.IHTMLWindow2) = #S_OK
While WindowEvent(): Wend ; wichtig!
If x=-1
window\scrollBY(0,y)
ElseIf y=-1
window\scrollBY(x,0)
Else
Window\ScrollTo(x, y)
EndIf
Window\Release()
EndIf
Document\Release()
EndIf
DocumentDispatch\Release()
EndIf
EndIf
EndProcedure
OpenWindow(0, 0, 0, 480, 480, "", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
WebGadget(0, 0, 20, 480, 460, "http://en.wikipedia.org")
ButtonGadget(1, 0, 0, 100, 20, "Scroll X by 250")
ButtonGadget(2, 100, 0, 100, 20, "Scroll Y by 250")
ButtonGadget(3, 200, 0, 100, 20, "Scroll to 200,200")
ButtonGadget(4, 300, 0, 100, 20, "Scroll to 300,300")
Repeat
Event = WaitWindowEvent()
If Event = #PB_Event_Gadget
Select (EventGadget())
Case 1
;
WebGadget_Scroll(0, 250, -1) ; resets Y
Debug "-------1-------"
Debug GetGadgetAttribute(0, #PB_Web_ScrollY)
Debug GetGadgetAttribute(0, #PB_Web_ScrollX)
Case 2
WebGadget_Scroll(0, -1,250) ; resets X
Debug "-------2-------"
Debug GetGadgetAttribute(0, #PB_Web_ScrollY)
Debug GetGadgetAttribute(0, #PB_Web_ScrollX)
Case 3
; SetGadgetAttribute(0, #PB_Web_ScrollX, 250)
; SetGadgetAttribute(0, #PB_Web_ScrollY, 250) ; resets X
WebGadget_Scroll(0,200,200)
Debug "-------3-------"
Debug GetGadgetAttribute(0, #PB_Web_ScrollY)
Debug GetGadgetAttribute(0, #PB_Web_ScrollX)
Case 4
;SetGadgetAttribute(0, #PB_Web_ScrollY, 250)
;SetGadgetAttribute(0, #PB_Web_ScrollX, 250) ; resets Y
WebGadget_Scroll(0,300,300)
Debug "-------4-------"
Debug GetGadgetAttribute(0, #PB_Web_ScrollY)
Debug GetGadgetAttribute(0, #PB_Web_ScrollX)
EndSelect
EndIf
Until (Event = #PB_Event_CloseWindow)
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