I have a Windows Mobile application where in the Main method I show the Main form:
[MTAThread]
static void Main()
{
new MainForm().ShowDialog();
}
When the program starts I see the the typical animation loading:
Instead of this animation I want to see an image (full screen), how can I do?
There you can find a complete sample on how to embedd a splash screen to your .NETCF application.
.NET Compact Framework Sample: Splash Screen
Don't be confused that link points to the .exe, this sample is made as an installer but as the end result you'll see the code itself.
One unfortunate thing about the CF SLR is that it shows that wait cursor down in the bowels when it starts JITting and loading classes. There's no way to get rid of it. You can create your own splash screen, but keep in mind that it won't show until the framework is loaded enough to display it unless it's a separate app. Even with a separate splash screen, that wait cursor will still be there, so it's not an "instead" like you want, but an "also".
Related
I am working on a program that starts several other c# WPF applications and checks wether there are errors (using .NET Automation Services / UITesting).
One of the requirements of it is to take a screenshot of the main window and to put it into a word document. I alread got it working quite fine when it´s one application at a time (using code from this site: http://www.developerfusion.com/code/4630/capture-a-screen-shot/) , but as soon as i am using parallelism (say, checking 5 applications in a parallel manner), i am running into the problem that the screenshots of the windows may be overlapped by other windows that just popped up or that are always brought to the front (e.g. splash screens). Bringing the window to the front does not really help.
There was an older similar thread not directly regarding to WPF applications, and sadly, without a clear solution: Taking screenshot of a partially hidden window in a programmatic way
Is there a way to get a "clean" screenshot, may be with the use of the windows AutomationElement instance?
I have a C# Windows program that offers a 30-day free trial. After that, users must purchase the product or it will lock them out. I made a splash screen to occupy the user while the program queries my web server to see if the user is tampering with data to try to get the program to work without purchasing it.
On my Windows 8 machine (I'm using .Net Framework 3.5), the splash screen comes up nicely, then the MessageBox comes up (over top of the splash screen) to give them info like "your 30 day free trial has 2 days left".
However, on my XP machine, the MessageBox is hidden by the splash screen. Any ideas on how I can SendToFront() the MessageBox or SendToBack() the splash screen? If I just try to send the form on the splash screen to the back, that's not the same as sending the whole thread to the back.
Here's the code to show the splash screen:
static public void ShowSplashScreen() {
// Make sure it's only launched once.
if (ms_frmSplash != null)
return;
ms_oThread = new Thread(new ThreadStart(SplashScreen.ShowForm));
ms_oThread.Name = "SplashScreenThread";
ms_oThread.IsBackground = true;
ms_oThread.SetApartmentState(ApartmentState.STA);
ms_oThread.Start();
while (ms_frmSplash == null || ms_frmSplash.IsHandleCreated == false) {
System.Threading.Thread.Sleep(TIMER_INTERVAL);
}
}
Without seeing all of your code, I think what is happening is this:
You run your splash screen on a separate thread from your main GUI thread, then launch your message box from the main GUI thread (or yet another thread). Interfaces on separate threads will act independently (read: erratically) for their Z-order. Try moving your GUI elements (splash screen and message box) to the main thread. Run all long running processes (your server check) on another thread.
OK, I see what Servy and MikeH are saying, but my concern is that I do a bunch of work and it still doesn't work. Or, it just isn't predictable from machine to machine. So, the approach I'm going to take is to enhance the splash screen so that it presents the results from the server, rather presenting it in a separate window. That way, no Z-ordering to worry about at all...
Thanks for the thoughts, though, I might need them later on!
I’m developing a screen saver in C# .NET4.0 on VS2010 which needs to do a fair bit of processing before it actually shows screens (fairly complex database access). This is fine because the user is unaware that this processing is going on and then the full screen forms kick in when everything is ready. That is, unless we are running on Windows 8.
Searching on the Microsoft Community (http://answers.microsoft.com/en-us/windows/forum/windows_8-desktop/bubbles-screensaver-has-black-background/e0807324-5ca6-4abe-b6ba-716848b41ff5?page=4) reveals that a design change was made in Windows 8 that prevents screensavers from drawing over an image of the desktop. Any screensaver that previously drew over the desktop will instead draw over a plain background using your chosen “metro” background colour. Experimenting reveals that this background kicks in immediately the .scr file launches i.e. before any forms can be displayed. Hence tricks like displaying forms minimised or with 0% opacity don’t work because this simply reveals the plain background underneath.
The best I’ve been able to come up with is to display full screen plain black forms as first action when my code starts i.e. before any database processing or other screen construction takes place. Why try to replace a plain screen with another plain screen? Well, because the default Windows background colour seems to be blue. That’s blue as in BSOD blue which looks kind of alarming when it kicks in. So the best I can do for a Windows 8 user experience is a quick flicker of blue followed by 3-4 seconds of plain black before screens are populated with something meaningful.
This new behaviour from Microsoft is apparently “by design”. The fact that it doesn’t manifest itself in Preview mode is apparently an error which one supposes MS will tidy up later.
So my question is does anyone know any way around this so that I can continue to have the desktop showing until screensaver forms are ready to kick in?
I struggled quite a lot with a similar problem regarding this awkward design decision in win8.
I the end had to compromise but my search continues for a a bullet proof solution, when I have time.
Now what I ended up with is running a batch file after the monitoring system starts and have thread detect idle time and run that batch again.
#start /wait Bubbles.scr /s & rundll32 user32.dll,LockWorkStation
What this does is:
starts screensaver preview in fullscreen (this works in win8) and waits
on user action lock screen is show and user prompted for password
As I said it's a compromise until a find something better. Hope it helps
Updated to win10; try to use that cool scr and found same issue;
Try to trick ms restriction and found only one very long solution:
enable logging of screensaver invoked events;
here instruction via gpedit: https://superuser.com/questions/538146/run-a-batch-cmd-upon-screensaver
now you will able to start other comand or app when screensaver starting;
goto C:\Windows\System32
copy Bubbles.scr and rename to Bubbles.exe
then config task to run C:\Windows\System32\Bubbles.exe with argument /s (administration->taskcheduler)
use some windows screensaver and config to use 1 min or more; (or use 'runsarver' with empty options from upper link or create your own empty.exe and rename to .scr and install with right menu, etc)
Found cool app to customize hidden screensaver features: http://winaero.com/download.php?view.8
(work with small bugs but work as needed under win10)
All work fine one cons checkbox to lock PC must be unchecked;
If needed create own app to run Bubbles and on exit lock PC or bat file as above, etc;
hope people will have fun with my solution :)
I am doing win form project.(C#). In that project i am willing to add welcome screen. So i created a welcome screen. But, It want to show a few minitute and automatically closed and open login screen.
System.Threading.Thread.Sleep(1500);
LogIn n = new LogIn();
n.Show();
I try this code in form shown,load, activate events. BUt no use. Any one know what to do?.
Here's a tutorial explaining how to make a splash screen.
Add a line for splash screen in Program.cs. Run a timer in splash screen and close the form.
private static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new FSplash()); // This is your splash form << added
Application.Run(new FMain());
}
In my opinion, you cannot create a splash screen in .NET for a .NET application:
The purpose of a splash screen is to distract users from long waiting times, until the application has been loaded, started and initialized.
Since a .NET application itself already has some startup time, there is no splash screen available within this time.
My solution
So in my applications, I am doing it the following way:
Write a small, tiny native C++ application.
Display a topmost bitmap (window with no borders) when the C++ application starts.
Let the C++ application start the actual .NET application.
The .NET application starts and when it is finished starting and initializing, it tells the C++ application to close. This is done through IPC.
The inter-process communication is done the following way:
The C++ application writes a temporary file.
When calling the .NET application, the file name is passed as a command line parameter.
The C++ application polls regularly whether the file exists.
The .NET application deletes the file as soon as the splash screen has to be hidden.
The C++ application exists as soon as the temporary file does not exists anymore (or a timeout occurs).
I know this is not 100% perfect, it was the most suitable solution I came up since I started developing .NET applications, years ago.
how do i calculate the loading percentage of my C# application. i want to show a splash screen with a progress bar showing percentage of application loaded.
Is there any standard method\library for that or i will have to just update the progress bar value at different points in my form load code.
Or can any gimme a tutorial on application preloaders
The first time user starts your application, assume it will take 10 seconds and show progressbar counting down those 10 seconds. Once the application is loaded, save somewhere on user's computer actual time it took to load your application. Next time user loads your application, use saved time instead of your original 10 seconds.
This is simple and obvious concept. User doesn't care what parts of the application are loading, he cares how long it's going to take and he wants to see countdown.
Probably the easiest way to do this is to create an instance of your splash form at the beginning of your startup form's Load event. In the splash form, expose its ProgressBar as a public property. After creating the splash form, set its ProgressBar's Maximum property to the number of discrete steps that you can identify in the Load event code, then show it by calling its .Show() method (not .ShowDialog(), of course).
As each step in the Load event completes, you just increment the public ProgressBar's Value property. When all steps have completed, close the splash form and dispose it.
This may or may not work properly, because if your startup form contains a large number of controls, then a good percentage of the total loadup time will actually be spent in the form's constructor, which will be called before the Load event. It might be best to move all of your initialization code into the constructor, and create and Show the splash screen from there.
Well, in any case you need a fairly accurate guess at how long your individual steps take. Only then can you give an actually meaningful progress bar. You can approximate it by dividing your loading process into several steps you assume to be roughly equal in time and calculate progress as you finish those steps.
An alternative would be not to show a progress bar but rather a series of loading steps, represented either by text or graphically. I think KDE does this on startup. That way you show progress but avoid the user's expectations towards a progress bar (which works best if the progress bar is either linearly progressing or accelerating. If it frequently stops and jumps it just creates the impression of a very slow process).
Another option would be to eliminate the splash screen entirely by trying to make program startup fast and loading what you need at runtime. This may or may not be an option for you or your program but it can show pretty significant improvements in startup time and overall impression of program speed.
First of all the Splash screen is shown to give user an illusion that program has started and they will be handled control at any moment.
Secondly if you want to show the progress bar then you need to accurately calculate the number of tasks you perform. Then show the label loading xxxxxx....... and increment progress bar after completion of every item.
As for the question of optimizing starting up time it mainly depends upon the function of your application.
Suppose you app is a PIM then you may load the events and tasks for today and show it to the user quickly and then start loading other data.
I once had an application where I had to show the object hierarchy using Treeview each node could have unlimited number of items. I loaded the top level objects and displayed then in the tree view and put marker (actually I put * in tag of the node, which I learned from some .net book or article I had read long ago but remembered) when use clicked on the node I loaded the immediate children.
A Pretty Good Splash Screen or Splash Screen