TDialog problem

TDialog problem

Postby Roger Seiler » Sat Oct 19, 2013 3:29 pm

I've noticed an aesthetically annoying problem since upgrading to the 8/16 version of FWH. The problem is that a "ghost" image of a dialog is briefly displayed - for maybe half a second - without the effect of RESIZE16 and without containing any data, and then the correct dialog is displayed with the effect of RESIZE16 and also containing the data.

Looking at TDialog:Activate() I can see how this happens but don't see how to fix it. In TDialog:Activate() we have...

::hWnd = CreateDlg( ::hResources, ::cResName, hActiveWnd )

This apparently displays the "ghost" image of the dialog. Then the following line almost immediately hides it...

ShowWindow( ::hWnd, SW_HIDE )

And then a few lines later we have...

::Show()
::Refresh() // needed for resource dialogs.

It seems that this ::Show() is where the dialog is correctly displayed with RESIZE16 in effect and with the data in place.

Is there a way to eliminate the annoying momentary display of the "ghost" image of the dialog just before the real dialog is shown?
User avatar
Roger Seiler
 
Posts: 223
Joined: Thu Dec 01, 2005 3:34 pm
Location: Nyack, New York, USA

Re: TDialog problem

Postby Roger Seiler » Sat Oct 19, 2013 3:31 pm

I meant 8/13 version not 8/16 version of FWH. No time machine here!
User avatar
Roger Seiler
 
Posts: 223
Joined: Thu Dec 01, 2005 3:34 pm
Location: Nyack, New York, USA

Re: TDialog problem

Postby Roger Seiler » Sat Oct 19, 2013 4:46 pm

Here are screenshots showing the problem. First the "ghost" image, then the real image.

Image

Image
User avatar
Roger Seiler
 
Posts: 223
Joined: Thu Dec 01, 2005 3:34 pm
Location: Nyack, New York, USA

Re: TDialog problem

Postby Rick Lipkin » Sun Oct 20, 2013 3:58 pm

Roger

Take a look at your ON INIT for the dialog box and if you are using MdiCHild .. look at the ON INIT clause on the Activate Window there as well.

A similar thing happened to me .. I failed to chase down some On Init code and found my errant process.

Rick Lipkin
User avatar
Rick Lipkin
 
Posts: 2638
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: TDialog problem

Postby Roger Seiler » Sun Oct 20, 2013 10:08 pm

Thanks, Rick, for your reply.

Here is an excerpt from my code:
Code: Select all  Expand view


   LOCAL nT := 101,nL := 130, cNameTxt := "Browse Registered Voters Database"

   DEFAULT nReadBrw := 2

   DEFINE DIALOG oVoteDlg RESOURCE "S_BASE2" OF oWnd  // a "popup" dialog
                                                      // not part of an MDI window

   oVoteDlg:cCaption := cNameTxt

   // Code defining TCbrowse, splitter and a folder with 2 tabs, and
   // ordinary code for various buttons, checkboxes, radios, gets and says
   // is located here, including oBtn14, oBtn15 and oSay23 referenced below.

   SysWait(.2)

   ACTIVATE DIALOG oVoteDlg CENTERED ;
      NOWAIT ;
      VALID !GETKEYSTATE(VK_ESCAPE) ;
      ON INIT ( oVoteDlg:Move(nT,nL),;
             IF(nReadBrw = 1,(oBtn14:Hide(),oBtn15:Hide(),oSay23:Hide()),),;
             oVoteDlg:SetFocus();
            ) RESIZE16
   
 


As you can see, MDI is not involved here. Is there anything in the ON INIT here that
jumps out at you as a problem?

On my Windows 7 stand-alone machines, which are fairly fast, the brief "ghost" dialog is barely noticable,
but on slower XP machines or on network workstations it is quite noticeable.

I did do a test with DIALOG.PRG whereby in the :Activate() I put a MsgInfo() after the CreateDlg() and another after ShowWindow( ::hWnd, SW_HIDE ). After CreateDlg() the ghost dialog (with no data and without RESIZE16) was shown. Then upon closing the test MsgInfo() that I used to force a wait there, the SW_HIDE did its job, and the ghost disappeared. Upon closing the test MsgInfo() used to cause a wait after SW_HIDE, then the dialog correctly reappeared after ::Show. It was complete with data and properly sized per RESIZE16.

I just checked several more dialogs, and it seems that this problem is only with NOWAIT dialogs. Modal dialogs all display normally without a preceding brief ghost image. Of course, ordinary dialogs with the NOWAIT clause in the ACTIVATE statement are similar to MDI windows in that they are non-modal. So I guess the problem is with anything non-modal.

Do you recall what you had in your ON INIT that caused the problem for you?

- Roger
User avatar
Roger Seiler
 
Posts: 223
Joined: Thu Dec 01, 2005 3:34 pm
Location: Nyack, New York, USA

Re: TDialog problem

Postby Roger Seiler » Sun Oct 20, 2013 11:59 pm

I took another look at Dialog.prg (for the TDialog class of FWH) and found that indeed the behavior I noticed can only happen with non-modal dialogs. Comparing the code with an earlier Dialog.prg I see that the current CreateDlg() for non-modal dialogs is different than the earlier version in that it doesn't have a 4th parameter: self - which is in the earlier version. The earlier version did not show a momentary display of the ghost image of the dialog. I am unable to see what effect the parameter difference (between old and new versions of CreateDlg() ) makes because though I can see the current CreateDlg() C code in Dlogbox.c in FWH\Source\Winapi, it isn't in the old version of Dlogbox.c and I couldn't find it anywhere else in the old C stuff. So I don't know what the new version may have changed from the old. And I don't know C well enough to figure it out just looking at CreateDlg() in the current Dlogbox.c

Somehow, it seems the newer version of CreateDlg() displays a ghost image of a non-modal dialog, hides it, and then shows the real thing an instant later. I wish we didn't have that weird brief display of the ghost image, which seems unnecessary and looks clumsy.

But maybe I'm doing something wrong in my ON INIT. If so, please point it out to me, anyone who can see it.
User avatar
Roger Seiler
 
Posts: 223
Joined: Thu Dec 01, 2005 3:34 pm
Location: Nyack, New York, USA

Re: TDialog problem

Postby Roger Seiler » Mon Oct 21, 2013 3:40 am

I found the solution to this problem: in Resource Workshop, the resource for the non-modal (NOWAIT) dialog box must have the "Dialog Style" option for "Visible" unchecked.

Per Borland's explanation of this option:

"The Visible check box makes a modeless dialog box visible before the return from CreateDialog. This option has no effect on modal dialog boxes (the usual kind of dialog box). By default, this option is not checked (NOT WS_VISIBLE)."
User avatar
Roger Seiler
 
Posts: 223
Joined: Thu Dec 01, 2005 3:34 pm
Location: Nyack, New York, USA

Re: TDialog problem

Postby Antonio Linares » Mon Oct 21, 2013 5:47 am

Roger,

Yes, thats the right solution: that the dialog has not the visible style.

thanks for sharing it :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41439
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 33 guests