Home General

after print dialog, application losing focus

edited April 2010 in General
D2006, RB 11.08

I recently upgraded to 11.08 and removed TExtraDevices. After the change, I
have noticed that when ShowPrintDialog is true, after I hit OK on the
dialog, the report prints, but my application loses focus. Whichever window
had focus before my application did pops on top. My reports are all in a
dll.

Thanks,
George

Comments

  • edited April 2010
    For an example of using RB in a .dll check out RBuilder\Demos\Dll. (For RB
    11 the default install location for the demos is the Public Documents or
    Shared Folders directory of Win7/Vista or XP)

    In the example we pass the Application.Handle to the .dll so that it can be
    used by the Delphi VCL. And the example dll is written such that if the
    Application.Handle is /not/ passed by the caller, then
    Application.CreateHandle is called.

    Here is that copy of that code...

    {------------------------------------------------------------------------}
    {ShowForm - exported function for DLL example


    1. When calling a DLL from Delphi, pass the Application.Handle

    example:
    ShowForm(Application.Handle);

    2. When calling from a non VCL environment, pass 0 and a new application
    handle will be created

    example:
    Showform(0);

    }

    function ShowForm(aAppHandle: THandle): Bool;
    var
    Form1: TfrmDLL;
    begin

    // use specified app handle or create a new one, as needed}
    if (aAppHandle <> 0) then
    Application.Handle := aAppHandle
    else
    Application.CreateHandle;

    {create the form}
    Form1 := TfrmDLL.Create(nil);

    {must be modal for DLL calls (never modeless) }
    try
    Result := (Form1.ShowModal = mrOK);
    finally
    Form1.Free;
    end;

    end;



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



    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited April 2010
    My report dll is 10 years old. I have never passed it in an application
    handle, and I have never had this problem before.

    Did something change with a version 11 or another recent version to require
    this?

    Thanks,
    George

  • edited May 2010
    I passed Application.Handle to the dll, and set it in the dll as you
    indicated. That did not solve the problem.

    Thanks,
    George

  • edited May 2010

    Can you modify our Demo to duplicate the issue you are experiencing? Or
    perhaps create a simple example project that we can build and run here? If
    so please use standard Delphi components and RB, send in zip format to
    support@. This is not a known issue.


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



    Best regards,

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