|
From: Wobien <wo...@pl...> - 2004-01-06 22:14:25
|
One of the examples that come with Dev-C++ is MDIApp, a MDI file edi=
tor.
I used it as an example to make my own MDI application.
If you (as the user of the application) maximize the active window, a=
nd then
open another file (or a new file), this new file is not maximized. Th=
is is
not what you would expect.
I put some debugging code in the MDIchild Windowproc to see what happ=
ens.
Before any message for the new window arrives in the Windowproc the o=
ld
active window gets the variable size.
I think this is strange. I would have expected that the DefMDIChildPr=
oc
(windows API, called by the program after each message to the MDI chi=
ldren)
would do better.
I tried to fix the problem. The only thing I can find that works is t=
o
change the case CM_FILE_NEW: in the parent windowproc to:
case CM_FILE_NEW:
{
MDICREATESTRUCT mcs;
HWND hChild;
mcs.szTitle =3D "[Untitled]";
mcs.szClass =3D g_szChild;
mcs.hOwner =3D g_hInst;
mcs.x =3D mcs.cx =3D CW_USEDEFAULT;
mcs.y =3D mcs.cy =3D CW_USEDEFAULT;
mcs.style =3D MDIS_ALLCHILDSTYLES;
BOOL Maximized;
// I added this
HWND ActiveChild=3D(HWND)
SendMessage(g_hMDIClient,WM_MDIGETACTIVE,0,(LPAR=
AM)
&Maximized); // Until here
hChild =3D (HWND)SendMessage(g_hMDIClient, WM_MDICREAT=
E,
0, (LONG)&mcs);
if(!hChild)
{
MessageBox(hwnd, "MDI Child creation failed.", "Oh =
Oh...",
MB_ICONEXCLAMATION | MB_OK);
}
else
// I added this
{
if(ActiveChild and Maximized)
SendMessage(g_hMDIClient,WM_MDIMAXIMIZE,(WPARAM)hChild,0);
}
// Until here
}
break;
Of coarse you have to add the same code to case CM_FILE_OPEN:
This works, but when you open the new window you see it become small =
first
and then maximize again.
My questions are:
Why don=B4t the windows API=B4s automaticly do the right thing?
Is this a bug?
Is there a better fix?
Wobien
|