Date: 02-16-2022
Return to Index
created by gbSnippets
'Compilable Example: (Jose Includes)
#Compile Exe
#Dim All
%Unicode = 1
%UseWebBrowser = 1 ' // Use the WebBrowser control
#Include Once "CWindow.inc" ' // CWindow class
%IDC_WebBrowser = 1001
%IDC_ToTop = 1002
%IDC_ToBottom = 1003
Global hDlg,hBrowser As Dword
Function PBMain
Local pWindow As IWindow, bstrURL As WString
Dialog New Pixels, 0, "WebBrowser", , , 350, 250, %WS_OverlappedWindow To hDlg
Control Add Button, hDlg, %IDC_ToTop, "To Top", 10,10,75,20
Control Add Button, hDlg, %IDC_ToBottom, "To Bottom", 90,10,75,20
pWindow = Class "CWindow"
bstrURL = "http://www.powerbasic.com"
hBrowser = pWindow.AddWebBrowserControl(hDlg, %IDC_WebBrowser, bstrURL, Nothing, 0, 40, 600,350)
Dialog Show Modal hDlg, Call DlgProc
End Function
CallBack Function DlgProc() As Long
Select Case CbMsg
Case %WM_Command
Select Case Cb.Ctl
Case %IDC_ToTop : GoToPosition(0,0)
Case %IDC_ToBottom : GoToPosition(0,100000)
End Select
Case %WM_Size
If Cb.WParam <> %Size_Minimized Then
Local w,h As Long
Dialog Get Client Cb.Hndl To w,h
Control Set Size Cb.Hndl, %IDC_WebBrowser, w, h-40
End If
End Select
End Function
Sub GoToPosition(x As Long, y As Long)
Local pIWebBrowser2 As IWebBrowser2
Local pIHTMLDocument2 As IHTMLDocument2
Local pIHTMLWindow2 As IHTMLWindow2
pIWebBrowser2 = OC_GetDispatch(hBrowser) 'reference to webbrowser control default interface
pIHTMLDocument2 = pIWebBrowser2.Document
pIHTMLWindow2 = pIHTMLDocument2.parentWindow
pIHTMLWindow2.ScrollTo(x,y)
End Sub
'gbs_01331
'Date: 05-11-2013
http://www.garybeene.com/sw/gbsnippets.htm