o check for both CW_USEDEFAULT and CW_USEDEFAULT16.
o if x is CW_USEDEFAULT (or CW_USEDEFAULT16) and y is *not*
CW_USEDEFAULT (or CW_USEDEFAULT16) then use y as a second
parameter to ShowWindow(). Some apps (CALC.EXE for Win98
is one of them) use this undocumented feature to create
hidden window with WS_VISIBLE style set.
diff --git a/windows/win.c b/windows/win.c
index 4922297..b50eb8e 100644
--- a/windows/win.c
+++ b/windows/win.c
@@ -662,6 +662,7 @@
static HWND WIN_CreateWindowEx( CREATESTRUCTA *cs, ATOM classAtom,
BOOL win32, BOOL unicode )
{
+ INT sw = SW_SHOW;
CLASS *classPtr;
WND *wndPtr;
HWND retvalue;
@@ -714,9 +715,29 @@
/* Fix the coordinates */
- if (cs->x == CW_USEDEFAULT)
+ if (cs->x == CW_USEDEFAULT || cs->x == CW_USEDEFAULT16)
{
PDB *pdb = PROCESS_Current();
+
+ /* Never believe Microsoft's documentation... CreateWindowEx doc says
+ * that if an overlapped window is created with WS_VISIBLE style bit
+ * set and the x parameter is set to CW_USEDEFAULT, the system ignores
+ * the y parameter. However, disassembling NT implementation (WIN32K.SYS)
+ * reveals that
+ *
+ * 1) not only if checks for CW_USEDEFAULT but also for CW_USEDEFAULT16
+ * 2) it does not ignore the y parameter as the docs claim; instead, it
+ * uses it as second parameter to ShowWindow() unless y is either
+ * CW_USEDEFAULT or CW_USEDEFAULT16.
+ *
+ * The fact that we didn't do 2) caused bogus windows pop up when wine
+ * was running apps that were using this obscure feature. Example -
+ * calc.exe that comes with Win98 (only Win98, it's different from
+ * the one that comes with Win95 and NT)
+ */
+ if (cs->y != CW_USEDEFAULT && cs->y != CW_USEDEFAULT16) sw = cs->y;
+
+ /* We have saved cs->y, now we can trash it */
if ( !(cs->style & (WS_CHILD | WS_POPUP))
&& (pdb->env_db->startup_info->dwFlags & STARTF_USEPOSITION) )
{
@@ -729,7 +750,7 @@
cs->y = 0;
}
}
- if (cs->cx == CW_USEDEFAULT)
+ if (cs->cx == CW_USEDEFAULT || cs->cx == CW_USEDEFAULT16)
{
PDB *pdb = PROCESS_Current();
if ( !(cs->style & (WS_CHILD | WS_POPUP))
@@ -777,8 +798,9 @@
wndPtr->owner = WIN_GetTopParentPtr(tmpWnd);
WIN_ReleaseWndPtr(wndPtr->owner);
WIN_ReleaseWndPtr(tmpWnd);
+ }
}
- }
+
wndPtr->pDriver = wndPtr->parent->pDriver;
wndPtr->pDriver->pInitialize(wndPtr);
@@ -982,7 +1004,7 @@
}
}
- if (cs->style & WS_VISIBLE) ShowWindow( hwnd, SW_SHOW );
+ if (cs->style & WS_VISIBLE) ShowWindow( hwnd, sw );
/* Call WH_SHELL hook */