How can I maximize a child window that fits only the client area but not an entire parent window? I don't want that the child window disappears under a main menu or other controls of the parent window.
I have this code
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 it's not good enough. The window is actually not maximized. If to change SW_RESTORE
to SW_MAXIMIZE
then the child window looks buggy.