|
| 1 | +#AutoIt3Wrapper_UseX64=y |
| 2 | +#include <GUIConstantsEx.au3> |
| 3 | +#include <WindowsConstants.au3> |
| 4 | + |
| 5 | +#include "..\NetWebView2Lib.au3" |
| 6 | + |
| 7 | +; ============================================================================== |
| 8 | +; WebView2 Multi-Channel Presentation Script |
| 9 | +; ============================================================================== |
| 10 | + |
| 11 | +; Global objects |
| 12 | + |
| 13 | +; GUI & Controls |
| 14 | +Global $hGUI, $idLabelStatus |
| 15 | + |
| 16 | +Main() |
| 17 | + |
| 18 | +Func Main() |
| 19 | + Local $oMyError = ObjEvent("AutoIt.Error", __NetWebView2_COMErrFunc) |
| 20 | + #forceref $oMyError |
| 21 | + |
| 22 | + ; Create the UI |
| 23 | + Local $iHeight = 400 |
| 24 | + $hGUI = GUICreate("WebView2 .NET Manager - Community Demo", 800, $iHeight, -1, -1, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPCHILDREN)) |
| 25 | + $idLabelStatus = GUICtrlCreateLabel("Status: Initializing Engine...", 10, $iHeight -20 , 880, 20) |
| 26 | + GUICtrlSetFont(-1, 9, 400, 0, "Segoe UI") |
| 27 | + |
| 28 | + ; Initialize WebView2 Manager and register events |
| 29 | + Local $oWebV2M = _NetWebView2_CreateManager() |
| 30 | + $_g_oWeb = $oWebV2M |
| 31 | + If @error Then Return SetError(@error, @extended, $oWebV2M) |
| 32 | + |
| 33 | + ; Initialize JavaScript Bridge |
| 34 | + Local $oJSBridge = _NetWebView2_GetBridge($oWebV2M, "_BridgeMyEventsHandler_") |
| 35 | + If @error Then Return SetError(@error, @extended, $oWebV2M) |
| 36 | + |
| 37 | + Local $sProfileDirectory = @TempDir & "\NetWebView2Lib-UserDataFolder" |
| 38 | + _NetWebView2_Initialize($oWebV2M, $hGUI, $sProfileDirectory, 0, 0, 0, 0, True, True, True, 1.2, "0x2B2B2B") |
| 39 | + |
| 40 | + GUISetState(@SW_SHOW) |
| 41 | + ConsoleWrite("! ===" & @ScriptLineNumber & @CRLF) |
| 42 | + MsgBox($MB_TOPMOST, "TEST #" & @ScriptLineNumber, 0) |
| 43 | + Local $s_PDF_FileFullPath |
| 44 | + |
| 45 | + $s_PDF_FileFullPath = "file:///" & @ScriptDir & '/FileViewerDemo_1.pdf' |
| 46 | + _NetWebView2_Navigate($oWebV2M, $s_PDF_FileFullPath) |
| 47 | + ConsoleWrite("! ===" & @ScriptLineNumber & @CRLF) |
| 48 | + MsgBox($MB_TOPMOST, "TEST #" & @ScriptLineNumber, $s_PDF_FileFullPath) |
| 49 | + |
| 50 | + $s_PDF_FileFullPath = "file:///" & @ScriptDir & '/FileViewerDemo_2.pdf' |
| 51 | + _NetWebView2_Navigate($oWebV2M, $s_PDF_FileFullPath) |
| 52 | + ConsoleWrite("! ===" & @ScriptLineNumber & @CRLF) |
| 53 | + MsgBox($MB_TOPMOST, "TEST #" & @ScriptLineNumber, $s_PDF_FileFullPath) |
| 54 | + |
| 55 | + ; Main Loop |
| 56 | + While 1 |
| 57 | + Switch GUIGetMsg() |
| 58 | + Case $GUI_EVENT_CLOSE |
| 59 | + ExitLoop |
| 60 | + EndSwitch |
| 61 | + WEnd |
| 62 | + |
| 63 | + GUIDelete($hGUI) |
| 64 | + |
| 65 | + _NetWebView2_CleanUp($oWebV2M, $oJSBridge) |
| 66 | +EndFunc ;==>Main |
0 commit comments