Search code examples
formsdelphitaskbarmaximizemaximize-window

How do I maximize a form from an other form?


My program has two forms. At a certain point while running, both forms will be shown - one atop of the other. I want to be able to maximize the bottom form while focused on the front one.

I played around a bit with TForm.BorderStyle := bsNone and ShowWindowAsync(Handle, SW_MAXIMIZE) as it seems to be the only thing that maximizes to fullscreen.

This, however, maximizes the current and wrong form.

Is there any way to completely maximize (to fullscreen) a form from inside another one?


Solution

  • To answer my own question:

    With the help of a comment made by Tom Brunberg, I have found that although ShowWindowAsync(TheOtherForm.Handle, SW_MAXIMIZE) does not make the form completely fullscreen, it works on removing the "Async".

    Thus,

    TForm.BorderStyle := bsNone;
    ShowWindow(TheOtherForm.Handle, SW_MAXIMIZE);
    

    is a working solution in this case.