Software Archive
Read-only legacy content
17061 Discussions

How to create a splash screen in QuickWin app

grtoro
Beginner
629 Views
Here is my question of the day:

I want to create a splash screen that disappears after (say) 20 seconds (without any user intervention) when my Quickwin app starts. What's the easiest way of doing this?

I created a dialog and used dlgmodeless to bring it up, but I need a loop like the one below:


do while( GetMessage (mesg, NULL, 0, 0) )
if ( DlgIsDlgMessage(mesg, dlg) .EQV. .FALSE. ) then
if ( TranslateAccelerator (mesg%hwnd, haccel, mesg) == 0) then
lret = TranslateMessage( mesg )
ret = DispatchMessage( mesg )
end if
end if
end do


If I don't add this loop, the contents of my dialog will not display. How do I get out of this loop after a given time? There must be an easy way of doing this but it escapes me.

Thanks,

Gabriel
0 Kudos
4 Replies
grtoro
Beginner
629 Views
Sorry about the code snippet in my original message. What I meant was:

 
 do while( GetMessage (mesg, NULL, 0, 0) ) 
    if ( DlgIsDlgMessage(mesg, dlg) .EQV. .FALSE. ) then  
       if ( TranslateAccelerator (mesg%hwnd, haccel, mesg) == 0) then 
         lret = TranslateMessage( mesg )  
         ret = DispatchMessage( mesg )  
       end if  
     end if  
end do  
0 Kudos
Jugoslav_Dujic
Valued Contributor II
629 Views

Many users, including myself, deem splash screens an annoynance unless your application really does initialize for a long time. It's considered a nice practice that when your application can be ready, it should be ready.


Yes, without the message loop your modeless dialog would be stuck except if it's created from QuickWin primary thread. (IIRC I've described few times QW threaded structure here). However, by adding message loop to the program you've added GUI capability to secondary thread.

The simplest fix would be to use a timer. See here for a sample of using timer in a dialog. In your case, timer would have a smaller frequency and the timer procedure should close the dialog the first time it's entered. For that to work, either Dlg has to be global between PROGRAM and TimerProc, or you could use an application-defined message to exit message loop:
 
INTEGER, PARAMETER:: WM_EXITDLG = WM_APP + 1 
... 
 
 do while( GetMessage (mesg, NULL, 0, 0) )   
     IF (mesg%message .EQ. WM_EXITDLG) EXIT 
    ... 
!In TimerProc: 
j = PostMessage(hWnd, WM_EXITDLG, 0, 0)     

HTH
Jugoslav
0 Kudos
Jugoslav_Dujic
Valued Contributor II
629 Views
Fix: the real link is this
0 Kudos
grtoro
Beginner
629 Views
Thanks, Jugoslav. It worked! Also, the splash screen disappears relatively soon, as per your preaching.

Gabriel
0 Kudos
Reply