' ########################################################################################
' CWebView2NavigationCompletedEventHandlerImpl class
' Implementation of the ICoreWebView2NavigationCompletedEventHandler callback interface.
' ########################################################################################
TYPE CWebView2NavigationCompletedEventHandlerImpl EXTENDS CWebView2NavigationCompletedEventHandler
' ICoreWebView2NavigationCompletedEventHandler
DECLARE FUNCTION Invoke (BYVAL sender AS Afx_ICoreWebView2 PTR, BYVAL args AS Afx_ICoreWebView2NavigationCompletedEventArgs PTR) AS HRESULT
DECLARE CONSTRUCTOR (BYVAL pWebView2 AS CWebView2 PTR)
DECLARE DESTRUCTOR
m_pWebView2 AS CWebView2 PTR
m_token AS EventRegistrationToken
END TYPE
' ########################################################################################
' ========================================================================================
CONSTRUCTOR CWebView2NavigationCompletedEventHandlerImpl (BYVAL pWebView2 AS CWebView2 PTR)
CWV2_DP("")
IF pWebView2 THEN
m_pWebView2 = pWebView2
pWebView2->AddNavigationCompleted(cast(ANY PTR, @this), @m_token)
END IF
END CONSTRUCTOR
' ========================================================================================
' ========================================================================================
DESTRUCTOR CWebView2NavigationCompletedEventHandlerImpl
CWV2_DP("")
IF m_pWebView2 THEN m_pWebView2->RemoveNavigationCompleted(m_token)
END DESTRUCTOR
' ========================================================================================
' ========================================================================================
FUNCTION CWebView2NavigationCompletedEventHandlerImpl.Invoke (BYVAL sender AS Afx_ICoreWebView2 PTR, BYVAL args AS Afx_ICoreWebView2NavigationCompletedEventArgs PTR) AS HRESULT
CWV2_DP("*** Navigation completed ***")
RETURN S_OK
END FUNCTION
' ========================================================================================
DIM pEnv AS CWebView2NavigationCompletedEventHandlerImpl PTR
pEnv = NEW CWebView2NavigationCompletedEventHandlerImpl(@pWebView2)
FUNCTION wWinMain (BYVAL hInstance AS HINSTANCE, _
BYVAL hPrevInstance AS HINSTANCE, _
BYVAL pwszCmdLine AS WSTRING PTR, _
BYVAL nCmdShow AS LONG) AS LONG
' // Set process DPI aware
SetProcessDpiAwareness(PROCESS_SYSTEM_DPI_AWARE)
' // Enable visual styles without including a manifest file
AfxEnableVisualStyles
DIM pWindow AS CWindow
DIM hWin AS HWND = pWindow.Create(NULL, "WebView2", @WndProc)
pWindow.SetClientSize(1050, 500)
pWindow.Center
' DIM pWebView2 AS CWebView2 = hWin
DIM pWebView2 AS CWebView2 = CWebView2(hWin, ExePath)
IF pWebView2.IsReady(5000) THEN
' // Navigate to the web page
pWebView2.Navigate("https://www.planetsquires.com/protect/forum/index.php")
ELSE
' // Timeout
END IF
' // Dispatch Windows messages
FUNCTION = pWindow.DoEvents(nCmdShow)
END FUNCTION
extern "Windows" LIB "gdiplus.dll"
DECLARE FUNCTION GdiplusStartup (BYVAL token AS ULONG_PTR PTR, BYVAL input AS CONST GdiplusStartupInput PTR, BYVAL output AS GdiplusStartupOutput PTR) AS GpStatus
DECLARE SUB GdiplusShutdown (BYVAL token AS ULONG_PTR)
DECLARE FUNCTION GdipCreateBitmapFromFile (BYVAL filename AS CONST WSTRING PTR, BYVAL bmp AS GpBitmap PTR PTR) AS GpStatus
...
...
end extern
' =====================================================================================
' * Creates a Pen object that uses a specified color and width.
' =====================================================================================
PRIVATE CONSTRUCTOR CGpPen (BYVAL colour AS ARGB, BYVAL nWidth AS SINGLE = 1.0, BYVAL unit AS GpUnit = UnitWorld)
m_Status = GdipCreatePen1(colour, nWidth, unit, @m_pPen)
END CONSTRUCTOR
' =====================================================================================
' =====================================================================================
' Creates a Pen object that uses the attributes of a brush and a real number to set the
' width of this Pen object.
' =====================================================================================
PRIVATE CONSTRUCTOR CGpPen (BYVAL pBrush AS CGpBrush PTR, BYVAL nWidth AS SINGLE = 1.0, BYVAL unit AS GpUnit = UnitWorld)
m_Status = GdipCreatePen2(pBrush->m_pBrush, nWidth, unit, @m_pPen)
END CONSTRUCTOR
' =====================================================================================