WPF application window appears on top of SplashScreen - wpf

I followed the simple steps outlined at How to: Add a Splash Screen to a WPF Application to add a splash screen to my WPF application. When I start the application, the splash image is shown, then the main window pops up, and the splash image fades away.
My problem is that when the main window pops up, it appears on top of the splash image. Then when the splash image begins to fade out, the splash image pops up to the top again. The end result is that the splash image disappears for a split second as the main window appears.
How can I force the main window to appear under the splash image, so that the splash image does not disappear?

In .NET 4.0 an overload has been added to the Show method that allows to set the window style WS_EX_TOPMOST on the splash screen window. Show the splash screen in code like this:
SplashScreen splash = new SplashScreen("SplashScreen.png");
splash.Show(autoClose: true, topMost: true);
I call that from the method
protected override void OnStartup(StartupEventArgs e)
in App.xaml.cs.
"SplashScreen.png" is of course the identifier for your splash image embedded in the application's resources.

This isn't default behaviour you must have some code thats manually focusing the main window?
It may be easier just to turn off the fade manually with a bit of code like this:
_splash = new SplashScreen("LoadingScreen.png");
_splash.Show(false);
_splash.Close(TimeSpan.Zero);

Not sure if this will help, but if you set the owner of the Splash screen to the current form, then this should maybe do the trick?
_splash.Owner = this;
Otherwise you can look here:
Splash Screen Example
This might help too.

Related

How to make label transparent without any flickering at load time

I have a panel and on that I've a picturebox. There are around 20 labels that I've to show in the panel. I want the background of Label to be transparent ie the image in picturebox is shown and the label displays only the text.
Now since labels do not exhibit true transparency I made the labels child of picturebox
this.lbl1.Parent = pictureBox1;
This has solved my immediate problem but now when the form loads, all the labels take a while to become visible and do so one at a time. I'd appreciate if you guys can give some solution for this.
Thanks in advance
The standard cure for flicker is double-buffering. But that cannot solve this kind of flicker. It is a different kind, caused by having multiple windows overlapping each other. Each label is its own window. When the form needs to paint itself, it draws its background leaving holes for the child windows. Each child window then takes a turn drawing itself. And their child windows draw themselves next. Etcetera.
This becomes noticeable when one control takes a while to draw, no doubt your picture box. Especially when it displays a large image that needs to be resized. The holes for the child windows stay unpainted while the picture box draws. They have a white background, black when you use the form's TransparencyKey or Opacity property. This can contrast badly with the image in your picture box, that effect is perceived by the user as flicker.
One immediate cure is to not use controls so you don't pay for their window. A Label is very convenient but it is a massive waste of system resources to burn up a window just to display a string. You can simply implement the picture box' Paint event and draw the strings with TextRenderer.DrawText(). PictureBox has double-buffering turned on by default so the image as well as the text is drawn completely smoothly, no more flicker. The obvious disadvantage is that you lose the convenience of point-and-click, you have to write code.
There are other fixes possible. One of them is to prevent the picture box from leaving holes for the child windows. It will draw the entire image, the labels pop on top of them. That's still flicker but not nearly as noticeable. Add a new class to your project and paste this code:
using System;
using System.Windows.Forms;
internal class MyPictureBox : PictureBox {
protected override CreateParams CreateParams {
get {
var parms = base.CreateParams;
parms.Style &= ~0x02000000; // Turn off WS_CLIPCHILDREN
return parms;
}
}
}
Compile and drop the new picture box control from the top of the toolbox onto your form.
Yet another possible workaround is to make the form and all of its children double-buffered. This doesn't speed up the painting at all but all of the windows get rendered into a memory buffer, the result is blitted to the screen. You'll notice a delay but the window suddenly pops on the screen. This is called compositing. Winforms doesn't support this directly since it can have side-effects but it is easy to enable. Paste this code into your form class:
protected override CreateParams CreateParams {
get {
CreateParams cp = base.CreateParams;
cp.ExStyle |= 0x02000000; // Turn on WS_EX_COMPOSITED
return cp;
}
}
Supported by XP and later. Watch out for painting artifacts.
or you can ditch the labels and draw the text yourself:
private void pictureBox1_Paint(object sender, PaintEventArgs e)
{
TextRenderer.DrawText(e.Graphics, "Label1", SystemFonts.DefaultFont,
new Point(10, 10), Color.Black, Color.Empty);
}
The label does not support transparency, you must create your own unique custom control, you can see these code examples.
http://www.codeproject.com/KB/dotnet/transparent_controls_net.aspx http://www.codeproject.com/KB/vb/uLabelX.aspx
Bye

How do you disable the Windows Phone 7 splash screen?

Is there any way to disable the WP7 splash screen and just show a blank screen?
My splash screen only stays on for less than half a second, leaving the user with a rather jarring sensation. I'd rather they not see any splash screen at all.
I would have simply used a plain black image as my splash screen, but then that would result in an ugly experience for people using a light theme (since my app's background is white on light themes and black on dark themes)
Thanks!
Simply remove the file SplashScreenImage.jpg.
Right click on the image file, select "Exclude from project". Rebuild.
Just try to delete the SplashScreenImage.jpgas madd0 said :)
If you want your SplashScreen to last longer you can add a start page like this:
Customer Splash Screen
Modify the Timespan to suit your the time you want:
_splashTimer.Interval = new TimeSpan(0, 0, 2);
Like everyone says, you could delete it. But before that, just rename it - right-click on SplashScreenImage.jpg in the Solution Explorer, click rename and just name it something like: SplashScreenImage2.jpg - gives VS a chance to catch up with your intent depending on your machine. Then delete that file.
You can and should delete the splash screen as per the guidance in the Windows Phone 7 Application Certification Guide in section 5.2.1.a:
Microsoft recommends that the
application provides a splash screen
image only when it takes longer than 1
second to load the first screen.
However, one thing that I've discovered is that while many apps can fire up really fast the first time they are launched, they made load slower after that if they have data that has been tombstoned. Just FYI

Windows Forms User Control not painting well in WPF application

So, this is the issue:
I have a Windows Forms User Control that I placed in main Window of my WPF application. I override paint method of User Control. It paints ok in "ideal" case. But, after showing the control in main window, I added MessageBox. This is the code snippet:
board = new BoggleBoard(Boggle.CurrentGame.Size);
boardHost.Child = board;
MessageBox.Show("You have " + time + " seconds to find as many words as you can. Click OK when you are ready to play);
If I don't show MessageBox, everything is ok. But with the code above, after MessageBox is shown, my control is painted, but just like boardHost (Windows Form Host) has lower opacity, so I get dark area around the control. I say "like" cause I tried with
boardHost.Opacity = 1;
but it doesn't help, I still get the same thing.
What might cause this problem?
Here is a screenshot. As obvious, the dark area around the board should not be there. And it is not visible if I don't show MessageBox after it is drawn.
http://i.stack.imgur.com/RZs2W.png

WPF animated splash screen

Is it possible to show a splash screen in WPF that has animation. I want my name of the company and the name of the application to fly in and a progress bar that continously animates. I Used this example
http://blogs.lessthandot.com/index.php/DesktopDev/MSTech/wpf-and-the-splashscreen
to try and get me started but the progress bar doesnt animate?
Also I do have on the progress bar the following property set. IsIndeterminate="True"
I am using vb.net.
Thanks,
spafa9
See my answer at the bottom of this question: Multi-threaded splash screen in C#?
This is in C#, but it does work with an animated indeterminate progress bar.

childWindow Full Screen Event tweak the Parent to also FullSCreen Mode

I have a ChildWindow which contains a ExpressionMediaPlayer inside it. When I click on the ChildWindow Media Player Full screen button it swiches the whole application to FullScreen Mode.
Is there a way to avoid it. I am not quite sure if this scenario is going to fall under SL security restrictions.
When I drag the ChildWindow(the position of ChildWindow changes) and click on the fullscreen
now the ChildWindow also changes it's position.
For example if I have dragged the ChildWindow 50px from Top and pressed the Full Screen button of of mediaPlayer (it contains) the Child Window also appears 50 pixels below the Screen Top.
But I want My ChildWindow to be FullScreen without having any Gap from LEFT,TOP,RIGHT or below.
Any help will be greatly appreciated.
Thanks,
Subhen
Silverlight only uses one of its two windows. The first is the normal window embedded in the Host application such as IE (or in windowless mode it co-operates with the host to draw directly on one of the host's windows in a give rectangle). The other window is a Fullscreen one.
When in full screen mode it moves all its rendering of its stack of content to the full screen window. You can't get Silverlight to render only some controls on the Fullscreen window, its an all or nothing proposition.
Creating a "fullscreenable" ChildWindow would be an interesting exercise. Probably a new templated control based on Childwindow with a new "Fullscreen" visual state (in a new state group) that hides the chrome and causes the content grid to stretch with Auto Width and Height.

Resources