Multiple Screen environment...

Ö

Özden Irmak

Hello,

My appliccation saves form size and positions whenever they are closed so
they can be shown at the same size and position when opened next time.

My problem in here is that when it is used in Multiple screen enviornment, I
can't understand whether the window is in which screen and I also don't know
how to set the position of a window other than the primary screen?

Can anybody help me?

Regards,

Özden Irmak
 
C

Carlos J. Quintero [.NET MVP]

Take a look at the System.Windows.Forms.Screen class and methods.

The Screen.FromControl(form) returns the Screen of your form.

To set the position, you can try Form.SetDesktopLocation(x,y).

--

Best regards,

Carlos J. Quintero

MZ-Tools: Productivity add-ins for Visual Studio .NET, VB6, VB5 and VBA
You can code, design and document much faster.
Free resources for add-in developers:
http://www.mztools.com
 
Ö

Özden Irmak

Hello Carlos,

Thanks for the quick and valuable reply...

I have one more question :

To identify a screen, I think I need to use the Screen.DeviceName right? I'm
asking this as I'll somehow have to identify and store a value to identify a
screen...

Thanks in advance...

Regards,

Özden Irmak
 
C

Carlos J. Quintero [.NET MVP]

Yes, but you can also identify a screen but its Bounds or WorkingArea
properties.
--

Best regards,

Carlos J. Quintero

MZ-Tools: Productivity add-ins for Visual Studio .NET, VB6, VB5 and VBA
You can code, design and document much faster.
Free resources for add-in developers:
http://www.mztools.com
 
P

Peter D. Dunlap

Hello,

My appliccation saves form size and positions whenever they are closed so
they can be shown at the same size and position when opened next time.

My problem in here is that when it is used in Multiple screen enviornment, I
can't understand whether the window is in which screen and I also don't know
how to set the position of a window other than the primary screen?

Can anybody help me?

Regards,

Özden Irmak
I've got a dual monitor system, primary monitor on the right, and I
just save the left, top, width and height of a form. The left-hand
monitor has negative "left" values, but I don't really need to know
that if I'm just saving and restoring form positions.
 
P

Paul Cheetham

To check the number of displays configured use:

_iScreenCount = Screen.AllScreens.Length


This function will return the bounding rectangle for a screen:-

Public Function GetDisplayRect (Display As Integer) As Rectangle
'Get the display rectangle for the specified screen.
'** Note: function numbers displays from 1, although system numbers
from 0

Dim ScreenNo As Integer
Dim ScreenRect As Rectangle = Nothing

If (Display > 0 And Display <= _iScreenCount) Then
ScreenNo = Display - 1
ScreenRect = Screen.AllScreens(ScreenNo).Bounds
End If
Return (ScreenRect)
End Function



To save the position of a form just do it as normal, and it will be
positioned back on the same screen.
The above function is very useful if you need to force a form onto a
particular screen.


Paul
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top