Solved TD-9047: SP2: window created by SalReportView() always in background

Report bugs and possible workarounds.
maju

TD-9047: SP2: window created by SalReportView() always in background

Post by maju » 11 Jan 2011, 12:18

... an other problem appears while migrating my TD3.0 applications to TD6.0 SP1:

I have a MDI application which opens a maximized window.
If a report window is created in this application by using SalReportView( hWndMsg, hWndNULL, xxxx ) the created report window goes always in the background after creation. If the MDI application windows is not maximized, the Report Window keeps (correctly) in foreground.

To keep the Report Window in foreground I tried this:
Set hWndReport = SalReportView( hWndMsg, hWndNULL, xxxx )
Call SalBringWindowToTop( hWndReport )
But it's also not working. As long as application window is maximized the Report Window goes always behind the application window after creation.

Martin
Last edited by maju on 07 Apr 2011, 13:19, edited 3 times in total.

Jeff Luther

Re: TD-9047: SP2: window created by SalReportView() always in background

Post by Jeff Luther » 11 Jan 2011, 20:58

Let me look at this if you can provide a small test case. It's surprising to me that a max'd form, for example, somehow prevents SalBringWindowToTop). Only thing I can think of is that the SalReport call isn't returning until too late.

Try this -- add that call to the first report msg. That might work:

Code: Select all

On SAM_ReportStart
        Call SalBringWindowToTop( SalNumberToWindowHandle( wParam ) )
        ... then whatever other code you might have here.
        Return TRUE
Note the hWnd value in the call -- that's the converted wParam for the msg.

maju

Re: TD-9047: SP2: window created by SalReportView() always in background

Post by maju » 16 Jan 2011, 19:02

A simple demo application was working perfect.
So I try to extract a demo application from my 1-million-lines application :D

While extracting I found the reason:
It's not a bug, the reason based on different behaviour of functions like SalSetFocus( ).

In TD3.0 it was possible to use SalSetFocus( ) in background windows without changing the current foreground window.
In TD6.0 it looks like SalSetFocus( ) includes a SalBringWindowToTop( ).
Many of my printing functions set the focus to a data field in the main window after calling the View/Print function.
So the main window is poping in the foreground and you do not see the view window anymore.

Martin

maju

Re: TD-9047: SP2: window created by SalReportView() always in background

Post by maju » 09 Mar 2011, 08:40

Now I found the same behaviour but without an easy resolution/workaround.
It looks like calling a SalModalDialog() before SalReportView() also puts Report Window in the background.
Please check the attached sample.
Using "Ansicht" Button will show a Dialog Box and creates a Report Window.
After creation the Report Window will move to background.

After disabling the line "Call SalModalDialog( dbViewPrintRechnung, hWndForm, nTYPE )" the function will work normally and the Report Window will stay in front.
I think it's a bug because it's not logical that SalReportView() behaviour changes when SalModalDialog() is called before.

Maybe a "late bound" bug because a simple "Call SalMessageBox( 'test', 'test', MB_Ok )" directly after "SalReportView()" will keep the Report Window also in the front.

Martin

BTW: Tested on Win7 with build 23971
You do not have the required permissions to view the files attached to this post.

Jeff Luther

Re: TD-9047: SP2: window created by SalReportView() always in background

Post by Jeff Luther » 09 Mar 2011, 18:30

a simple "Call SalMessageBox( 'test', 'test', MB_Ok )" directly after "SalReportView()" will keep the Report Window also in the front.
I believe this is a z-order issue -- the management of the order of open 'windows'. TD isn't managing that. (You can see that z-order using Alt+Tab keys. That icon display of open windows changes depending on which window you now click on or has the focus.)

This is a good way to guarantee that the preview window is on top:

Code: Select all

Variables
    Window Handle: hWndReport 
Set hWndReport = SalReportView( ... )
Call SalBringWindowToTop( hWndReport )

maju

Re: TD-9047: SP2: window created by SalReportView() always in background

Post by maju » 10 Mar 2011, 09:20

Jeff Luther wrote:Set hWndReport = SalReportView( ... )
Call SalBringWindowToTop( hWndReport )
Calling SalBringWindowToTop() does not change anything for me (Build 23971).
The Report Window still pops in the background.

Martin

Jeff Luther

Re: TD-9047: SP2: window created by SalReportView() always in background

Post by Jeff Luther » 11 Mar 2011, 00:40

Calling SalBringWindowToTop() does not change anything for me
Works for me using your test case ViewPrint Background.zip:

Code: Select all

Function: ViewPrint
   Actions
      Call SalWaitCursor( TRUE )
      Set hWndReport = SalReportView(
                                                 hWndMsg, hWndNULL,
                                                 sPATH, sBIND, sINTO,
                                                 nErr )
-->   Call SalBringWindowToTop( hWndReport )
      ! Call SalMessageBox( 'test', 'test', MB_Ok ) 
      Return TRUE
If you still have a problem then I will need to see your modified test that is failing for you.
You do not have the required permissions to view the files attached to this post.

Jeff Luther

Re: TD-9047: SP2: window created by SalReportView() always in background

Post by Jeff Luther » 11 Mar 2011, 01:16

Developer reminded me of a workaround for you now: Change the RTC Margins attributes to be > 0.0, like this:
TD-9047-RTF_text_SetMargins.png
I'll attach modified test case.
You do not have the required permissions to view the files attached to this post.

maju

Re: TD-9047: SP2: window created by SalReportView() always in background

Post by maju » 12 Mar 2011, 10:56

Please check the attached sample which looks like yours.
For me, it's not working. The Report Window still goes to background.

The only way to prevent this behaviour is:
1. not calling a dialog box before SalReportView( )-> disable "Call SalModalDialog( dbViewPrintRechnung, hWndForm, nTYPE )" or
2. Doing some wait after SalReportView( ) call -> e.g. by "Call SalMessageBox( 'test', 'test', MB_Ok )"
Jeff Luther wrote:
Calling SalBringWindowToTop() does not change anything for me
Works for me using your test case ViewPrint Background.zip:

Code: Select all

Function: ViewPrint
   Actions
      Call SalWaitCursor( TRUE )
      Set hWndReport = SalReportView(
                                                 hWndMsg, hWndNULL,
                                                 sPATH, sBIND, sINTO,
                                                 nErr )
-->   Call SalBringWindowToTop( hWndReport )
      ! Call SalMessageBox( 'test', 'test', MB_Ok ) 
      Return TRUE
If you still have a problem then I will need to see your modified test that is failing for you.
You do not have the required permissions to view the files attached to this post.

maju

Re: TD-9047: SP2: window created by SalReportView() always in background

Post by maju » 07 Apr 2011, 13:20

This behaviour is still the same in SP2.
There is also no defect logged for this issue ...

Return to “Bug Reports”

Who is online

Users browsing this forum: [Ccbot] and 0 guests