Open main window (OpenWindow(#WinMain, ... #PB_Window_Invisible
Hide-it Use #PB_Window_Invisible in OpenWindow line
Open a second window for splashscreen OpenWindow(#WinSplash, (borderless)
Display something in splashcreen (progressbar, text etc)
Create gadget for main window (whatever there are slow, this is hide)
When all initialization are done
Close window splashscreen (CloseWindow(#WinSplash
Unhide main window HideWindow(#WinMain, #False)
With this technique, no matter how long it takes to initialize the main window, it will appear only when everything is ready.
CloseWindow(#WinSplash is the last line of initialisation
(this is how I do in my little software the splashscreen is display will loading INI file, but main window is here (but hide))
Last edited by Marc56us on Thu Oct 06, 2016 4:23 pm, edited 1 time in total.
Ok, but now I need to do ThreadSafe application. A ThreadSafe programs run slower than usual. It turns due SplahScreen entire program will then run slowly? )
__________________________________________________
Quote tag repaired
07.10.2016
RSBasic
; Sample of simple Splash screen system
; Marc56us - 2016-10-06
Enumeration
#Win_Main
#Win_Splash
#Load_Report
EndEnumeration
; --- Open main window first with *** #PB_Window_Invisible *** option
; --- Because some objects like timer are attached on it
OpenWindow(#Win_Main, 100, 100, 500, 300, "Hello World",
#PB_Window_SystemMenu| #PB_Window_Invisible)
OpenWindow(#Win_Splash, 0, 0, 300, 100, "",
#PB_Window_ScreenCentered | #PB_Window_BorderLess)
TextGadget(#Load_Report, 10, 40, 280, 80, "Loading...", #PB_Text_Center)
; --- Initialization...
; --- Now create object for #Win_Main and others action
; --- Display what you do
; --- Add delay only if user need to read it
; --- Sample
SetGadgetText(#Load_Report, "Load INI datas") : Delay(1000)
; --- add call for Procedure to load prefs
SetGadgetText(#Load_Report, "Create Interface") : Delay(1000)
; --- add call for Procedure for create objects
; etc.
SetGadgetText(#Load_Report, "Drink my coffee... ;-)") : Delay(3000)
SetGadgetText(#Load_Report, "Oh oh? Phone call, wait") : Delay(2000)
SetGadgetText(#Load_Report, "Done Spam call :-]") : Delay(2000)
SetGadgetText(#Load_Report, "Yes, now Ready.") : Delay(1000)
; --- That's it.
CloseWindow(#Win_Splash)
; --- unhide main window
HideWindow(#Win_Main, #False)
While WaitWindowEvent() <> #PB_Event_CloseWindow : Wend
Marc56us wrote:
Put animation on a Window and splashscreen on another window (over)
Uses StickyWindow(#Win_Splash, #True) to keep splash windows on top.
and you joker
I animation is created in real time.
As far as I know, you shouldn't make changes to the gui from outside the main thread.
So you might want to consider to reverse things; handle the animation from the main event loop and do the initialization and loading from another thread.
You could also try to optimize the initialization so it doesn't take that long (5 seconds seems much to me).
If I remember correctly it's also not a very good idea to use WindowOutput. It's better to use an ImageGadget or CanvasGadget. Drawing to WindowOutput is slower.