Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Indentify Dual Monitors

Status
Not open for further replies.

Gnism

Technical User
Jan 9, 2003
29
0
0
US
Hello All,
In our dual monitor environment, I am having a difficult time trying to accomplish opening a form (Doc Viewer) on the opposite screen.

Currently I am able to open it on the right screen automatically using this code:

Dim myScreens() As screen = screen.AllScreens

If myScreens.Length = 2 Then
Dim screen As screen
'Send Doc Viewer Form to Second Monitor: Right Monitor = 1
Me.DesktopLocation = screen.AllScreens(1).Bounds.Location
screen = Windows.Forms.Screen.AllScreens(0)
Else
'Send Doc Viewer Form to Second Monitor: Left Monitor = 0
Me.DesktopLocation = screen.AllScreens(0).Bounds.Location
End If

If the user opens the app on the right screen I want the form to open on the left… My goal is to give the user the flexibility to have the main app on either monitor and have the (Doc Viewer) respond accordingly. Any insight would be greatly appreciated.

Thanks.

?
?

 
Have you tried writting code to identify which monitor the app is on? Either with some form of code similar to what you already have or else getting the position on the screen and the calculating which screen your on, by subtracting the width of the screen resolution.

-The answer to your problem may not be the answer to your question.
 
Qik3Coder, thanks for responding...I guess that is what I have been attempting to do. I've played around with .Primay & .PrimaryScreen and others but nothing has shown my desired results. Can you provide an example on the screen positioning? Maybe from there I'll be able to work something out...
 
i was thinking something along the lines of:

Dim intLength As int = Screen.Total Width
Dim intMyAppPos as int = Me.ScreenPosition.X
Dim intScreenResolution as int = intLength / 2

if intMyAppPos > intScreenResolution then
'right monitor
else
left monitor
end if

-The answer to your problem may not be the answer to your question.
 
Qik3Coder - Thanks again for trying to help me out.

After beating myself up I finally figured out what to do - here's my solution...

'Send Doc Viewer Form to Second Monitor: Left Monitor = 0, Right Monitor = 1
Dim myScreens() As screen = screen.AllScreens
Dim locRef As Integer 'Location Reference for the Review Screen

If myScreens.Length = 2 Then
'Start populating all the screens
Dim screen As screen

'Determine Review Screen location
locRef = frmReview.ActiveForm.Location.X()

'With two monitors Right Monitor begins @ 1100
If locRef > 1099 Then
'Send Doc Viewer to Left Monitor
Me.DesktopLocation = screen.AllScreens(0).Bounds.Location
Else
'Send Doc Viewer to Right Monitor
Me.DesktopLocation = screen.AllScreens(1).Bounds.Location
End If

'Hide Medical Panel
hideDocViewerMedicalPanel()
Else
Me.DesktopLocation = screen.AllScreens(0).Bounds.Location
End If
 
you might not want to hard code values for monitor resolution. You will probably want to get the screen resolution and set the position based on that.

-The answer to your problem may not be the answer to your question.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top