From aaee4f863b548f467fb510bc1fdc8ca0671a918f Mon Sep 17 00:00:00 2001 From: "locka%iol.ie" Date: Wed, 3 Jul 2002 20:52:05 +0000 Subject: [PATCH] winEmbed window sizing fixes on behalf of steve-w@dircon.co.uk. b=152853 r/a=adamlock@netscape.com --- embedding/tests/winEmbed/WebBrowserChrome.cpp | 5 +++-- embedding/tests/winEmbed/winEmbed.cpp | 18 ++++++++++++++---- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/embedding/tests/winEmbed/WebBrowserChrome.cpp b/embedding/tests/winEmbed/WebBrowserChrome.cpp index abc98f3d6053..dcb81b2b48b5 100644 --- a/embedding/tests/winEmbed/WebBrowserChrome.cpp +++ b/embedding/tests/winEmbed/WebBrowserChrome.cpp @@ -194,12 +194,13 @@ NS_IMETHODIMP WebBrowserChrome::DestroyBrowserWindow(void) } -NS_IMETHODIMP WebBrowserChrome::SizeBrowserTo(PRInt32 aCX, PRInt32 aCY) +// IN: The desired browser client area dimensions. +NS_IMETHODIMP WebBrowserChrome::SizeBrowserTo(PRInt32 aWidth, PRInt32 aHeight) { /* This isn't exactly correct: we're setting the whole window to the size requested for the browser. At time of writing, though, it's fine and useful for winEmbed's purposes. */ - WebBrowserChromeUI::SizeTo(this, aCX, aCY); + WebBrowserChromeUI::SizeTo(this, aWidth, aHeight); mSizeSet = PR_TRUE; return NS_OK; } diff --git a/embedding/tests/winEmbed/winEmbed.cpp b/embedding/tests/winEmbed/winEmbed.cpp index 79215beabe14..776cd69e1cbe 100644 --- a/embedding/tests/winEmbed/winEmbed.cpp +++ b/embedding/tests/winEmbed/winEmbed.cpp @@ -1302,11 +1302,21 @@ void WebBrowserChromeUI::ShowWindow(nsIWebBrowserChrome *aChrome, PRBool aShow) void WebBrowserChromeUI::SizeTo(nsIWebBrowserChrome *aChrome, PRInt32 aWidth, PRInt32 aHeight) { - HWND win = GetBrowserDlgFromChrome(aChrome); - RECT winRect; + HWND hchrome = GetBrowserDlgFromChrome(aChrome); + HWND hbrowser = GetBrowserFromChrome(aChrome); + RECT chromeRect, browserRect; - ::GetWindowRect(win, &winRect); - ::MoveWindow(win, winRect.left, winRect.top, aWidth, aHeight, TRUE); + ::GetWindowRect(hchrome, &chromeRect); + ::GetWindowRect(hbrowser, &browserRect); + + PRInt32 decoration_x = (browserRect.left - chromeRect.left) + + (chromeRect.right - browserRect.right); + PRInt32 decoration_y = (browserRect.top - chromeRect.top) + + (chromeRect.bottom - browserRect.bottom); + + ::MoveWindow(hchrome, chromeRect.left, chromeRect.top, + aWidth+decoration_x, + aHeight+decoration_y, TRUE); } //