views:

73

answers:

1

Hi guys,

I'm facing a problem when displaying a splash screen in a system with two monitors. When I start the application in the primary display, and then the mouse pointer is moved to the second monitor before the splash screen is shown, my splash screen "follows" the mouse pointer. That means, the splash screen is shown in the 2nd display and after it finishes its work, dissapears and the application is displayed in the primary monitor. This looks pretty ugly and unprofessional.

I have tried to set the property FormStartPosition.CenterScreen in the form's properties and set it in run time in the constructor of my form but none of this has worked. By the way, I'm using C#.

Any hints to achieve that the splash screen be displayed in the same monitor as my application?

Any help will bee deeply appreciated.

Greetings, Victor

+2  A: 

In Main, you need to force the form to start on the primary monitor. Here's how to open a form at (0, 0) on the primary monitor.

    [STAThread]
    static void Main()
    {
        Application.EnableVisualStyles();
        Application.SetCompatibleTextRenderingDefault(false);

        Form1 f = new Form1();
        f.StartPosition = FormStartPosition.Manual;
        f.Location = Screen.PrimaryScreen.Bounds.Location;

        Application.Run(f);
    }
Alex Morris
Hi Alex, thanks for your answer, unfortunately this didn't help to solve the issue. I should've mentioned that the splash screen is included in a dll (a component created in C#) which is called by a C++ application. So the splash screen has to be shown in the display where the C++ application is started. I tried including the line f.Location = Screen.PrimaryScreen.Bounds.Location; in the constructor of the slpash screen but it didn not help. Any ideas?
Hi, the problem was solved including the follwing lines in my Form constructor: this.Location=Screen.PrimaryScreen.Bounds.Location; this.CenterToScreen; If I use this.StartPosition=FormStartPosition.CenterScreen; then I get the described problem. Thanks for the help !
Glad this was able to help steer you in the right direction.
Alex Morris