473,785 Members | 2,768 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Dual Monitors in VB.NET - HELP!

I have been experimenting with the Screen object. It has a property
called Screen.DeviceNa me 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.Writeli ne 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 SetDesktopBound s 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
9 15763
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
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
Robert,
It sounds like Screen.DeviceNa me contains an embedded and/or trailing Null
Chars (ControlChars.N ullChar).

Remember that ControlChars.Nu llChar 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.SubStrin g to remove the trailing
ControlChars.Nu llChar.

Dim s As Screen
Dim deviceName As String

Dim length As Integer =
s.DeviceName.In dexOf(ControlCh ars.NullChar)
If length = -1 Then
deviceName = s.DeviceName
Else
deviceName = s.DeviceName.Su bstring(0, length)
End If

Hope this helps
Jay

"Robert Porter" <rh******@noema il.nospam> wrote in message
news:e%******** *********@TK2MS FTNGP10.phx.gbl ...
|I have been experimenting with the Screen object. It has a property
| called Screen.DeviceNa me 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.Writeli ne 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 SetDesktopBound s 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
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.DeviceNa me contains an embedded and/or trailing Null
Chars (ControlChars.N ullChar).

Remember that ControlChars.Nu llChar 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.SubStrin g to remove the trailing
ControlChars.Nu llChar.

Dim s As Screen
Dim deviceName As String

Dim length As Integer =
s.DeviceName.In dexOf(ControlCh ars.NullChar)
If length = -1 Then
deviceName = s.DeviceName
Else
deviceName = s.DeviceName.Su bstring(0, length)
End If

Hope this helps
Jay

"Robert Porter" <rh******@noema il.nospam> wrote in message
news:e%******** *********@TK2MS FTNGP10.phx.gbl ...
|I have been experimenting with the Screen object. It has a property
| called Screen.DeviceNa me 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.Writeli ne 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 SetDesktopBound s 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
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.EventArg s)
Dim s As Screen
For Each s In Screen.AllScree ns
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.Locat ion & Rectangle.Offse t 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******@noema il.nospam> wrote in message
news:O9******** *****@TK2MSFTNG P12.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.DeviceNa me contains an embedded and/or trailing
Null
| > Chars (ControlChars.N ullChar).
| >
| > Remember that ControlChars.Nu llChar 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.SubStrin g to remove the
trailing
| > ControlChars.Nu llChar.
| >
| > Dim s As Screen
| > Dim deviceName As String
| >
| > Dim length As Integer =
| > s.DeviceName.In dexOf(ControlCh ars.NullChar)
| > If length = -1 Then
| > deviceName = s.DeviceName
| > Else
| > deviceName = s.DeviceName.Su bstring(0, length)
| > End If
| >
| > Hope this helps
| > Jay
| >
| > "Robert Porter" <rh******@noema il.nospam> wrote in message
| > news:e%******** *********@TK2MS FTNGP10.phx.gbl ...
| > |I have been experimenting with the Screen object. It has a property
| > | called Screen.DeviceNa me 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.Writeli ne 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 SetDesktopBound s 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
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.HasBe enConfigured Then
Me.Height = oLUConfig.IRHei ght
Me.Width = oLUConfig.IRWid th
Me.Left = oLUConfig.IRLef t
Me.Top = oLUConfig.IRTop
If CheckForMultipl eMonitors() AndAlso
(oLUConfig.IRSc reenDeviceName <> "") Then
Dim s As Screen
Dim bFound As Boolean = False
Dim sName As String

For Each s In Screen.AllScree ns
sName =oUtility.Strip ControlCharacte rs(s.DeviceName )
If sName = oLUConfig.IRScr eenDeviceName Then
Me.SetDesktopBo unds(Me.Left, Me.Top, Me.Width,
Me.Height)
bFound = True
me.bounds = s.bounds
me.setdesktopbo unds(oluconfig. IRLeft, oluconfig.IRTop ,
oluconfig.IRWid th, oluconfig.IRHei ght)
Exit For
End If
Next
If Not bFound Then
Me.Bounds = Screen.PrimaryS creen.Bounds
End If
Else
Me.Bounds = Screen.PrimaryS creen.Bounds
End If
Else
Me.Height = 256
Me.Width = Screen.PrimaryS creen.WorkingAr ea.Width
Me.Top = iScreenHeight - Me.Height
Me.Left = Screen.PrimaryS creen.WorkingAr ea.Left
Me.SetDesktopBo unds(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.EventArg s)
Dim s As Screen
For Each s In Screen.AllScree ns
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.Locat ion & Rectangle.Offse t 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******@noema il.nospam> wrote in message
news:O9******** *****@TK2MSFTNG P12.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.DeviceNa me contains an embedded and/or trailing
Null
| > Chars (ControlChars.N ullChar).
| >
| > Remember that ControlChars.Nu llChar 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.SubStrin g to remove the
trailing
| > ControlChars.Nu llChar.
| >
| > Dim s As Screen
| > Dim deviceName As String
| >
| > Dim length As Integer =
| > s.DeviceName.In dexOf(ControlCh ars.NullChar)
| > If length = -1 Then
| > deviceName = s.DeviceName
| > Else
| > deviceName = s.DeviceName.Su bstring(0, length)
| > End If
| >
| > Hope this helps
| > Jay
| >
| > "Robert Porter" <rh******@noema il.nospam> wrote in message
| > news:e%******** *********@TK2MS FTNGP10.phx.gbl ...
| > |I have been experimenting with the Screen object. It has a property
| > | called Screen.DeviceNa me 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.Writeli ne 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 SetDesktopBound s 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
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.L ocation.

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.AllScree ns
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.PrimaryS creen

' 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 (secondaryScree n.Bounds.X, secondaryScreen .Bounds.Y)

Me.Location = location

' Assumes the size is already set...

End Sub
Hope this helps
Jay
"Robert Porter" <rh******@noema il.nospam> wrote in message
news:e0******** ******@tk2msftn gp13.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.HasBe enConfigured Then
| Me.Height = oLUConfig.IRHei ght
| Me.Width = oLUConfig.IRWid th
| Me.Left = oLUConfig.IRLef t
| Me.Top = oLUConfig.IRTop
| If CheckForMultipl eMonitors() AndAlso
| (oLUConfig.IRSc reenDeviceName <> "") Then
| Dim s As Screen
| Dim bFound As Boolean = False
| Dim sName As String
|
| For Each s In Screen.AllScree ns
| sName =oUtility.Strip ControlCharacte rs(s.DeviceName )
| If sName = oLUConfig.IRScr eenDeviceName Then
| Me.SetDesktopBo unds(Me.Left, Me.Top, Me.Width,
| Me.Height)
| bFound = True
| me.bounds = s.bounds
| me.setdesktopbo unds(oluconfig. IRLeft, oluconfig.IRTop ,
| oluconfig.IRWid th, oluconfig.IRHei ght)
| Exit For
| End If
| Next
| If Not bFound Then
| Me.Bounds = Screen.PrimaryS creen.Bounds
| End If
| Else
| Me.Bounds = Screen.PrimaryS creen.Bounds
| End If
| Else
| Me.Height = 256
| Me.Width = Screen.PrimaryS creen.WorkingAr ea.Width
| Me.Top = iScreenHeight - Me.Height
| Me.Left = Screen.PrimaryS creen.WorkingAr ea.Left
| Me.SetDesktopBo unds(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.EventArg s)
| > Dim s As Screen
| > For Each s In Screen.AllScree ns
| > 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.Locat ion & Rectangle.Offse t 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******@noema il.nospam> wrote in message
| > news:O9******** *****@TK2MSFTNG P12.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.DeviceNa me contains an embedded and/or
trailing
| > Null
| > | > Chars (ControlChars.N ullChar).
| > | >
| > | > Remember that ControlChars.Nu llChar 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.SubStrin g to remove the
| > trailing
| > | > ControlChars.Nu llChar.
| > | >
| > | > Dim s As Screen
| > | > Dim deviceName As String
| > | >
| > | > Dim length As Integer =
| > | > s.DeviceName.In dexOf(ControlCh ars.NullChar)
| > | > If length = -1 Then
| > | > deviceName = s.DeviceName
| > | > Else
| > | > deviceName = s.DeviceName.Su bstring(0, length)
| > | > End If
| > | >
| > | > Hope this helps
| > | > Jay
| > | >
| > | > "Robert Porter" <rh******@noema il.nospam> wrote in message
| > | > news:e%******** *********@TK2MS FTNGP10.phx.gbl ...
| > | > |I have been experimenting with the Screen object. It has a property
| > | > | called Screen.DeviceNa me 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.Writeli ne 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 SetDesktopBound s 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
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.L ocation.

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.AllScree ns
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.PrimaryS creen

' 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 (secondaryScree n.Bounds.X, secondaryScreen .Bounds.Y)

Me.Location = location

' Assumes the size is already set...

End Sub
Hope this helps
Jay
"Robert Porter" <rh******@noema il.nospam> wrote in message
news:e0******** ******@tk2msftn gp13.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.HasBe enConfigured Then
| Me.Height = oLUConfig.IRHei ght
| Me.Width = oLUConfig.IRWid th
| Me.Left = oLUConfig.IRLef t
| Me.Top = oLUConfig.IRTop
| If CheckForMultipl eMonitors() AndAlso
| (oLUConfig.IRSc reenDeviceName <> "") Then
| Dim s As Screen
| Dim bFound As Boolean = False
| Dim sName As String
|
| For Each s In Screen.AllScree ns
| sName =oUtility.Strip ControlCharacte rs(s.DeviceName )
| If sName = oLUConfig.IRScr eenDeviceName Then
| Me.SetDesktopBo unds(Me.Left, Me.Top, Me.Width,
| Me.Height)
| bFound = True
| me.bounds = s.bounds
| me.setdesktopbo unds(oluconfig. IRLeft, oluconfig.IRTop ,
| oluconfig.IRWid th, oluconfig.IRHei ght)
| Exit For
| End If
| Next
| If Not bFound Then
| Me.Bounds = Screen.PrimaryS creen.Bounds
| End If
| Else
| Me.Bounds = Screen.PrimaryS creen.Bounds
| End If
| Else
| Me.Height = 256
| Me.Width = Screen.PrimaryS creen.WorkingAr ea.Width
| Me.Top = iScreenHeight - Me.Height
| Me.Left = Screen.PrimaryS creen.WorkingAr ea.Left
| Me.SetDesktopBo unds(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.EventArg s)
| > Dim s As Screen
| > For Each s In Screen.AllScree ns
| > 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.Locat ion & Rectangle.Offse t 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******@noema il.nospam> wrote in message
| > news:O9******** *****@TK2MSFTNG P12.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.DeviceNa me contains an embedded and/or
trailing
| > Null
| > | > Chars (ControlChars.N ullChar).
| > | >
| > | > Remember that ControlChars.Nu llChar 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.SubStrin g to remove the
| > trailing
| > | > ControlChars.Nu llChar.
| > | >
| > | > Dim s As Screen
| > | > Dim deviceName As String
| > | >
| > | > Dim length As Integer =
| > | > s.DeviceName.In dexOf(ControlCh ars.NullChar)
| > | > If length = -1 Then
| > | > deviceName = s.DeviceName
| > | > Else
| > | > deviceName = s.DeviceName.Su bstring(0, length)
| > | > End If
| > | >
| > | > Hope this helps
| > | > Jay
| > | >
| > | > "Robert Porter" <rh******@noema il.nospam> wrote in message
| > | > news:e%******** *********@TK2MS FTNGP10.phx.gbl ...
| > | > |I have been experimenting with the Screen object. It has a property
| > | > | called Screen.DeviceNa me 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.Writeli ne 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 SetDesktopBound s 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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
30453
by: KJM | last post by:
How can I detect if the user has dual monitors and then how do I control which monitor a form is displayed on. Currently my forms always come up on my right monitor. What if I want to have it always display on my left one? Thanks Ken
0
1069
by: Mingle | last post by:
Hi, all I am developing a program for displaying two pictures separately in two monitors ( A and B). The goal is: when the mouse pointer is pointed to a picture loaded in picturebox1 in A, a "virtual" mouse pointer is drawn at the same location in picturebox2 in B. The program works well for two monitors with the same size (note: NOT the same resolution), even when I set two different resolutions for them, the mouse pointer locations in the...
3
3629
by: Frank Rizzo | last post by:
Is there anyway to be able to split vs.net between 2 monitors? For instance, on one monitor, I'd like to have the form in design mode, while the other monitor would have the code for the form. Or at least be able to split a code window between 2 monitors. Is this even possible? Thanks.
2
1795
by: Strah | last post by:
Is there a way to determine whether a computer is connected to dual monitors with VB.NET code? Thanks, Strah
3
7690
by: fournij | last post by:
Hi I'm writing a MFC C++ application using Visual .NET. I'm using a Dual Head video card with 2 monitors. I want to start my application in the first monitor but open a dialog box in the second monitor. I tried to set the X position of the dialog box greather thant the first screen resolution, but the dialog box still appear on the first monitor. Can you help me ?
0
1346
by: Neji | last post by:
Is there a way to make a keyboard shortcut to change the mouse focus between dual monitors? For example, if I'm on the left-hand screen, would be able to hit a button combination that would change the mouse focus to the right-hand monitor? It seems like I waste a large amount of time moving the mouse between monitors, so it would be great if I could switch the mouse focus with the keyboard. VB appears to have MouseFocus functionality,...
0
1276
by: Neji | last post by:
Is it possible to switch between dual monitors with the keyboard? For example, if I am on the left-hand monitor, can I press a keyboard combination to teleport the mouse cursor to the middle of the right-hand monitor? And if I am on the right-hand monitor, can I press a keyboard combination to teleport the mouse cursor to the middle of the left-hand monitor? Is this something that can be done in .NET and/or VB?
8
6111
by: Sheldon | last post by:
I just received a 2nd (configured as a dual) monitor but, for Access only, I can't seem to figure out, if it's possible, to view, say, Table1 on one monitor and Table2 on the other monitor. If I open Table1, then Table2, Table2 apparently sits directly over Table1 and seems anchored so that I cannot move it "out of the way". Is this bahavior a restriction with Access as I do not have this problem with Excel or Word? Sheldon Potolsky
2
6071
by: Cindy | last post by:
I've been using dual monitors for about a year now (absolutely love it), but have run into a weird situation with Access 2000 lately. I loaded a database on two PC's that do NOT have dual monitors, and when I try to open 2 different forms from this database, it looks/feels like nothing is happening. If I look in the window list, the form IS open, but the user can't get to it. I open the same database at home on my two monitors, and the...
3
4763
by: kssnatha | last post by:
Hi, I have a issue when i open a popup in dual monitors. I opened a popup from my page using windows.open() method. During popup loading i used both moveTo and resizeTo methods. Its working fine with single monitor. But when working with two monitors only one half (vertical) of the popup is displayed. Its a complete popup with close,minimize buttons. Its in IE 6. Your help is appreciated. Regards,
0
9645
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10148
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10091
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9950
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8972
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5381
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4053
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.