By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,079 Members | 940 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,079 IT Pros & Developers. It's quick & easy.

Dual Monitors

P: n/a
Assuming a user has a dual (or more) monitor setup, how do I force a
windows form application to open up and display in the default monitor
of the system?

Thanks in advance

Dave.

Jun 21 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
> Assuming a user has a dual (or more) monitor setup, how do I force a
windows form application to open up and display in the default monitor
of the system?


Here's how to centre the form on the primary monitor:

***
Rectangle wa = Screen.PrimaryScreen.WorkingArea;
this.Location = new Point(
((wa.Width - this.Width) / 2) + wa.X,
((wa.Height - this.Width) / 2) + wa.Y);
***

It centres the window on the working area of the screen (i.e. not including the area taken up by the start bar etc.) If
you would prefer to make it based on the full screen area then set wa to Screen.PrimaryScreen.Bounds instead.
Hope this helps,

Mike
- Microsoft Visual Basic MVP -
E-Mail: ED***@mvps.org
WWW: Http://EDais.mvps.org/
Jun 21 '06 #2

P: n/a
Excellent -many thanks - works a treat.
Mike D Sutton wrote:
Assuming a user has a dual (or more) monitor setup, how do I force a
windows form application to open up and display in the default monitor
of the system?


Here's how to centre the form on the primary monitor:

***
Rectangle wa = Screen.PrimaryScreen.WorkingArea;
this.Location = new Point(
((wa.Width - this.Width) / 2) + wa.X,
((wa.Height - this.Width) / 2) + wa.Y);
***

It centres the window on the working area of the screen (i.e. not including the area taken up by the start bar etc.) If
you would prefer to make it based on the full screen area then set wa to Screen.PrimaryScreen.Bounds instead.
Hope this helps,

Mike
- Microsoft Visual Basic MVP -
E-Mail: ED***@mvps.org
WWW: Http://EDais.mvps.org/


Jun 22 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.