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_HighLight = 1006
%IDC_SearchTerm = 1007
Function PBMain
Local hDlg As Dword, bstrURL As WString
Dialog New Pixels, 0, "WebBrowser", , , 800, 1000, %WS_OverlappedWindow To hDlg
Control Add Button, hDlg, %IDC_HighLight, "Highlight", 10,10,100,20
Control Add TextBox, hDlg, %IDC_SearchTerm, "for site", 120,10,100,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 'instance of the webbrowser control
Local hBrowser As Dword 'handle to window containing web browser
Local pDisp As IDispatch
Local pIHTMLDocument As IHTMLDocument2
Local pIHTMLSelectionObject As IHTMLSelectionObject
Local pDispatch As IDispatch
Local pIHTMLTxtRange As IHTMLTxtRange
Local i, iRes As Integer, tmp$
Select Case CbMsg
Case %WM_Command
Select Case Cb.Ctl
Case %IDC_Highlight
hBrowser = GetDlgItem(Cb.Hndl,%IDC_WebBrowser)
pIWebBrowser2 = OC_GetDispatch(hBrowser) 'reference to webbrowser control default interface
pIHTMLDocument = pIWebBrowser2.Document
pIHTMLSelectionObject = pIHTMLDocument.selection
pDispatch = pIHTMLSelectionObject.createRange
pIHTMLTxtRange = pDispatch
? pIHTMLTxtRange.text
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
'gbs_01324
'Date: 05-11-2013
http://www.garybeene.com/sw/gbsnippets.htm