Can't Minimize Main Form
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?
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
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.