Home End User
New Blog Posts: Merging Reports - Part 1 and Part 2

Problem minimizing print preview window

edited September 2004 in End User
I have an end-user reporting app set up using RB7.03 and Delphi 5. If I
print a report to the screen, then minimize the print preview window and
then click on my application in the taskbar I get the Report Explorer
window. At this point I am stuck because the print preview window is the
active window but it's not visible. Nothing I do will bring it back. I'm
forced to terminate my application to get out of this. Is this a RB bug or
is it something I'm doing? I can consistently make it do this.

Michael Gregg

Comments

  • edited September 2004

    This is an issue related to Delphi applications and many Windows apps in
    general. They do not always activate themselves properly when switching
    between apps using the task bar. I believe Borland is trying to improving
    the VCL to handle this better in future versions.

    When Alt + Tab is used to switch between apps, this is never an problem -
    the app is always restored properly. As a test try using Alt + Tab and
    observe what happens.

    You can implement an Application.OnActivate event-handler to work improve
    the default behavior.

    1. Assign the event-handler sometime after the application starts up.

    Application.OnActivate := ehApplicationActivate;


    2. Add the following code to the event-handler method

    procedure TmyEndUserSolution.ehApplicationActivate(Sender: TObject);
    begin

    if Screen.ActiveForm.WindowState = wsMinimized then
    Screen.ActiveForm.WindowState := wsMaximized;

    Screen.ActiveForm.BringToFront;

    end;




    --
    Nard Moseley
    Digital Metaphors Corporation
    www.digital-metaphors.com



    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited September 2004
    Michael Gregg wrote:


    This may help you:


    First, one unit subclasses the report explorer form (remember to
    register/unregister it).

    type
    TgtcRBReportExplorerForm = class(TppReportExplorerForm)
    ...

    constructor TgtcRBReportExplorerForm.Create(aOwner: TComponent);
    begin
    inherited;

    ...

    // Minimising the designer or explorer is confusing when they are not
    in the taskbar.
    BorderIcons := BorderIcons - [biMinimize];
    end;

    procedure TgtcRBReportExplorerForm.CreateParams(var Params:
    TCreateParams);
    begin
    inherited CreateParams(Params);

    // We don't want a taskbar icon for the explorer.
    Params.ExStyle := Params.ExStyle and not WS_EX_APPWINDOW;
    end;


    Next, I had to do the same for the designer, in another unit:
    (rpt is the data module containing the TppReport, and the
    RemoveDesignerTaskIcon is called from an OnIdle event.)

    rocedure TdmReport.RemoveDesignerTaskIcon(Sender: TObject);
    var
    ppd : TppDesigner;
    dwExStyle : DWORD;
    begin
    ppd := rpt.ppReportExplorer.Designer;
    if not Assigned(ppd) then
    Exit;

    // We don't want the designer as an icon in the taskbar. Form
    property creates the form.
    dwExStyle := GetWindowLong(ppd.Form.Handle, GWL_EXSTYLE);
    if dwExStyle <> 0 then
    SetWindowLong(ppd.Form.Handle, GWL_EXSTYLE, dwExStyle and not
    WS_EX_APPWINDOW);
    end;


    I think this should be just about it. Got rid of the problem, at least.

    -tor
  • edited September 2004
    First, to answer Nard - yes using Alt-Tab does restore the windows properly.
    Secondly, the response offered below refers to another question I had.
    Namely, why do the Report Explorer and Report Designer show up as separate
    entries on the taskbar? It seems to me that this was not the behavior prior
    to version 7. Is there a way to override this without the recoding as shown
    below?

    Michael Gregg

  • edited September 2004

    RB 6 and RB 7 behave differently in managing the windows and task bar. RB 7
    contains some modifications that were meant to improve things. However,
    there is still room for more improvement. We will research this and try to
    improve things for the next release.


    --
    Nard Moseley
    Digital Metaphors Corporation
    www.digital-metaphors.com



    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
This discussion has been closed.