Dmitry Timoshkov : user32:
Windows uses ptMaxTrackSize to set an initial window size not
ptMaxSize.
Alexandre Julliard
julliard at wine.codeweavers.com
Fri Apr 6 06:08:00 CDT 2007
Module: wine
Branch: master
Commit: 56852a5eac44213258f46dc4f4fe4e38d58a560c
URL: http://source.winehq.org/git/wine.git/?a=commit;h=56852a5eac44213258f46dc4f4fe4e38d58a560c
Author: Dmitry Timoshkov <dmitry at codeweavers.com>
Date: Sun Apr 8 19:28:05 2007 +0900
user32: Windows uses ptMaxTrackSize to set an initial window size not ptMaxSize.
---
dlls/user32/tests/win.c | 67 +++++++++++++++++++++++++++++++++++++-------
dlls/winex11.drv/window.c | 11 +++++--
2 files changed, 64 insertions(+), 14 deletions(-)
diff --git a/dlls/user32/tests/win.c b/dlls/user32/tests/win.c
index 5502bf9..632fcc1 100644
--- a/dlls/user32/tests/win.c
+++ b/dlls/user32/tests/win.c
@@ -3718,8 +3718,36 @@ static void test_IsWindowUnicode(void)
DestroyWindow(hwnd);
}
+static LRESULT CALLBACK minmax_wnd_proc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
+{
+ MINMAXINFO *minmax;
+
+ if (msg != WM_GETMINMAXINFO)
+ return DefWindowProc(hwnd, msg, wp, lp);
+
+ minmax = (MINMAXINFO *)lp;
+
+ if ((GetWindowLong(hwnd, GWL_STYLE) & WS_CHILD))
+ {
+ minmax->ptReserved.x = 0;
+ minmax->ptReserved.y = 0;
+ minmax->ptMaxSize.x = 400;
+ minmax->ptMaxSize.y = 400;
+ minmax->ptMaxPosition.x = 300;
+ minmax->ptMaxPosition.y = 300;
+ minmax->ptMaxTrackSize.x = 200;
+ minmax->ptMaxTrackSize.y = 200;
+ minmax->ptMinTrackSize.x = 100;
+ minmax->ptMinTrackSize.y = 100;
+ }
+ else
+ DefWindowProc(hwnd, msg, wp, lp);
+ return 1;
+}
+
static void test_CreateWindow(void)
{
+ WNDCLASS cls;
HWND hwnd, parent;
HMENU hmenu;
RECT rc, rc_minmax;
@@ -3917,8 +3945,20 @@ static void test_CreateWindow(void)
ok(GetLastError() == ERROR_INVALID_MENU_HANDLE, "IsMenu set error %d\n", GetLastError());
/* test child window sizing */
+ cls.style = 0;
+ cls.lpfnWndProc = minmax_wnd_proc;
+ cls.cbClsExtra = 0;
+ cls.cbWndExtra = 0;
+ cls.hInstance = GetModuleHandle(0);
+ cls.hIcon = 0;
+ cls.hCursor = LoadCursorA(0, (LPSTR)IDC_ARROW);
+ cls.hbrBackground = GetStockObject(WHITE_BRUSH);
+ cls.lpszMenuName = NULL;
+ cls.lpszClassName = "MinMax_WndClass";
+ RegisterClass(&cls);
+
SetLastError(0xdeadbeef);
- parent = CreateWindowEx(0, "static", NULL, WS_CAPTION | WS_SYSMENU | WS_THICKFRAME,
+ parent = CreateWindowEx(0, "MinMax_WndClass", NULL, WS_CAPTION | WS_SYSMENU | WS_THICKFRAME,
0, 0, 100, 100, 0, 0, 0, NULL);
ok(parent != 0, "CreateWindowEx error %d\n", GetLastError());
expect_menu(parent, 0);
@@ -3928,19 +3968,20 @@ static void test_CreateWindow(void)
memset(&minmax, 0, sizeof(minmax));
SendMessage(parent, WM_GETMINMAXINFO, 0, (LPARAM)&minmax);
SetRect(&rc_minmax, 0, 0, minmax.ptMaxSize.x, minmax.ptMaxSize.y);
- ok(IsRectEmpty(&rc_minmax), "rc_minmax is not empty\n");
+ ok(IsRectEmpty(&rc_minmax), "ptMaxSize is not empty\n");
+ SetRect(&rc_minmax, 0, 0, minmax.ptMaxTrackSize.x, minmax.ptMaxTrackSize.y);
+ ok(IsRectEmpty(&rc_minmax), "ptMaxTrackSize is not empty\n");
+ GetWindowRect(parent, &rc);
+ ok(!IsRectEmpty(&rc), "parent window rect is empty\n");
GetClientRect(parent, &rc);
- ok(rc_minmax.left >= rc.left && rc_minmax.top >= rc.top &&
- rc_minmax.right <= rc.right && rc_minmax.bottom <= rc.bottom,
- "rc_minmax (%d,%d-%d,%d) is not within of parent client rect (%d,%d-%d,%d)\n",
- rc_minmax.left, rc_minmax.top, rc_minmax.right, rc_minmax.bottom,
- rc.left, rc.top, rc.right, rc.bottom);
+ ok(!IsRectEmpty(&rc), "parent client rect is empty\n");
+
InflateRect(&rc, 200, 200);
trace("creating child with rect (%d,%d-%d,%d)\n", rc.left, rc.top, rc.right, rc.bottom);
SetLastError(0xdeadbeef);
- hwnd = CreateWindowEx(0, "static", NULL, WS_CHILD | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME,
+ hwnd = CreateWindowEx(0, "MinMax_WndClass", NULL, WS_CHILD | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME,
rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top,
parent, (HMENU)1, 0, NULL);
ok(hwnd != 0, "CreateWindowEx error %d\n", GetLastError());
@@ -3948,10 +3989,12 @@ static void test_CreateWindow(void)
expect_style(hwnd, WS_CHILD | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME);
expect_ex_style(hwnd, WS_EX_WINDOWEDGE);
- OffsetRect(&rc, -rc.left, -rc.top);
+ memset(&minmax, 0, sizeof(minmax));
+ SendMessage(hwnd, WM_GETMINMAXINFO, 0, (LPARAM)&minmax);
+ SetRect(&rc_minmax, 0, 0, minmax.ptMaxTrackSize.x, minmax.ptMaxTrackSize.y);
- GetWindowRect(hwnd, &rc_minmax);
- OffsetRect(&rc_minmax, -rc_minmax.left, -rc_minmax.top);
+ GetWindowRect(hwnd, &rc);
+ OffsetRect(&rc, -rc.left, -rc.top);
ok(EqualRect(&rc, &rc_minmax), "rects don't match: (%d,%d-%d,%d) and (%d,%d-%d,%d)\n",
rc.left, rc.top, rc.right, rc.bottom,
rc_minmax.left, rc_minmax.top, rc_minmax.right, rc_minmax.bottom);
@@ -3959,6 +4002,8 @@ static void test_CreateWindow(void)
DestroyWindow(hwnd);
DestroyWindow(parent);
+ UnregisterClass("MinMax_WndClass", GetModuleHandle(0));
+
#undef expect_menu
#undef expect_style
#undef expect_ex_style
diff --git a/dlls/winex11.drv/window.c b/dlls/winex11.drv/window.c
index a31227f..a74c095 100644
--- a/dlls/winex11.drv/window.c
+++ b/dlls/winex11.drv/window.c
@@ -1078,10 +1078,15 @@ BOOL X11DRV_CreateWindow( HWND hwnd, CREATESTRUCTA *cs, BOOL unicode )
if ((cs->style & WS_THICKFRAME) || !(cs->style & (WS_POPUP | WS_CHILD)))
{
POINT maxSize, maxPos, minTrack, maxTrack;
- /* Although Windows sends WM_GETMINMAXINFO at the window creation time,
- * it doesn't use returned values to set window size.
- */
+
WINPOS_GetMinMaxInfo( hwnd, &maxSize, &maxPos, &minTrack, &maxTrack);
+ if (maxTrack.x < cs->cx) cs->cx = maxTrack.x;
+ if (maxTrack.y < cs->cy) cs->cy = maxTrack.y;
+ if (cs->cx < 0) cs->cx = 0;
+ if (cs->cy < 0) cs->cy = 0;
+
+ SetRect( &rect, cs->x, cs->y, cs->x + cs->cx, cs->y + cs->cy );
+ if (!X11DRV_SetWindowPos( hwnd, 0, &rect, &rect, SWP_NOZORDER, NULL )) return FALSE;
}
/* send WM_NCCREATE */
More information about the wine-cvs
mailing list