Skip to content

Commit 3aa9819

Browse files
authored
Update 011-TwinWebView.au3
1 parent 8be9453 commit 3aa9819

1 file changed

Lines changed: 11 additions & 20 deletions

File tree

examples/011-TwinWebView.au3

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@
1919
#include <WindowsConstants.au3>
2020
#include <StaticConstants.au3>
2121
#include <EditConstants.au3>
22+
#include "..\NetWebView2Lib.au3"
2223
#include "_WV2_ExtensionPicker.au3"
2324

24-
OnAutoItExitRegister("_ExitApp")
25+
OnAutoItExitRegister(_ExitApp)
2526

2627
; Global Objects & Handles
2728
Global $oWeb1, $oWeb2
@@ -50,7 +51,7 @@ Func _MainGUI() ; Creates the primary application window and starts the message
5051
GUICtrlSetResizing(-1, $GUI_DOCKALL)
5152

5253
; Register the WM_SIZE message to handle window resizing dynamically
53-
GUIRegisterMsg($WM_SIZE, "WM_SIZE")
54+
GUIRegisterMsg($WM_SIZE, WM_SIZE)
5455

5556
; Initialize Browsers and their child window containers
5657
_InitBrowsers()
@@ -168,32 +169,22 @@ Func _InitBrowsers() ; Creates child window containers and initializes WebView2
168169
; Instance 1 - "Profile_1" folder
169170
$hID1 = GUICreate("", 485, 580, 10, 10, BitOR($WS_CHILD, $WS_CLIPCHILDREN), -1, $hMainGUI)
170171
$Bar1 = _Web_MakeBar($hID1, $sExtras)
171-
$oWeb1 = ObjCreate("NetWebView2.Manager")
172-
ObjEvent($oWeb1, "Web1_", "IWebViewEvents")
173-
$oBridge1 = $oWeb1.GetBridge()
174-
ObjEvent($oBridge1, "Bridge1_", "IBridgeEvents")
172+
$oWeb1 = _NetWebView2_CreateManager("", "Web1_")
173+
$oBridge1 = _NetWebView2_GetBridge($oWeb1, "Bridge1_")
175174
$Bar1.Web_ProfilePath = $sProfileDirectory
176-
$oWeb1.Initialize($hID1, $sProfileDirectory, 0, 25, 485, 555)
175+
_NetWebView2_Initialize($oWeb1, $hID1, $sProfileDirectory, 0, 25, 485, 555, True, True, 1.2, "0x2B2B2B", False)
176+
_NetWebView2_Navigate($oWeb1, "https://www.google.com/search?q=web1")
177177

178178
; Instance 2 - "Profile_2" folder
179179
$hID2 = GUICreate("", 485, 580, 505, 10, BitOR($WS_CHILD, $WS_CLIPCHILDREN), -1, $hMainGUI)
180180
$Bar2 = _Web_MakeBar($hID2, $sExtras)
181-
$oWeb2 = ObjCreate("NetWebView2.Manager")
182-
ObjEvent($oWeb2, "Web2_", "IWebViewEvents")
183-
$oBridge2 = $oWeb2.GetBridge()
184-
ObjEvent($oBridge2, "Bridge2_", "IBridgeEvents")
181+
$oWeb2 = _NetWebView2_CreateManager("", "Web2_")
182+
$oBridge2 = _NetWebView2_GetBridge($oWeb2, "Bridge2_")
185183
$Bar2.Web_ProfilePath = @ScriptDir & "\Profile_2"
186-
$oWeb2.Initialize($hID2, @ScriptDir & "\Profile_2", 0, 25, 485, 555)
187-
188-
; Wait until both instances are ready
189-
Do
190-
Sleep(10)
191-
Until $oWeb1.IsReady And $oWeb2.IsReady
184+
_NetWebView2_Initialize($oWeb2, $hID2, $sProfileDirectory, 0, 25, 485, 555, True, True, 1.2, "0x2B2B2B", False)
185+
_NetWebView2_Navigate($oWeb2, "https://www.google.com/search?q=web2")
192186

193-
_NetWebView2_Navigate($oWeb1, "https://www.google.com/search?q=web1")
194187
GUISetState(@SW_SHOWNOACTIVATE, $hID1)
195-
196-
$oWeb2.Navigate("https://www.google.com/search?q=web2")
197188
GUISetState(@SW_SHOWNOACTIVATE, $hID2)
198189

199190
EndFunc ;==>_InitBrowsers

0 commit comments

Comments
 (0)