ElapsedMilliseconds()

Everything else that doesn't fall into one of the other PB categories.
ebs
Enthusiast
Enthusiast
Posts: 567
Joined: Fri Apr 25, 2003 11:08 pm

ElapsedMilliseconds()

Post by ebs »

Can anyone tell me what code and/or Windows API calls are used for the "ElapsedMilliseconds()" function?

One of my programs has a simple splash screen (just 3 TextGadgets), which is displayed like this:

Code: Select all

; display splash screen
OpenWindow_Window_Splash()
st.l = ElapsedMilliseconds()
Repeat
  While WindowEvent():Wend
Until ElapsedMilliseconds() - st = 1500
CloseWindow(#Window_Splash)
This works fine on almost every machine, except one. On this PC,
the splash screen never closes, and the CPU usage goes up close to 100%.
The problem PC is running Windows XP SP2, but I have also seen the same result on Vista.

Can anyone help me understand why this hangs, and maybe suggest a better way to do it?

Thanks for your help,
Eric
User avatar
nco2k
Addict
Addict
Posts: 1344
Joined: Mon Sep 15, 2003 5:55 am

Post by nco2k »

Code: Select all

Until ElapsedMilliseconds() - st >= 1500
c ya,
nco2k
If OSVersion() = #PB_OS_Windows_ME : End : EndIf
ebs
Enthusiast
Enthusiast
Posts: 567
Joined: Fri Apr 25, 2003 11:08 pm

Post by ebs »

Of course!!! :oops:
I'm surprised that it did work on most of the machines!

Thanks,
Eric
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

Code: Select all

Repeat 
  While WindowEvent():Wend 
Until ElapsedMilliseconds() - st <= 1500
This will always use 100% cpu. There is no delay in there. Better use WaitWindowEvent(15).

In any case, the code seems meaningless. The splash screen is displayed when the program loads to show the user that the program loads. With this code, the program doesn't do anything when the splash screen is there, which is just a waste of time.
ebs
Enthusiast
Enthusiast
Posts: 567
Joined: Fri Apr 25, 2003 11:08 pm

Post by ebs »

Trond wrote:This will always use 100% cpu. There is no delay in there. Better use WaitWindowEvent(15).
That's a good idea - thanks.
Trond wrote:In any case, the code seems meaningless. The splash screen is displayed when the program loads to show the user that the program loads. With this code, the program doesn't do anything when the splash screen is there, which is just a waste of time.
The purpose of the splash screen is just to display the customer that the program is licensed to.
The main window opens immediately after the splash screen closes, and the program is ready to go.
It is a small waste of time (1.5 seconds), but a necessary one.

Thanks for your suggestion.
User avatar
talisman
Enthusiast
Enthusiast
Posts: 231
Joined: Sat May 23, 2009 9:33 am

Post by talisman »

May I add my personal opinion on this? Whether the application is targeted for personal or business use, I feel that splash screens of any nature are a waste of time and usefulness. Sure, one and a half seconds might sound small, but being an aggressive multitasking maniac myself I want everything to open up snappy without any delays and let my computer decide when it wants to slow things down or not. If you really must show whom the application is licensed to, maybe you could use the window title for this. Something like "My Application (Licensed to: Client, My)" will definitely work. Besides, you can always have the splash screen there, just make it show up whenever the user chooses so from the menu (Help -> About anyone?).

Anyway, just my personal opinion so decide on your own how you want to do it. Your application after all :)
User avatar
Kaeru Gaman
Addict
Addict
Posts: 4826
Joined: Sun Mar 19, 2006 1:57 pm
Location: Germany

Post by Kaeru Gaman »

another possibility is, to put the splashscreen topmost and open the window in the back without any delay, and disable the splashscreen on the first click on the surface.
this makes the sc visible as long as possible without any delay for the functionality.
the editor for civ3 does it this way.
oh... and have a nice day.
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

Yes, splash screens that are not there to show that the program is actually doing something are ridiculous and ignorant.

In any case, it seems irrational that one would care who the application was registered to. And if one actually cares, it seems irrational that this information would be available for only 1.5 second (read fast!) on program startup (to find out who it's registered to you have to close the program and restart it!).

Sorry about ranting but honestly, it is well deserved! :twisted:
Kale
PureBasic Expert
PureBasic Expert
Posts: 3000
Joined: Fri Apr 25, 2003 6:03 pm
Location: Lincoln, UK
Contact:

Post by Kale »

IMHO there is nothing wrong with splash screens as long as they are asynchronous and show useful program information. Once the main app has loaded, however, they should disappear.
--Kale

Image
User avatar
Rescator
Addict
Addict
Posts: 1769
Joined: Sat Feb 19, 2005 5:05 pm
Location: Norway

Post by Rescator »

You might want to consider the new (PB4.40) message timer instead.
Post Reply