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_Test = 1002
Function PBMain
Local hDlg As Dword, bstrURL As WString
Dialog New Pixels, 0, "WebBrowser", , , 600, 500, %WS_OverlappedWindow To hDlg
Control Add Button, hDlg, %IDC_Test, "Test", 400,10,50,20
Local pWindow As IWindow
pWindow = Class "CWindow"
bstrURL = "http://www.garybeene.com"
pWindow.AddWebBrowserControl(hDlg, %IDC_WEBBROWSER, bstrURL, Nothing, 0, 40, 600,350)
Dialog Show Modal hDlg, Call DlgProc
End Function
CallBack Function DlgProc() As Long
Local pIWebBrowser2 As IWebBrowser2
Local pIHTMLDocument2 As IHTMLDocument2
Local pElement As IHTMLElement
Local pElement2 As IHTMLElement2
Local w,h As Long, hBrowser As Dword
Select Case CbMsg
Case %WM_Command
Select Case Cb.Ctl
Case %IDC_Test
hBrowser = GetDlgItem(Cb.Hndl,%IDC_WebBrowser)
pIWebBrowser2 = OC_GetDispatch(hBrowser) 'reference to webbrowser control default interface
pIHTMLDocument2 = pIWebBrowser2.Document
pElement = pIHTMLDocument2.body
pElement2 = pElement
h = pElement2.scrolltop
? Str$(h)
End Select
Case %WM_Size
If Cb.WParam <> %Size_Minimized Then
Dialog Get Client Cb.Hndl To w,h
Control Set Size Cb.Hndl, %IDC_WebBrowser, w, h-40
End If
End Select
End Function
'gbs_01436
'Date: 10-17-2014
http://www.garybeene.com/sw/gbsnippets.htm