Skip to content

Commit 7a10488

Browse files
authored
Add resizing
1 parent 838af6e commit 7a10488

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

WebView2Sample/HelloWebView.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ HINSTANCE hInst;
2323
// Forward declarations of functions included in this code module:
2424
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
2525

26+
// Pointer to WebView window
27+
static ComPtr<IWebView2WebView> webviewWindow;
28+
2629
int CALLBACK WinMain(
2730
_In_ HINSTANCE hInstance,
2831
_In_ HINSTANCE hPrevInstance,
@@ -125,6 +128,13 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
125128

126129
switch (message)
127130
{
131+
case WM_SIZE:
132+
if (webviewWindow != nullptr) {
133+
RECT bounds;
134+
GetClientRect(hWnd, &bounds);
135+
webviewWindow->put_Bounds(bounds);
136+
};
137+
break;
128138
case WM_DESTROY:
129139
PostQuitMessage(0);
130140
break;
@@ -134,4 +144,4 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
134144
}
135145

136146
return 0;
137-
}
147+
}

0 commit comments

Comments
 (0)