Jump to content

SplashMadeSimple UDF


Dragonlair
 Share

Recommended Posts

hello, this is my second post and my first UDF,

its function is to create a Splash Screen, similar to CorelDraw or Sony Vegas

for now is functions are very limited but I hope will be useful

FUNCTIONS:

_SplashCreate() creates the splash itself whit the initial params and show it

_SplashUpdate() Update the message text in the splash

_SplashUpdateProgress() Update the ProgressBar in the splash, else this function includes a smoothing of the progressbar so the update time from 0 to 100% is of 1-2 sec.

_SplashDelete() Delete the Splash, Both functions _SplashCreate() and _SplashDelete() transitions in a fade effect

Notes: all comments are welcome, as well as suggestions for adding new functions to UDF

Tested in Windows Xp Service Pack 3 Spanish(México) using Autoit 3.3.6.1

PS: sorry for my English is not my native language

TO DO: I have to add functions "Error checking returns" but still the UDF works properly.

OK here is the UDF

#include-once
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
; #INDEX# =======================================================================================================================
; Title .........: Splash Made Simple
; AutoIt Version : 3.3.6.1
; Description ...: Functions to easily create a boot splash
; Author(s) .....: Dragonlair
; ===============================================================================================================================
Global $Splash, $SplashUpdate, $FadeEffectTime, $Progress
Func _SplashCreate($Pic, $Authorcopy, $Widht = 480, $Height = 272, $Loadmsg = "loading.", $FontColor = 0xFFFFFF, $ProgressBKColor = 0xFFFFFF, $ProgressColor = 0xC0C0C0, $FadeEffectTime = 300)
DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0)
$Splash = GUICreate("", $Widht, $Height, -1, -1, BitOR($WS_SYSMENU, $WS_POPUP), BitOR($WS_EX_TOPMOST, $WS_EX_WINDOWEDGE, $WS_EX_TOOLWINDOW))
GUICtrlCreatePic($Pic, 0, 0, $Widht, $Height)
GUICtrlCreateLabel($Loadmsg, 15, ($Height - 62), 438, 17)
GUICtrlSetColor(-1, $FontColor)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$SplashUpdate = GUICtrlCreateLabel("", 15, ($Height - 49), 438, 17)
GUICtrlSetColor(-1, $FontColor)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$Progress = GUICtrlCreateProgress(15, ($Height - 33), 198, 7, $PBS_SMOOTH)
GUICtrlSetColor(-1, $ProgressColor)
GUICtrlSetBkColor(-1, $ProgressBKColor)
GUICtrlCreateLabel("Copyright © " & @YEAR & " " & $Authorcopy, 16, ($Height - 20), 438, 14)
GUICtrlSetFont(-1, 6, 800, 0, "Arial")
GUICtrlSetColor(-1, $FontColor)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $Splash, "int", $FadeEffectTime, "long", 0x00080000)
GUISetState()
EndFunc   ;==>_SplashCreate
Func _SplashUpdate($updatemsg)
GUICtrlSetData($SplashUpdate, $updatemsg)
EndFunc   ;==>_SplashUpdate
Func _SplashProgressUpdate($ProgValue)
if $ProgValue < GUICtrlRead($Progress) Then GUICtrlSetData($Progress, 0)
For $i = GUICtrlRead($Progress) To $ProgValue Step 1
  Sleep(10)
  GUICtrlSetData($Progress, $i)
Next
EndFunc   ;==>_SplashProgressUpdate
Func _SplashDelete()
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $Splash, "int", $FadeEffectTime, "long", 0x00090000)
GUIDelete($Splash)
EndFunc   ;==>_SplashDelete

And an example

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Misc.au3>
#include <SplashMadeSimple.au3> ;Include the UDF
Global $Picture = @ScriptDir & "\background.jpg", $TextColor = 0xFFFFFF, $ProgressBarBGColor = 0xFFFFFF, $ProgressBarColor = 0xC0C0C0
#region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Splash Made Simple Example", 334, 216, -1, -1)
GUICtrlCreateLabel("Loading Message", 8, 8, 88, 17)
$Input1 = GUICtrlCreateInput("Loading...", 96, 8, 233, 21)
GUICtrlCreateLabel("Module name 1", 8, 40, 77, 17)
$Input2 = GUICtrlCreateInput("Main Executable modules", 96, 32, 233, 21)
GUICtrlCreateLabel("Module name 2", 8, 64, 77, 17)
$Input3 = GUICtrlCreateInput("Network Support", 96, 56, 233, 21)
GUICtrlCreateLabel("Module name 3", 8, 88, 77, 17)
$Input4 = GUICtrlCreateInput("Multimedia Support", 96, 80, 233, 21)
$Button1 = GUICtrlCreateButton("Font Color", 8, 176, 75, 33)
GUICtrlCreateLabel("Author info", 8, 112, 55, 17)
$Input5 = GUICtrlCreateInput("Dragonlair Software. OpenSource Code...", 96, 104, 233, 21)
$Button2 = GUICtrlCreateButton("Progress bar bk color", 88, 176, 75, 33, $BS_MULTILINE)
$Button3 = GUICtrlCreateButton("Progress bar color", 168, 176, 75, 33, $BS_MULTILINE)
$Button4 = GUICtrlCreateButton("Preview", 248, 176, 75, 33)
GUICtrlCreateLabel("Width", 8, 152, 32, 17)
$Input6 = GUICtrlCreateInput("480", 40, 144, 49, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_NUMBER))
GUICtrlCreateLabel("height", 104, 152, 33, 17)
$Input7 = GUICtrlCreateInput("272", 144, 144, 33, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_NUMBER))
GUICtrlCreateLabel("image used in background", 184, 136, 129, 17)
GUICtrlCreateLabel("will be automatically stretched", 184, 152, 144, 17)
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
  Case $GUI_EVENT_CLOSE
   Exit
  Case $Button1
   $TextColor = _ChooseColor(2, 0xFFFFFF, 2, $Form1)
  Case $Button2
   $ProgressBarBGColor = _ChooseColor(2, 0xFFFFFF, 2, $Form1)
  Case $Button3
   $ProgressBarColor = _ChooseColor(2, 0xC0C0C0, 2, $Form1)
  Case $Button4 ; If Button Preview Is Pressed
   GUICtrlSetState($Button4, $Gui_Disable)
   GUISetState(@SW_MINIMIZE, $Form1)
   ;we read the values from the GUI
   $inputloadmsg = GUICtrlRead($Input1)
   $loadmsg1 = GUICtrlRead($Input2)
   $loadmsg2 = GUICtrlRead($Input3)
   $loadmsg3 = GUICtrlRead($Input4)
   $authormsg = GUICtrlRead($Input5)
   $inputWidth = GUICtrlRead($Input6)
   $inputheigh = GUICtrlRead($Input7)
;~   here is dscribes how is used the UDF itself
;~  Create the splash whith the default provided parameters
   _SplashCreate($Picture, $authormsg, $inputWidth, $inputheigh, $inputloadmsg, $TextColor, $ProgressBarBGColor, $ProgressBarColor)
;~  we wait 2 secs for the first message in splash update
   Sleep(2000)
;~  here We update the message in the splash
   _SplashUpdate($loadmsg1)
;~  this bucle is to show how progress bar works, the maximun values is 100
   For $i = 0 To 100 Step 25
    Sleep(1000)
    _SplashProgressUpdate($i)
   Next
;~  same as above
   Sleep(2000)
   _SplashUpdate($loadmsg2)
   _SplashProgressUpdate(60)
   Sleep(500)
   _SplashProgressUpdate(100)
   Sleep(2000)
   _SplashUpdate($loadmsg3)
   _SplashProgressUpdate(60)
   Sleep(500)
   _SplashProgressUpdate(70)
   Sleep(1000)
   _SplashProgressUpdate(100)
   Sleep(1000)
   _Splashdelete()
   GUISetState(@SW_RESTORE, $Form1)
   GUICtrlSetState($Button4, $Gui_Enable)
EndSwitch
WEnd

also here is at your disposal the rar with the source code and a test image

I hope not to forget anything else. bye bye

Link to comment
Share on other sites

  • 2 months later...

I tried to use this in my script, running Windows 7. It start my gui with basic theme! :) Why is that? The rest of the system is not affected, but my script gets the Windows Classic theme, you know, no aero, no glassy, the old Windows Classic..

Link to comment
Share on other sites

I tried to use this in my script, running Windows 7. It start my gui with basic theme! :) Why is that? The rest of the system is not affected, but my script gets the Windows Classic theme, you know, no aero, no glassy, the old Windows Classic..

could you give me more details about your issue, because i recently tested it in windows 7 x64 and i dont get that issue.

PS. again, sorry for my english....

Link to comment
Share on other sites

I haven't got that issue either, under windows 7 Home Premium x64 (running 32 bit autoit executable). What system are you running? 32 / 64 bit? Are you using the 32 or 64 bit executable?

Wait 1 second... Try it without this:

DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0)

It is in the UDF, right after the GUICreate Function.

Edited by Mikeman27294
Link to comment
Share on other sites

  • 2 weeks later...

Excellent. Thank you very much for this UDF and the example.

I know its easy to do on my own, however if you were thinking how you could improve the example it would be to export the settings used in the example to form code, like KODA does.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...