WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Dialog Editor version 6.X
plus
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Splash Screen Using Dialog Editor

 Keywords:  Splash Screen Using Dialog Editor CreateWindow

Question:

How do I create a timed splash screen using dialog editor?

Answer:

Here are a couple ways:

Example 1:

;This DefineFunction may be used
#DefineFunction   DoItToIt(MyDialogHandle,MyDialogMessage,MyDialogControlID,param4,param5)
 InitDialog = 0
TimerTick  = 1
  
   Switch MyDialogMessage

          Case InitDialog   ; Init_Dialog  (case number 0 subject to change on implementation)
               DialogProcOptions(MyDialogHandle,TimerTick, 1000)   ; enable 1 second timer events
               Return (-1)
   
          Case TimerTick
               Clock=DialogControlGet(MyDialogHandle, 3, 4)
               Clock=Clock-1
               If Clock==0 Then Return(2) ; exit, buttonpushed==2
               DialogControlSet(MyDialogHandle, 3, 4, Clock)
               Return(-1)
   
   EndSwitch ; MyDialogMessage
   Return(-1) ; Do default processing
#EndFunction


MyDialogFormat=`WWWDLGED,6.1`

MyDialogCaption=`WIL Dialog 1`
MyDialogX=78
MyDialogY=129
MyDialogWidth=121
MyDialogHeight=117
MyDialogNumControls=3
MyDialogFont=`DEFAULT`
MyDialogTextColor=`DEFAULT`
MyDialogBackground=`DEFAULT`
MyDialogProcedure="DoItToIt" ;;;;;;;;;;;;;;;;added line

MyDialog001=`12,82,35,14,PUSHBUTTON,DEFAULT,"OK",1,DEFAULT,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog002=`66,82,35,14,PUSHBUTTON,DEFAULT,"Cancel",0,DEFAULT,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog003=`22,15,71,53,VARYTEXT,clock,"10",DEFAULT,DEFAULT,DEFAULT,"Tahoma|49152|70|34","128|0|0",DEFAULT`

ButtonPushed=Dialog("MyDialog")

Message("ButtonPushed Results",ButtonPushed)

Exit

Example 2:

This does away with the buttons and the timer display..
ScreenX=WinMetrics(0)/WinMetrics(-6)
ScreenY=WinMetrics(1)/WinMetrics(-5)
DlgWidth =ScreenX*0.663
DlgHeight=ScreenY*0.663
DlgX=(ScreenX/2)-(DlgWidth /2)
DlgY=(ScreenY/2)-(DlgHeight/2)

#DefineSubRoutine   DlgCallback (DlgName,DlgEvent,DlgCtrlNo,param4,param5)
InitDialog = 0
TimerTick  = 1
   Switch DlgEvent
      Case InitDialog
         Count=10
         DialogProcOptions(DlgName,TimerTick,1000)
         Return (-1)
      Case TimerTick
         Count=Count-1
         If Count==0 Then Return (1)
         Return(-1)
   EndSwitch 
   Return(-1) 
#EndSubRoutine

frmSplashFormat=`WWWDLGED,6.1`
frmSplashCaption=`Splash Test`
frmSplashX=%DlgX%
frmSplashY=%DlgY%
frmSplashWidth=%DlgWidth%
frmSplashHeight=%DlgHeight%
frmSplashNumControls=001
frmSplashProcedure=`DlgCallback`
frmSplashFont=`DEFAULT`
frmSplashTextColor=`DEFAULT`
frmSplashBackground=`DEFAULT,DEFAULT`
frmSplashConfig=123
frmSplash001=`201,155,034,014,PUSHBUTTON,DEFAULT,"OK",1,1,1,DEFAULT,DEFAULT,DEFAULT`
frmSplashButtonPushed=Dialog("frmSplash",1) 

Example 3: Borderless Splash Screen

This code uses the SetWindowLong function of User32.dll in a UDF to get rid of the caption.
ScreenWidth =WinMetrics(0)/WinMetrics(-6)                  ;Determine screen width in pixels
ScreenHeight=WinMetrics(1)/WinMetrics(-5)                  ;Determine screen height in pixels

DlgWidth =ScreenWidth*0.663                                ;Make splash screen 2/3 width of screen
DlgHeight=ScreenHeight*0.5                                 ;Make splash screen 1/2 height of screen
DlgX=(ScreenWidth-DlgWidth)  /2                            ;Determine X co-ordinate for splash screen to be centered
DlgY=(ScreenHeight-DlgHeight)/2                            ;Determine Y co-ordinate for splash screen to be centered

TextWidth=162                                             
TextHeight=30
TextX=(DlgWidth-TextWidth)  /2                             ;Determine X co-ordinate for label to be centered
TextY=(DlgHeight-TextHeight)/2                             ;Determine Y co-ordinate for label to be centered

;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~;
;FixBox : Sets window style.                                                      ;
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~;
;Win   : window name                                                            ;
;flags : Use '&' to combine flags                                                 ;
;        ~262144    unresizable                                                   ;
;        ~65536     remove maximize                                               ;
;        ~131072    remove minimize                                               ;
;        ~12582912  remove caption                                                ;
;        ~524288    remove system menu                                            ;
;        2147483648 pop up mode                                                   ;
;        8388608    pop up mode with border                                       ;
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~;
#DefineFunction FixBox(Win,Flags)                          ;Originally by Guido, with some liberties taken by Marc Worrel
hwnd=DllHwnd (Win)                                         ;Get window handle
User32 = StrCat(DirWindows(1),"USER32.DLL")
OldStyle=DllCall(User32, long:"GetWindowLongA",long:hwnd,long:-16)
NewStyle=OldStyle & Flags
Result = DllCall(User32,long:"SetWindowLongA",long:hwnd,long:-16,long:NewStyle)
;Display can glitch until window is refreshed, so convince it has moved by moving it to its own current position
CurPos = Arrayize(WinPosition(Win),",")                      
WinPlace (CurPos[0],CurPos[1],CurPos[2],CurPos[3],"Splash Test")
Return (Result)
#EndFunction

#DefineSubRoutine   DlgCallback (DlgName,DlgEvent,DlgCtrlNo,param4,param5)
InitDialog = 0
TimerTick  = 1
   Switch DlgEvent
      Case InitDialog
         Count=10                                          ;Set initial count
         IntControl (54,"Splash Test",1,0,0)
         FixBox ("Splash Test",8388608)                    ;Get rid of window caption and create frame
         DialogProcOptions(DlgName,TimerTick,1000)         ;Set 1 second timer event
         Return (-2)
      Case TimerTick
         Count=Count-1
         If Count==0 Then Return (1)
         Return(-2)
   EndSwitch 
   Return(-2) 
#EndSubRoutine

frmSplashFormat=`WWWDLGED,6.1`
frmSplashCaption=`Splash Test`
frmSplashX=DlgX
frmSplashY=DlgY
frmSplashWidth=DlgWidth
frmSplashHeight=DlgHeight
frmSplashNumControls=002
frmSplashProcedure=`DlgCallback`
frmSplashFont=`DEFAULT`
frmSplashTextColor=`DEFAULT`
frmSplashBackground=`DEFAULT,DEFAULT`
frmSplashConfig=123
frmSplash001=`201,155,034,014,PUSHBUTTON,DEFAULT,"OK",1,1,1,DEFAULT,DEFAULT,DEFAULT`
frmSplash002=`%TextX%,%TextY%,%TextWidth%,%TextHeight%,STATICTEXT,DEFAULT,"Insert text here",DEFAULT,2,DEFAULT,"Microsoft Sans Serif|24576|40|34","0|0|128",DEFAULT`
frmSplashButtonPushed=Dialog("frmSplash",1)


Article ID:   W15477
File Created: 2005:12:22:14:24:36
Last Updated: 2005:12:22:14:24:36