There is the good component to maximize a child window in a client area (the SHIFT key must be held) - NLDExtraMDIProps.
Or this code can be used:
procedure WMSIZE(var Msg: TMessage); message WM_SIZE;
procedure TForm2.WMSIZE(var Msg: TMessage);
begin
inherited;
if Msg.WParam = SIZE_MAXIMIZED then
begin
ShowWindow(Handle, SW_RESTORE);
Left := 0;
Top := 0;
Width := Form1.ClientWidth - 4; // The BORDER
Height := Form1.ClientHeight - 4;
end;
end;
But maximizing isn't real maximizing. The child window is only aligned to the client area. It must automatically resize and fit the client area when the parent window is resized, the maximize/restore system button must change etc.
I try to accomplish effects that are described below.
As you see on the pictures the child windows are maximized, and
they don't take the entire parent window (only the client area).
It's impossible to move them over the caption/title bar because they are maximized.
They have the restore button, not the maximize button any more.
They are aligned to the client area (resizing of the parent window causes resizing of the child one withing the client area).
The code in my question and the component don't do like the child windows on the pictures.
Can we make a window really maximized (not just aligned)?
Not maximized (not good; the component and the code from my question maximize like on these pictures):
Maximized (what I need):
I do not understand your problem. Maximizing an MDI child window is done:
ShowWindow(ActiveMDIChild.Handle, SW_MAXIMIZE)
,Both these actions result in:
Align=alClient
.To restrict the available space for the child windows within the main form, make sure to align windowed controls to edges of the form.
Setting the Align
or Anchors
properties for MDI child windows has no effect: they are not part of the default VCL aligning implementation anymore; Windows has taken over that job.
If you want to intervene on the resizing of an MDI child, then handling WM_SIZE
is the wrong approach, because that message is send áfter the resize. Instead, handle WM_SYSCOMMAND
as I explained here.
As for my component that you refer to: