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_ZoomIn = 1002
%IDC_ZoomOut = 1003
%IDC_Zoom100 = 1004
Global hDlg, hBrowser As Dword
Function PBMain
Local pWindow As IWindow
Dialog New Pixels, 0, "WebBrowser",0, 40, 600, 400, %WS_OverlappedWindow To hDlg
Control Add Button, hDlg, %IDC_ZoomIn, "ZoomIn", 10,10,50,25
Control Add Button, hDlg, %IDC_ZoomOut, "ZoomOut", 110,10,50,25
Control Add Button, hDlg, %IDC_Zoom100, "Zoom100", 210,10,50,25
pWindow = Class "CWindow"
hBrowser = pWindow.AddWebBrowserControl(hDlg, %IDC_WEBBROWSER, "http://www.garybeene.com", Nothing, 0, 40, 600,400)
Dialog Show Modal hDlg, Call DlgProc
End Function
CallBack Function DlgProc() As Long
Local pIWebBrowser2 As IWebBrowser2
Select Case Cb.Msg
Case %WM_Command
Select Case Cb.Ctl
Case %IDC_ZoomIn : ZoomIn
Case %IDC_ZoomOut : ZoomOut
Case %IDC_Zoom100 : Zoom100
End Select
End Select
End Function
Sub ZoomIn
Local pIWebBrowser2 As IWebBrowser2
Local nZoom As Long ' // Zoom
Local vZoom As Variant ' // Zoom
' // Call the ExecWB method to get the current zoom factor
pIWebBrowser2 = OC_GetDispatch(hBrowser)
pIWebBrowser2.ExecWB %OLECMDID_OPTICAL_ZOOM, %OLECMDEXECOPT_DONTPROMPTUSER, ByVal %NULL, vZoom
nZoom = Variant#(vZoom)
If nZoom < 990 Then nZoom +=10
' // Call the ExecWB method to set the new zoom factor
vZoom = nZoom As Long ' The 'AS LONG' part is important!
pIWebBrowser2.ExecWB %OLECMDID_OPTICAL_ZOOM, %OLECMDEXECOPT_DONTPROMPTUSER, vZoom
pIWebBrowser2 = Nothing
End Sub
Sub ZoomOut
Local pIWebBrowser2 As IWebBrowser2
Local nZoom As Long ' // Zoom
Local vZoom As Variant ' // Zoom
' // Call the ExecWB method to get the current font zoom scale
pIWebBrowser2 = OC_GetDispatch(hBrowser)
pIWebBrowser2.ExecWB %OLECMDID_OPTICAL_ZOOM, %OLECMDEXECOPT_DONTPROMPTUSER, ByVal %NULL, vZoom
nZoom = Variant#(vZoom)
If nZoom > 20 Then nZoom -=10
' // Call the ExecWB method to set the new font zoom scale
vZoom = nZoom As Long ' The 'AS LONG' part is important!
pIWebBrowser2.ExecWB %OLECMDID_OPTICAL_ZOOM, %OLECMDEXECOPT_DONTPROMPTUSER, vZoom
End Sub
Sub Zoom100
Local pIWebBrowser2 As IWebBrowser2
Local vZoom As Variant ' // Zoom
pIWebBrowser2 = OC_GetDispatch(hBrowser)
vZoom = 100 As Long ' The 'AS LONG' part is important!
pIWebBrowser2.ExecWB %OLECMDID_OPTICAL_ZOOM, %OLECMDEXECOPT_DONTPROMPTUSER, vZoom
End Sub
'gbs_01336
'Date: 05-11-2013
http://www.garybeene.com/sw/gbsnippets.htm