- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
How can I close a modal dialog box displaying an image, after a given time is elapsed (using a sleep or slipqq command) without
pressing any key as esc ?
It seems that an event of some sort must be necessarily produced and then processed by a callback containing a dlgexit command. Is there any possibility of mimic pressing ok or cancel button closing automatically the dialog box?
pressing any key as esc ?
It seems that an event of some sort must be necessarily produced and then processed by a callback containing a dlgexit command. Is there any possibility of mimic pressing ok or cancel button closing automatically the dialog box?
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Splash screen, ha :-). You cannot quite do it with sleep(qq) since it blocks the calling thread, but you may try creating a Windows timer object on dialog start. There's also DlgExit function. I mean something like:
In the sample above, MyDlg should be defined globally somehow so that TimerProc could close it appropriately. I'm not sure whether the TimerProc gets called first time at 0 and second time at 2s or only once on 2s -- if the former, you'll have to protect against executing it at 0s.
Sleep(qq) might do the trick also, but
a) it shouldn't be called before DlgModal, but in a dialog initialization callback (if you're not aware about it, please see nearby messages, it's
frequently used trick). After that, DlgExit should be called.
b) even then, your dialog won't be repainted (i.e. if you, say, switch to another app and then back, you'll get impression that your app is dead).
HTH
Jugoslav
USE DFWIN ... INTERFACE SUBROUTINE TimerProc(hWnd, Msg, id, iTime) !DEC$ATTRIBUTES STDCALL:: TimerProc INTEGER hWnd, Msg, iEvent, iTime END SUBROUTINE TimerProc END INTERFACE ... !Create a timer object which will call TimerProc each 2000 ms IDTimer = SetTimer(NULL, 0, 2000, LOC(TimerProc)) ... iRet=DlgModal(MyDlg) ... SUBROUTINE TimerProc(hWnd, Msg, id, iTime) !This one gets called automatically each 2s !DEC$ATTRIBUTES STDCALL:: TimerProc USE DFWIN USE DFLOGM INTEGER hWnd, Msg, id, iTime !Destroy the timer iSt = KillTimer(hWnd, id) !Close the dialog CALL DlgExit(MyDlg) END SUBROUTINE TimerProc
In the sample above, MyDlg should be defined globally somehow so that TimerProc could close it appropriately. I'm not sure whether the TimerProc gets called first time at 0 and second time at 2s or only once on 2s -- if the former, you'll have to protect against executing it at 0s.
Sleep(qq) might do the trick also, but
a) it shouldn't be called before DlgModal, but in a dialog initialization callback (if you're not aware about it, please see nearby messages, it's
frequently used trick). After that, DlgExit should be called.
b) even then, your dialog won't be repainted (i.e. if you, say, switch to another app and then back, you'll get impression that your app is dead).
HTH
Jugoslav

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page