473,383 Members | 1,748 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Screen Coordinates of Secondary Screen

In a multi-monitor environment, a form I am creating at run time keeps
placing itself on the primary screen, even if the main form of the program
making the call is on the secondary screen.

How do I place a form on the secondary screen (monitor)?

--
--Zorpie
Jan 4 '06 #1
4 8072
Zorpiedoman,
I normally set the bounds of my form to the bounds of the secondary screen.

Something like (VB.NET):

Protected Overrides Sub OnLoad(ByVal e As System.EventArgs)
MyBase.OnLoad(e)
Dim s As Screen
For Each s In Screen.AllScreens
If Not s.Primary Then Exit For
Next
Me.Bounds = s.Bounds
Me.WindowState = FormWindowState.Maximized
End Sub

NOTE: I look for the non primary screen, rather then assume AllScreens[1] is
the second screen... The above code works if there is no secondary monitor
(it just uses the primary).
--
Hope this helps
Jay [MVP - Outlook]
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley - http://www.tsbradley.net
"Zorpiedoman" <no*********@beatles.com> wrote in message
news:1A**********************************@microsof t.com...
| In a multi-monitor environment, a form I am creating at run time keeps
| placing itself on the primary screen, even if the main form of the program
| making the call is on the secondary screen.
|
| How do I place a form on the secondary screen (monitor)?
|
|
|
| --
| --Zorpie
Jan 4 '06 #2
Jay,
NOTE: I look for the non primary screen, rather then assume AllScreens[1] is
the second screen... The above code works if there is no secondary monitor
(it just uses the primary).


But it seems to assume that there is at most one secondary monitor,
what if you have more than that? If you have one form and want another
to appear on the same screen wouldn't it be better to do something
like

form2.Bounds = Screen.FromControl(form1).Bounds
Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Jan 4 '06 #3
| But it seems to assume that there is at most one secondary monitor,
| what if you have more than that?
Yes my code is written to find the first secondary monitor.
| form2.Bounds = Screen.FromControl(form1).Bounds

Doh! I miss read the original question. Screen.FromControl would be better
to find the screen where a form is currently displayed.

--
Hope this helps
Jay [MVP - Outlook]
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley - http://www.tsbradley.net
"Mattias Sjögren" <ma********************@mvps.org> wrote in message
news:ez**************@TK2MSFTNGP15.phx.gbl...
| Jay,
|
| >NOTE: I look for the non primary screen, rather then assume AllScreens[1]
is
| >the second screen... The above code works if there is no secondary
monitor
| >(it just uses the primary).
|
| But it seems to assume that there is at most one secondary monitor,
| what if you have more than that? If you have one form and want another
| to appear on the same screen wouldn't it be better to do something
| like
|
| form2.Bounds = Screen.FromControl(form1).Bounds
|
|
| Mattias
|
| --
| Mattias Sjögren [C# MVP] mattias @ mvps.org
| http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
| Please reply only to the newsgroup.
Jan 4 '06 #4
Thanks Guys!
Jan 4 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: phil cunningham | last post by:
Hello, I am looking for a good way to scale real objects on to the screen/printer In our project, objects are created assuming the units are meters. For example, I may have a rectangluar shape...
2
by: Dan Sikorsky | last post by:
How do you get the x,y pixel location of a textbox so that you can position the Web Date Control popup nearby the associated textbox that will contain the date selected by the Web Date Control? ...
3
by: ZorpiedoMan | last post by:
Help... I need the screen coordinates of a control so I can place a pop up form underneath it. --Zorpy *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in...
1
by: zoneal | last post by:
OS: Win XP Language: VB.net or C# I have a program where I need to launch 2 separate instances of an App called "Main.exe". Each instance will need to be piped to there own video display. ...
3
by: steve | last post by:
Hi All I have textboxes within a TableLayoutpanel and I want to be able to position an independant control adjacent to a selected textbox This independent control allows selection of text to...
11
by: AliR | last post by:
Hi everybody! I need a script, which calculates screen coordinates of given object (e.g. textbox or div). By "screen coordinates" I mean offset from upper left corner of the screen (not frame or...
3
by: Peter Oliphant | last post by:
I'm programming using MS VS VC++ 2008 Express (Beta 2) in /Cli pure mode. I've found the Screen class. With it I can very easily get the count and all the data on the various Screens attached to...
0
by: raylopez99 | last post by:
keywords: logical coordinates, page coordinates, world coordinates, device coordinates, physical coordinates, screen coordinates, client coordinates. offset rectangle. WYSIWYG rubber rectangle...
10
by: =?Utf-8?B?UmljaA==?= | last post by:
A lot of users at my workplace use different screen resolutions, and I build apps to use 1680 x 1050 pixels res by default. But some users are using 800 x 600, and the apps are too large for their...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.