Skip to content

Commit 69de937

Browse files
committed
Backport part of #661 so that when size of WinForms browser is 0x0, it's set to SWP_NOMOVE && SWP_NOACTIVATE
1 parent 349edc7 commit 69de937

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

CefSharp.Core/ManagedCefBrowserAdapter.h

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,19 @@ namespace CefSharp
484484
void Resize(int width, int height)
485485
{
486486
HWND browserHwnd = _renderClientAdapter->GetBrowserHwnd();
487-
SetWindowPos(browserHwnd, NULL, 0, 0, width, height, SWP_NOZORDER);
487+
if (browserHwnd)
488+
{
489+
if (width == 0 && height == 0)
490+
{
491+
// For windowed browsers when the frame window is minimized set the
492+
// browser window size to 0x0 to reduce resource usage.
493+
SetWindowPos(browserHwnd, NULL, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOMOVE | SWP_NOACTIVATE);
494+
}
495+
else
496+
{
497+
SetWindowPos(browserHwnd, NULL, 0, 0, width, height, SWP_NOZORDER);
498+
}
499+
}
488500
}
489501

490502
void RegisterJsObject(String^ name, Object^ object)

0 commit comments

Comments
 (0)