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

Dual Monitors in VB.NET - HELP!

P: n/a
I have been experimenting with the Screen object. It has a property
called Screen.DeviceName which returns a string value similar to the
following:

\\.\DISPLAY1 or \\.\DISPLAY2

I have 2 questions. When I assign the value to a class property and then
serialize that class using a SoapFormatter I get a bunch of garbage
characters after the name. Console.Writeline does not display these
characters, but it does show a " in front of the string but not at the end?

Secondly, I want my application to remember which monitor it was
displayed on, and in what location and size etc.

I have the size handled okay, and using SetDesktopBounds I can get it
back where it started, but cannot seem to figure out how to tell it
which monitor to use?

Any help would be appreciated.

Cheers,

Robert Porter
Nov 21 '05 #1
Share this Question
Share on Google+
9 Replies


P: n/a
Hi

First, I suggest you assign the DeviceName to a string first, and note the
length to see if it has redundant character, and then serialize the string
value direct to see if the problem persists.
Based on my test, it is shown correct in messagebox.

Second, for the monitor issue, I think we may use the DesktopLocation
property to set a position large than first desktop.
e.g. the first desktop is 1024*768, then we can set the DesktopLocation to
1100,100, then it will show on the second monitor.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 21 '05 #2

P: n/a
Peter Huang [MSFT] wrote:
Hi

First, I suggest you assign the DeviceName to a string first, and note the
length to see if it has redundant character, and then serialize the string
value direct to see if the problem persists.
Based on my test, it is shown correct in messagebox.

Second, for the monitor issue, I think we may use the DesktopLocation
property to set a position large than first desktop.
e.g. the first desktop is 1024*768, then we can set the DesktopLocation to
1100,100, then it will show on the second monitor.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Thank you for the reply, but I am not trying to make the screen larger
than one desktop, I want to be able to place the form on the secondary
monitor if it was last there, or the primary monitor if it was last
displayed there. My program always places the form on the primary
monitor and I would like to be able to override that.

I did assign the value to a string property first, and in MsgBox it
displays correctly. When serialized using the SoapFormatter it is when
it seems to acquire the extra garbage characters.

Any help would be appreciated.
Nov 21 '05 #3

P: n/a
Robert,
It sounds like Screen.DeviceName contains an embedded and/or trailing Null
Chars (ControlChars.NullChar).

Remember that ControlChars.NullChar is a valid System.String character,
however most Win32 APIs, including the VS.NET debugger, treat it as a string
terminator.

I would use either String.Trim or String.SubString to remove the trailing
ControlChars.NullChar.

Dim s As Screen
Dim deviceName As String

Dim length As Integer =
s.DeviceName.IndexOf(ControlChars.NullChar)
If length = -1 Then
deviceName = s.DeviceName
Else
deviceName = s.DeviceName.Substring(0, length)
End If

Hope this helps
Jay

"Robert Porter" <rh******@noemail.nospam> wrote in message
news:e%*****************@TK2MSFTNGP10.phx.gbl...
|I have been experimenting with the Screen object. It has a property
| called Screen.DeviceName which returns a string value similar to the
| following:
|
| \\.\DISPLAY1 or \\.\DISPLAY2
|
| I have 2 questions. When I assign the value to a class property and then
| serialize that class using a SoapFormatter I get a bunch of garbage
| characters after the name. Console.Writeline does not display these
| characters, but it does show a " in front of the string but not at the
end?
|
| Secondly, I want my application to remember which monitor it was
| displayed on, and in what location and size etc.
|
| I have the size handled okay, and using SetDesktopBounds I can get it
| back where it started, but cannot seem to figure out how to tell it
| which monitor to use?
|
| Any help would be appreciated.
|
| Cheers,
|
| Robert Porter
Nov 21 '05 #4

P: n/a
That was perfect! Worked for me... Many thanks! Now you would not happen
to know how I can tell a form to appear, other than maximized, on a
screen other than the primary display would you?

Cheers,

Bob Porter

Jay B. Harlow [MVP - Outlook] wrote:
Robert,
It sounds like Screen.DeviceName contains an embedded and/or trailing Null
Chars (ControlChars.NullChar).

Remember that ControlChars.NullChar is a valid System.String character,
however most Win32 APIs, including the VS.NET debugger, treat it as a string
terminator.

I would use either String.Trim or String.SubString to remove the trailing
ControlChars.NullChar.

Dim s As Screen
Dim deviceName As String

Dim length As Integer =
s.DeviceName.IndexOf(ControlChars.NullChar)
If length = -1 Then
deviceName = s.DeviceName
Else
deviceName = s.DeviceName.Substring(0, length)
End If

Hope this helps
Jay

"Robert Porter" <rh******@noemail.nospam> wrote in message
news:e%*****************@TK2MSFTNGP10.phx.gbl...
|I have been experimenting with the Screen object. It has a property
| called Screen.DeviceName which returns a string value similar to the
| following:
|
| \\.\DISPLAY1 or \\.\DISPLAY2
|
| I have 2 questions. When I assign the value to a class property and then
| serialize that class using a SoapFormatter I get a bunch of garbage
| characters after the name. Console.Writeline does not display these
| characters, but it does show a " in front of the string but not at the
end?
|
| Secondly, I want my application to remember which monitor it was
| displayed on, and in what location and size etc.
|
| I have the size handled okay, and using SetDesktopBounds I can get it
| back where it started, but cannot seem to figure out how to tell it
| which monitor to use?
|
| Any help would be appreciated.
|
| Cheers,
|
| Robert Porter

Nov 21 '05 #5

P: n/a
Robert,
I normally set the bounds of the form to the bounds of the Screen (monitor)
that I want the form to appear on.

Something like:

Protected Overrides Sub OnLoad(ByVal e As System.EventArgs)
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

Will cause the form to appear "full screen" on the first secondary monitor
if one is present.

You should be able to use Rectangle.Location & Rectangle.Offset to adjust
the bounds before you set them if you don't want a "full screen" window.
Post if you need help with offsetting the bounds.

Hope this helps
Jay

"Robert Porter" <rh******@noemail.nospam> wrote in message
news:O9*************@TK2MSFTNGP12.phx.gbl...
| That was perfect! Worked for me... Many thanks! Now you would not happen
| to know how I can tell a form to appear, other than maximized, on a
| screen other than the primary display would you?
|
| Cheers,
|
| Bob Porter
|
| Jay B. Harlow [MVP - Outlook] wrote:
| > Robert,
| > It sounds like Screen.DeviceName contains an embedded and/or trailing
Null
| > Chars (ControlChars.NullChar).
| >
| > Remember that ControlChars.NullChar is a valid System.String character,
| > however most Win32 APIs, including the VS.NET debugger, treat it as a
string
| > terminator.
| >
| > I would use either String.Trim or String.SubString to remove the
trailing
| > ControlChars.NullChar.
| >
| > Dim s As Screen
| > Dim deviceName As String
| >
| > Dim length As Integer =
| > s.DeviceName.IndexOf(ControlChars.NullChar)
| > If length = -1 Then
| > deviceName = s.DeviceName
| > Else
| > deviceName = s.DeviceName.Substring(0, length)
| > End If
| >
| > Hope this helps
| > Jay
| >
| > "Robert Porter" <rh******@noemail.nospam> wrote in message
| > news:e%*****************@TK2MSFTNGP10.phx.gbl...
| > |I have been experimenting with the Screen object. It has a property
| > | called Screen.DeviceName which returns a string value similar to the
| > | following:
| > |
| > | \\.\DISPLAY1 or \\.\DISPLAY2
| > |
| > | I have 2 questions. When I assign the value to a class property and
then
| > | serialize that class using a SoapFormatter I get a bunch of garbage
| > | characters after the name. Console.Writeline does not display these
| > | characters, but it does show a " in front of the string but not at the
| > end?
| > |
| > | Secondly, I want my application to remember which monitor it was
| > | displayed on, and in what location and size etc.
| > |
| > | I have the size handled okay, and using SetDesktopBounds I can get it
| > | back where it started, but cannot seem to figure out how to tell it
| > | which monitor to use?
| > |
| > | Any help would be appreciated.
| > |
| > | Cheers,
| > |
| > | Robert Porter
| >
| >
Nov 21 '05 #6

P: n/a
The bounds bit works... but it slams the window to full screen. I sure
could use some help offsetting the bounds.

I have been playing with saving the height, top and left, then trying to
dynamically resize the form on the secondary monitor as far as width
goes, but I somehow always end up with it full screen, here is the code
I have so far.

If oLUConfig.HasBeenConfigured Then
Me.Height = oLUConfig.IRHeight
Me.Width = oLUConfig.IRWidth
Me.Left = oLUConfig.IRLeft
Me.Top = oLUConfig.IRTop
If CheckForMultipleMonitors() AndAlso
(oLUConfig.IRScreenDeviceName <> "") Then
Dim s As Screen
Dim bFound As Boolean = False
Dim sName As String

For Each s In Screen.AllScreens
sName =oUtility.StripControlCharacters(s.DeviceName)
If sName = oLUConfig.IRScreenDeviceName Then
Me.SetDesktopBounds(Me.Left, Me.Top, Me.Width,
Me.Height)
bFound = True
me.bounds = s.bounds
me.setdesktopbounds(oluconfig.IRLeft, oluconfig.IRTop,
oluconfig.IRWidth, oluconfig.IRHeight)
Exit For
End If
Next
If Not bFound Then
Me.Bounds = Screen.PrimaryScreen.Bounds
End If
Else
Me.Bounds = Screen.PrimaryScreen.Bounds
End If
Else
Me.Height = 256
Me.Width = Screen.PrimaryScreen.WorkingArea.Width
Me.Top = iScreenHeight - Me.Height
Me.Left = Screen.PrimaryScreen.WorkingArea.Left
Me.SetDesktopBounds(Me.Left, Me.Top, Me.Width, Me.Height)
End If
Jay B. Harlow [MVP - Outlook] wrote:
Robert,
I normally set the bounds of the form to the bounds of the Screen (monitor)
that I want the form to appear on.

Something like:

Protected Overrides Sub OnLoad(ByVal e As System.EventArgs)
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

Will cause the form to appear "full screen" on the first secondary monitor
if one is present.

You should be able to use Rectangle.Location & Rectangle.Offset to adjust
the bounds before you set them if you don't want a "full screen" window.
Post if you need help with offsetting the bounds.

Hope this helps
Jay

"Robert Porter" <rh******@noemail.nospam> wrote in message
news:O9*************@TK2MSFTNGP12.phx.gbl...
| That was perfect! Worked for me... Many thanks! Now you would not happen
| to know how I can tell a form to appear, other than maximized, on a
| screen other than the primary display would you?
|
| Cheers,
|
| Bob Porter
|
| Jay B. Harlow [MVP - Outlook] wrote:
| > Robert,
| > It sounds like Screen.DeviceName contains an embedded and/or trailing
Null
| > Chars (ControlChars.NullChar).
| >
| > Remember that ControlChars.NullChar is a valid System.String character,
| > however most Win32 APIs, including the VS.NET debugger, treat it as a
string
| > terminator.
| >
| > I would use either String.Trim or String.SubString to remove the
trailing
| > ControlChars.NullChar.
| >
| > Dim s As Screen
| > Dim deviceName As String
| >
| > Dim length As Integer =
| > s.DeviceName.IndexOf(ControlChars.NullChar)
| > If length = -1 Then
| > deviceName = s.DeviceName
| > Else
| > deviceName = s.DeviceName.Substring(0, length)
| > End If
| >
| > Hope this helps
| > Jay
| >
| > "Robert Porter" <rh******@noemail.nospam> wrote in message
| > news:e%*****************@TK2MSFTNGP10.phx.gbl...
| > |I have been experimenting with the Screen object. It has a property
| > | called Screen.DeviceName which returns a string value similar to the
| > | following:
| > |
| > | \\.\DISPLAY1 or \\.\DISPLAY2
| > |
| > | I have 2 questions. When I assign the value to a class property and
then
| > | serialize that class using a SoapFormatter I get a bunch of garbage
| > | characters after the name. Console.Writeline does not display these
| > | characters, but it does show a " in front of the string but not at the
| > end?
| > |
| > | Secondly, I want my application to remember which monitor it was
| > | displayed on, and in what location and size etc.
| > |
| > | I have the size handled okay, and using SetDesktopBounds I can get it
| > | back where it started, but cannot seem to figure out how to tell it
| > | which monitor to use?
| > |
| > | Any help would be appreciated.
| > |
| > | Cheers,
| > |
| > | Robert Porter
| >
| >

Nov 21 '05 #7

P: n/a
Robert,
You should only set the Form.Bounds to Screen.Bounds if you want Full
Screen.

Seeing as you have a position in mind, I would simply set the Form.Location
to the Saved.Location + Screen.Bounds.Location.

Something like:

Protected Overrides Sub OnLoad(ByVal e As EventArgs)
MyBase.OnLoad(e)
Dim secondaryScreen As Screen

' look up the secondaryScreen
For Each secondaryScreen In Screen.AllScreens
If Not secondaryScreen.Primary Then Exit For
Next

' Use the primary screen if there is no secondary screen
If secondaryScreen Is Nothing Then secondaryScreen =
Screen.PrimaryScreen

' Move the form to the secondary screen

' use the forms current location
Dim location As Point = Me.Location
' or you could use the saved location
Dim location As New Point(oLUConfig.IRLeft, oLUConfig.IRTop)

location.Offset(secondaryScreen.Bounds.X, secondaryScreen.Bounds.Y)

Me.Location = location

' Assumes the size is already set...

End Sub
Hope this helps
Jay
"Robert Porter" <rh******@noemail.nospam> wrote in message
news:e0**************@tk2msftngp13.phx.gbl...
| The bounds bit works... but it slams the window to full screen. I sure
| could use some help offsetting the bounds.
|
| I have been playing with saving the height, top and left, then trying to
| dynamically resize the form on the secondary monitor as far as width
| goes, but I somehow always end up with it full screen, here is the code
| I have so far.
|
| If oLUConfig.HasBeenConfigured Then
| Me.Height = oLUConfig.IRHeight
| Me.Width = oLUConfig.IRWidth
| Me.Left = oLUConfig.IRLeft
| Me.Top = oLUConfig.IRTop
| If CheckForMultipleMonitors() AndAlso
| (oLUConfig.IRScreenDeviceName <> "") Then
| Dim s As Screen
| Dim bFound As Boolean = False
| Dim sName As String
|
| For Each s In Screen.AllScreens
| sName =oUtility.StripControlCharacters(s.DeviceName)
| If sName = oLUConfig.IRScreenDeviceName Then
| Me.SetDesktopBounds(Me.Left, Me.Top, Me.Width,
| Me.Height)
| bFound = True
| me.bounds = s.bounds
| me.setdesktopbounds(oluconfig.IRLeft, oluconfig.IRTop,
| oluconfig.IRWidth, oluconfig.IRHeight)
| Exit For
| End If
| Next
| If Not bFound Then
| Me.Bounds = Screen.PrimaryScreen.Bounds
| End If
| Else
| Me.Bounds = Screen.PrimaryScreen.Bounds
| End If
| Else
| Me.Height = 256
| Me.Width = Screen.PrimaryScreen.WorkingArea.Width
| Me.Top = iScreenHeight - Me.Height
| Me.Left = Screen.PrimaryScreen.WorkingArea.Left
| Me.SetDesktopBounds(Me.Left, Me.Top, Me.Width, Me.Height)
| End If
|
|
| Jay B. Harlow [MVP - Outlook] wrote:
| > Robert,
| > I normally set the bounds of the form to the bounds of the Screen
(monitor)
| > that I want the form to appear on.
| >
| > Something like:
| >
| > Protected Overrides Sub OnLoad(ByVal e As System.EventArgs)
| > 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
| >
| > Will cause the form to appear "full screen" on the first secondary
monitor
| > if one is present.
| >
| > You should be able to use Rectangle.Location & Rectangle.Offset to
adjust
| > the bounds before you set them if you don't want a "full screen" window.
| > Post if you need help with offsetting the bounds.
| >
| > Hope this helps
| > Jay
| >
| > "Robert Porter" <rh******@noemail.nospam> wrote in message
| > news:O9*************@TK2MSFTNGP12.phx.gbl...
| > | That was perfect! Worked for me... Many thanks! Now you would not
happen
| > | to know how I can tell a form to appear, other than maximized, on a
| > | screen other than the primary display would you?
| > |
| > | Cheers,
| > |
| > | Bob Porter
| > |
| > | Jay B. Harlow [MVP - Outlook] wrote:
| > | > Robert,
| > | > It sounds like Screen.DeviceName contains an embedded and/or
trailing
| > Null
| > | > Chars (ControlChars.NullChar).
| > | >
| > | > Remember that ControlChars.NullChar is a valid System.String
character,
| > | > however most Win32 APIs, including the VS.NET debugger, treat it as
a
| > string
| > | > terminator.
| > | >
| > | > I would use either String.Trim or String.SubString to remove the
| > trailing
| > | > ControlChars.NullChar.
| > | >
| > | > Dim s As Screen
| > | > Dim deviceName As String
| > | >
| > | > Dim length As Integer =
| > | > s.DeviceName.IndexOf(ControlChars.NullChar)
| > | > If length = -1 Then
| > | > deviceName = s.DeviceName
| > | > Else
| > | > deviceName = s.DeviceName.Substring(0, length)
| > | > End If
| > | >
| > | > Hope this helps
| > | > Jay
| > | >
| > | > "Robert Porter" <rh******@noemail.nospam> wrote in message
| > | > news:e%*****************@TK2MSFTNGP10.phx.gbl...
| > | > |I have been experimenting with the Screen object. It has a property
| > | > | called Screen.DeviceName which returns a string value similar to
the
| > | > | following:
| > | > |
| > | > | \\.\DISPLAY1 or \\.\DISPLAY2
| > | > |
| > | > | I have 2 questions. When I assign the value to a class property
and
| > then
| > | > | serialize that class using a SoapFormatter I get a bunch of
garbage
| > | > | characters after the name. Console.Writeline does not display
these
| > | > | characters, but it does show a " in front of the string but not at
the
| > | > end?
| > | > |
| > | > | Secondly, I want my application to remember which monitor it was
| > | > | displayed on, and in what location and size etc.
| > | > |
| > | > | I have the size handled okay, and using SetDesktopBounds I can get
it
| > | > | back where it started, but cannot seem to figure out how to tell
it
| > | > | which monitor to use?
| > | > |
| > | > | Any help would be appreciated.
| > | > |
| > | > | Cheers,
| > | > |
| > | > | Robert Porter
| > | >
| > | >
| >
| >
Nov 21 '05 #8

P: n/a
Excellent! That's what I needed, I had not looked at location.offset
before. Thanks very much for your continued help.

Cheers,

Bob

Jay B. Harlow [MVP - Outlook] wrote:
Robert,
You should only set the Form.Bounds to Screen.Bounds if you want Full
Screen.

Seeing as you have a position in mind, I would simply set the Form.Location
to the Saved.Location + Screen.Bounds.Location.

Something like:

Protected Overrides Sub OnLoad(ByVal e As EventArgs)
MyBase.OnLoad(e)
Dim secondaryScreen As Screen

' look up the secondaryScreen
For Each secondaryScreen In Screen.AllScreens
If Not secondaryScreen.Primary Then Exit For
Next

' Use the primary screen if there is no secondary screen
If secondaryScreen Is Nothing Then secondaryScreen =
Screen.PrimaryScreen

' Move the form to the secondary screen

' use the forms current location
Dim location As Point = Me.Location
' or you could use the saved location
Dim location As New Point(oLUConfig.IRLeft, oLUConfig.IRTop)

location.Offset(secondaryScreen.Bounds.X, secondaryScreen.Bounds.Y)

Me.Location = location

' Assumes the size is already set...

End Sub
Hope this helps
Jay
"Robert Porter" <rh******@noemail.nospam> wrote in message
news:e0**************@tk2msftngp13.phx.gbl...
| The bounds bit works... but it slams the window to full screen. I sure
| could use some help offsetting the bounds.
|
| I have been playing with saving the height, top and left, then trying to
| dynamically resize the form on the secondary monitor as far as width
| goes, but I somehow always end up with it full screen, here is the code
| I have so far.
|
| If oLUConfig.HasBeenConfigured Then
| Me.Height = oLUConfig.IRHeight
| Me.Width = oLUConfig.IRWidth
| Me.Left = oLUConfig.IRLeft
| Me.Top = oLUConfig.IRTop
| If CheckForMultipleMonitors() AndAlso
| (oLUConfig.IRScreenDeviceName <> "") Then
| Dim s As Screen
| Dim bFound As Boolean = False
| Dim sName As String
|
| For Each s In Screen.AllScreens
| sName =oUtility.StripControlCharacters(s.DeviceName)
| If sName = oLUConfig.IRScreenDeviceName Then
| Me.SetDesktopBounds(Me.Left, Me.Top, Me.Width,
| Me.Height)
| bFound = True
| me.bounds = s.bounds
| me.setdesktopbounds(oluconfig.IRLeft, oluconfig.IRTop,
| oluconfig.IRWidth, oluconfig.IRHeight)
| Exit For
| End If
| Next
| If Not bFound Then
| Me.Bounds = Screen.PrimaryScreen.Bounds
| End If
| Else
| Me.Bounds = Screen.PrimaryScreen.Bounds
| End If
| Else
| Me.Height = 256
| Me.Width = Screen.PrimaryScreen.WorkingArea.Width
| Me.Top = iScreenHeight - Me.Height
| Me.Left = Screen.PrimaryScreen.WorkingArea.Left
| Me.SetDesktopBounds(Me.Left, Me.Top, Me.Width, Me.Height)
| End If
|
|
| Jay B. Harlow [MVP - Outlook] wrote:
| > Robert,
| > I normally set the bounds of the form to the bounds of the Screen
(monitor)
| > that I want the form to appear on.
| >
| > Something like:
| >
| > Protected Overrides Sub OnLoad(ByVal e As System.EventArgs)
| > 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
| >
| > Will cause the form to appear "full screen" on the first secondary
monitor
| > if one is present.
| >
| > You should be able to use Rectangle.Location & Rectangle.Offset to
adjust
| > the bounds before you set them if you don't want a "full screen" window.
| > Post if you need help with offsetting the bounds.
| >
| > Hope this helps
| > Jay
| >
| > "Robert Porter" <rh******@noemail.nospam> wrote in message
| > news:O9*************@TK2MSFTNGP12.phx.gbl...
| > | That was perfect! Worked for me... Many thanks! Now you would not
happen
| > | to know how I can tell a form to appear, other than maximized, on a
| > | screen other than the primary display would you?
| > |
| > | Cheers,
| > |
| > | Bob Porter
| > |
| > | Jay B. Harlow [MVP - Outlook] wrote:
| > | > Robert,
| > | > It sounds like Screen.DeviceName contains an embedded and/or
trailing
| > Null
| > | > Chars (ControlChars.NullChar).
| > | >
| > | > Remember that ControlChars.NullChar is a valid System.String
character,
| > | > however most Win32 APIs, including the VS.NET debugger, treat it as
a
| > string
| > | > terminator.
| > | >
| > | > I would use either String.Trim or String.SubString to remove the
| > trailing
| > | > ControlChars.NullChar.
| > | >
| > | > Dim s As Screen
| > | > Dim deviceName As String
| > | >
| > | > Dim length As Integer =
| > | > s.DeviceName.IndexOf(ControlChars.NullChar)
| > | > If length = -1 Then
| > | > deviceName = s.DeviceName
| > | > Else
| > | > deviceName = s.DeviceName.Substring(0, length)
| > | > End If
| > | >
| > | > Hope this helps
| > | > Jay
| > | >
| > | > "Robert Porter" <rh******@noemail.nospam> wrote in message
| > | > news:e%*****************@TK2MSFTNGP10.phx.gbl...
| > | > |I have been experimenting with the Screen object. It has a property
| > | > | called Screen.DeviceName which returns a string value similar to
the
| > | > | following:
| > | > |
| > | > | \\.\DISPLAY1 or \\.\DISPLAY2
| > | > |
| > | > | I have 2 questions. When I assign the value to a class property
and
| > then
| > | > | serialize that class using a SoapFormatter I get a bunch of
garbage
| > | > | characters after the name. Console.Writeline does not display
these
| > | > | characters, but it does show a " in front of the string but not at
the
| > | > end?
| > | > |
| > | > | Secondly, I want my application to remember which monitor it was
| > | > | displayed on, and in what location and size etc.
| > | > |
| > | > | I have the size handled okay, and using SetDesktopBounds I can get
it
| > | > | back where it started, but cannot seem to figure out how to tell
it
| > | > | which monitor to use?
| > | > |
| > | > | Any help would be appreciated.
| > | > |
| > | > | Cheers,
| > | > |
| > | > | Robert Porter
| > | >
| > | >
| >
| >

Nov 21 '05 #9

P: n/a
Hi all,

Thanks for you Jay's elegant contribution in the community.
All will benefit from your suggestion. :)
Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 21 '05 #10

This discussion thread is closed

Replies have been disabled for this discussion.