Skip to content

Commit 591808f

Browse files
committed
Call NotifyParentWindowPositionChanged()
Call this in WM_MOVE and WM_MOVING messages to ensure the webview knows the window position changed. Also update the coding style with handling of braces.
1 parent 381fa8b commit 591808f

1 file changed

Lines changed: 15 additions & 5 deletions

File tree

src/WebView.cpp

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,14 @@ int CALLBACK WinMain(
114114

115115
CreateCoreWebView2EnvironmentWithOptions(nullptr, nullptr, options.Get(),
116116
Callback<ICoreWebView2CreateCoreWebView2EnvironmentCompletedHandler>(
117-
[hWnd, configJson](HRESULT result, ICoreWebView2Environment* env) -> HRESULT {
118-
117+
[hWnd, configJson](HRESULT result, ICoreWebView2Environment* env) -> HRESULT
118+
{
119119
// Create a CoreWebView2Controller and get the associated CoreWebView2 whose parent is the main window hWnd
120120
env->CreateCoreWebView2Controller(hWnd, Callback<ICoreWebView2CreateCoreWebView2ControllerCompletedHandler>(
121-
[hWnd, configJson](HRESULT result, ICoreWebView2Controller* controller) -> HRESULT {
122-
if (controller != nullptr) {
121+
[hWnd, configJson](HRESULT result, ICoreWebView2Controller* controller) -> HRESULT
122+
{
123+
if (controller != nullptr)
124+
{
123125
webviewController = controller;
124126
webviewController->get_CoreWebView2(&webview);
125127
}
@@ -164,12 +166,20 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
164166
switch (message)
165167
{
166168
case WM_SIZE:
167-
if (webviewController != nullptr) {
169+
if (webviewController != nullptr)
170+
{
168171
RECT bounds;
169172
GetClientRect(hWnd, &bounds);
170173
webviewController->put_Bounds(bounds);
171174
};
172175
break;
176+
case WM_MOVE:
177+
case WM_MOVING:
178+
if (webviewController != nullptr)
179+
{
180+
webviewController->NotifyParentWindowPositionChanged();
181+
}
182+
break;
173183
case WM_DESTROY:
174184
PostQuitMessage(0);
175185
break;

0 commit comments

Comments
 (0)