Can't Minimize Main Form

edited 9:21AM in FastReport 4.0
From my main form, I call a frxReport as

Rpt := TfrxReport.Create(Nil);

Rpt.PreviewOptions.Maximized := False;
Rpt.PreviewOptions.Modal := False;
Rpt.LoadFromFile(RptName);
Rpt.PrepareReport();
Rpt.ShowPreparedReport();

The above calls are in a Delphi data module which is called via a function in the main form.

The report is clearly non-modal since I can run multiple windows with a different report in each. However, the main form will NOT minimize if even 1 previewed report is showing. Am I missing something?

Comments

  • edited 9:21AM
    While I am working with FastReports Support on why I can't minimize a main form if a non-modal report form is open, I found a "solution" that has some advantages and disadvantages:

    In the Private section of your main form add:

    Private
    procedure WMSyscommand(Var msg: TWmSysCommand);
    message WM_SYSCOMMAND;

    Then add the following code:

    procedure TForm1.WMSyscommand(Var msg: TWmSysCommand);
    Begin
    Case (msg.cmdtype and $FFF0) of
    SC_MINIMIZE: Begin
    ShowWindow( handle, SW_MINIMIZE );
    msg.result := 0;
    End;
    SC_RESTORE: Begin
    ShowWindow( handle, SW_RESTORE );
    msg.result := 0;
    End;
    Else
    inherited;
    End;
    end;

    Advantages: The main form will minimize INDEPENDENT of the Preview Report windows. So you can display the report and have the main form minimized.

    Disadvantage: The main form is minimized to the DESKTOP, not the Taskbar and the TaskBar can not be used to bring the form back up since the form is on the desktop not the Taskbar.

    If you want to have the main form minimize to the Taskbar and be restored from the TaskBar, the following code needs to be added:

    Private
    procedure CreateParams( Var params: TCreateParams ); override;


    procedure TForm1.CreateParams( Var params: TCreateParams );
    begin
    inherited CreateParams( params );
    params.ExStyle := params.ExStyle or WS_EX_APPWINDOW;
    end;


    Advantage: Main form will minimize to the Taskbar and not the Desktop.
    Disadvantage: At least in Windows 7, you will have 2 Taskbar icons for your main form instead of one.

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.