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?
TDialog problem
- Roger Seiler
- Posts: 223
- Joined: Thu Dec 01, 2005 3:34 pm
- Location: Nyack, New York, USA
- Contact:
- Roger Seiler
- Posts: 223
- Joined: Thu Dec 01, 2005 3:34 pm
- Location: Nyack, New York, USA
- Contact:
- Roger Seiler
- Posts: 223
- Joined: Thu Dec 01, 2005 3:34 pm
- Location: Nyack, New York, USA
- Contact:
Re: TDialog problem
Here are screenshots showing the problem. First the "ghost" image, then the real image.


- Rick Lipkin
- Posts: 2677
- Joined: Fri Oct 07, 2005 1:50 pm
- Location: Columbia, South Carolina USA
- Been thanked: 2 times
Re: TDialog problem
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
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
- Roger Seiler
- Posts: 223
- Joined: Thu Dec 01, 2005 3:34 pm
- Location: Nyack, New York, USA
- Contact:
Re: TDialog problem
Thanks, Rick, for your reply.
Here is an excerpt from my code:
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
Here is an excerpt from my code:
Code: Select all | Expand
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
- Roger Seiler
- Posts: 223
- Joined: Thu Dec 01, 2005 3:34 pm
- Location: Nyack, New York, USA
- Contact:
Re: TDialog problem
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.
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.
- Roger Seiler
- Posts: 223
- Joined: Thu Dec 01, 2005 3:34 pm
- Location: Nyack, New York, USA
- Contact:
Re: TDialog problem
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)."
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)."
- Antonio Linares
- Site Admin
- Posts: 42655
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Has thanked: 67 times
- Been thanked: 96 times
- Contact:
Re: TDialog problem
Roger,
Yes, thats the right solution: that the dialog has not the visible style.
thanks for sharing it
Yes, thats the right solution: that the dialog has not the visible style.
thanks for sharing it
