|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Arranging window screens on multi-monitor DesktopI need to arrange window screens on the total area of a mulitple-mopnitor desktop. As an example, below is the bound info for my 2-monitor PC: Device Name: \\.\DISPLAY1 Bounds: {X=1152,Y=0,Width=1152,Height=864} Primary Screen: False Device Name: \\.\DISPLAY2 Bounds: {X=0,Y=0,Width=1152,Height=864} Primary Screen: True Now I need to display a form on Display1 and another form on Display2 I don't know if this is possible using .NET or not. Any help is greatly appreciated. Bill See the Screen class at:
http://msdn2.microsoft.com/en-us/library/system.windows.forms.screen.aspx Note the AllScreens property Bill Nguyen schreef: Show quoteHide quote > This has been posted before but received no response: > > I need to arrange window screens on the total area of a mulitple-mopnitor > desktop. > As an example, below is the bound info for my 2-monitor PC: > > Device Name: \\.\DISPLAY1 > Bounds: {X=1152,Y=0,Width=1152,Height=864} > Primary Screen: False > > Device Name: \\.\DISPLAY2 > Bounds: {X=0,Y=0,Width=1152,Height=864} > Primary Screen: True > > > Now I need to display a form on Display1 and another form on Display2 > I don't know if this is possible using .NET or not. > > Any help is greatly appreciated. > > Bill Michel;
I already looked into it, and as a matter of fact, used AllScreens to retrieve the screens info. The problem is that I can't assign a form to a particular screen. I looked into all the methods but do not know which one I shoudl use to display an object to a screen. In short, I need an example of how to do this if it's possible. Thanks again Bill Show quoteHide quote "Michel van den Berg" <m**@promontis.nl> wrote in message news:1164660763.478923.65420@j72g2000cwa.googlegroups.com... > See the Screen class at: > http://msdn2.microsoft.com/en-us/library/system.windows.forms.screen.aspx > > Note the AllScreens property > > > Bill Nguyen schreef: > >> This has been posted before but received no response: >> >> I need to arrange window screens on the total area of a >> mulitple-mopnitor >> desktop. >> As an example, below is the bound info for my 2-monitor PC: >> >> Device Name: \\.\DISPLAY1 >> Bounds: {X=1152,Y=0,Width=1152,Height=864} >> Primary Screen: False >> >> Device Name: \\.\DISPLAY2 >> Bounds: {X=0,Y=0,Width=1152,Height=864} >> Primary Screen: True >> >> >> Now I need to display a form on Display1 and another form on Display2 >> I don't know if this is possible using .NET or not. >> >> Any help is greatly appreciated. >> >> Bill > Bill Nguyen wrote:
Show quoteHide quote > This has been posted before but received no response: I understand your problem as I have 4 screens, however, the only way > > I need to arrange window screens on the total area of a mulitple-mopnitor > desktop. > As an example, below is the bound info for my 2-monitor PC: > > Device Name: \\.\DISPLAY1 > Bounds: {X=1152,Y=0,Width=1152,Height=864} > Primary Screen: False > > Device Name: \\.\DISPLAY2 > Bounds: {X=0,Y=0,Width=1152,Height=864} > Primary Screen: True > > > Now I need to display a form on Display1 and another form on Display2 > I don't know if this is possible using .NET or not. > > Any help is greatly appreciated. > > Bill > > > Bill, I've ever solved it was by assigning Global Variables to hold screen information and then referencing that information from other Forms. Basically, I have the following in a Global Module - Public Scrn() As Screen Public gliPrimaryScreen, gliDesignatedScreen As UInt16 In my Main (Startup) Form I have - Scrn = Screen.AllScreens Dim X As UInt16 For Each S As Screen In Scrn If S.Primary Then gliPrimaryScreen = X Exit For End If X += 1 Next At this point I know the "Primary" Screen index value (can't always be assumed to be "0"). I can then iterate through the other indexes to determine the layout of the entire display area, and what order they're in. Now, if I want to display a Form on a particular display I simply set the "gliDesignatedScreen" variable prior to opening the Form and in that Form's Load Event I use something like the following - Private Sub SecondFrm_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim recScreenWorkingArea As Rectangle Try recScreenWorkingArea = Scrn(gliDesignatedScreen).WorkingArea Catch ex As Exception recScreenWorkingArea = Screen.PrimaryScreen.WorkingArea End Try End Sub Now I can position/manipulate the Form based on the Bounds values associated with the recScreenWorkingArea values. There are probably easier ways to do all of this, but like you, I haven't found them. This approach was a quick and dirty method I used for a single application that I needed for my own use and is in need of cleaning up, but it does work! I hope this helps. If you find something better I'd be interested to hear about it. ShaneO There are 10 kinds of people - Those who understand Binary and those who don't. Dear Shane;
I'll try this and let you know the results. Thanks a million! Bill Show quoteHide quote "ShaneO" <spc***@optusnet.com.au> wrote in message news:456b68e1$0$9771$afc38c87@news.optusnet.com.au... > Bill Nguyen wrote: >> This has been posted before but received no response: >> >> I need to arrange window screens on the total area of a >> mulitple-mopnitor desktop. >> As an example, below is the bound info for my 2-monitor PC: >> >> Device Name: \\.\DISPLAY1 >> Bounds: {X=1152,Y=0,Width=1152,Height=864} >> Primary Screen: False >> >> Device Name: \\.\DISPLAY2 >> Bounds: {X=0,Y=0,Width=1152,Height=864} >> Primary Screen: True >> >> >> Now I need to display a form on Display1 and another form on Display2 >> I don't know if this is possible using .NET or not. >> >> Any help is greatly appreciated. >> >> Bill >> >> >> > Bill, > > I understand your problem as I have 4 screens, however, the only way I've > ever solved it was by assigning Global Variables to hold screen > information and then referencing that information from other Forms. > > Basically, I have the following in a Global Module - > > Public Scrn() As Screen > Public gliPrimaryScreen, gliDesignatedScreen As UInt16 > > In my Main (Startup) Form I have - > > Scrn = Screen.AllScreens > > Dim X As UInt16 > For Each S As Screen In Scrn > If S.Primary Then > gliPrimaryScreen = X > Exit For > End If > X += 1 > Next > > At this point I know the "Primary" Screen index value (can't always be > assumed to be "0"). > > I can then iterate through the other indexes to determine the layout of > the entire display area, and what order they're in. > > Now, if I want to display a Form on a particular display I simply set the > "gliDesignatedScreen" variable prior to opening the Form and in that > Form's Load Event I use something like the following - > > Private Sub SecondFrm_Load(ByVal sender As Object, ByVal e As > System.EventArgs) Handles Me.Load > > Dim recScreenWorkingArea As Rectangle > Try > recScreenWorkingArea = Scrn(gliDesignatedScreen).WorkingArea > Catch ex As Exception > recScreenWorkingArea = Screen.PrimaryScreen.WorkingArea > End Try > > End Sub > > Now I can position/manipulate the Form based on the Bounds values > associated with the recScreenWorkingArea values. > > There are probably easier ways to do all of this, but like you, I haven't > found them. > > This approach was a quick and dirty method I used for a single application > that I needed for my own use and is in need of cleaning up, but it does > work! > > I hope this helps. If you find something better I'd be interested to hear > about it. > > ShaneO > > There are 10 kinds of people - Those who understand Binary and those who > don't. Shane;
I tried but finally got lost! Below is a simplified version of the routine I used to display multiple windows on a desktop. The last part is where I tried to send the new window to a different "Bound" but it never worked! Any suggestion is greatly appreciated. Bill Private Sub loadMaps(ByVal dV As DataView, ByVal mMonitor As Integer) Dim mdVR As DataRowView dV.RowFilter = "monitorID = " & mMonitor If dV.Count <= 0 Then ' MsgBox("No records found") Exit Sub End If Dim mUrl, mMPPath As String ' mScreen, mUrl2, mUrl3, mUrl4 As String Dim mScreenName, mvehicleID, mButtonName, mButtonText As String Dim mModulus As Integer Dim mPanel As New TableLayoutPanel Dim mWeb, mWeb1, mWeb2, mWeb3, mWeb4 As New WebBrowser Dim mButton, mButton1, mButton2, mButton3, mButton4 As Button With mPanel .ColumnCount = 2 .ColumnStyles.Add(New System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50.0!)) .ColumnStyles.Add(New System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50.0!)) .RowCount = 2 .RowStyles.Add(New System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50.0!)) .RowStyles.Add(New System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50.0!)) For Each mdVR In dV mScreenName = mdVR.Item("panelID").ToString.Trim mvehicleID = mdVR.Item("vehicleID").ToString.Trim mUrl = "http://masterserver/" & mdVR.Item("mapPath1").Trim mMPPath = mdVR.Item("mapPath2").ToString mModulus = mdVR.Item("panelID") - ((mMonitor - 1) * 4) mButtonName = mdVR.Item("mapPath2").ToString.Trim mButtonText = "View GPS trail for vehicle " & mvehicleID & " in Mappoint" Select Case mModulus Case 1 With mWeb1 .Dock = DockStyle.Fill .Navigate(mUrl) End With .Controls.Add(mWeb1, 0, 0) Case 2 With mWeb2 .Dock = DockStyle.Fill .Navigate(mUrl) End With .Controls.Add(mWeb2, 1, 0) Case 3 With mWeb3 .Dock = DockStyle.Fill .Navigate(mUrl) End With .Controls.Add(mWeb3, 0, 1) Case 4 With mWeb4 .Dock = DockStyle.Fill .Navigate(mUrl) End With .Controls.Add(mWeb4, 1, 1) Case Else End Select .Dock = DockStyle.Fill Next End With Dim thisX, thisY, thisW, thisH As Integer thisY = 0 thisW = 1152 thisH = 864 thisX = 1152 * (mMonitor - 1) ' MsgBox(thisX & " - " & thisY) ' Dim frmScreen As New frmMultiScreens Dim frmScreen As New frmBlank With frmScreen .Text = "WF Truck Breadcumbs Display" ' .SetBounds(thisX, thisY, thisW, thisH) '.SetDesktopBounds(thisX, thisY, thisW, thisH) .Controls.Add(mPanel) .WindowState = FormWindowState.Maximized ' .SetDisplayRectLocation(thisX, thisY) .Show() '.ShowDialog() End With 'Me.Controls.Add(mPanel) 'Me.WindowState = FormWindowState.Maximized End Sub Show quoteHide quote "ShaneO" <spc***@optusnet.com.au> wrote in message news:456b68e1$0$9771$afc38c87@news.optusnet.com.au... > Bill Nguyen wrote: >> This has been posted before but received no response: >> >> I need to arrange window screens on the total area of a >> mulitple-mopnitor desktop. >> As an example, below is the bound info for my 2-monitor PC: >> >> Device Name: \\.\DISPLAY1 >> Bounds: {X=1152,Y=0,Width=1152,Height=864} >> Primary Screen: False >> >> Device Name: \\.\DISPLAY2 >> Bounds: {X=0,Y=0,Width=1152,Height=864} >> Primary Screen: True >> >> >> Now I need to display a form on Display1 and another form on Display2 >> I don't know if this is possible using .NET or not. >> >> Any help is greatly appreciated. >> >> Bill >> >> >> > Bill, > > I understand your problem as I have 4 screens, however, the only way I've > ever solved it was by assigning Global Variables to hold screen > information and then referencing that information from other Forms. > > Basically, I have the following in a Global Module - > > Public Scrn() As Screen > Public gliPrimaryScreen, gliDesignatedScreen As UInt16 > > In my Main (Startup) Form I have - > > Scrn = Screen.AllScreens > > Dim X As UInt16 > For Each S As Screen In Scrn > If S.Primary Then > gliPrimaryScreen = X > Exit For > End If > X += 1 > Next > > At this point I know the "Primary" Screen index value (can't always be > assumed to be "0"). > > I can then iterate through the other indexes to determine the layout of > the entire display area, and what order they're in. > > Now, if I want to display a Form on a particular display I simply set the > "gliDesignatedScreen" variable prior to opening the Form and in that > Form's Load Event I use something like the following - > > Private Sub SecondFrm_Load(ByVal sender As Object, ByVal e As > System.EventArgs) Handles Me.Load > > Dim recScreenWorkingArea As Rectangle > Try > recScreenWorkingArea = Scrn(gliDesignatedScreen).WorkingArea > Catch ex As Exception > recScreenWorkingArea = Screen.PrimaryScreen.WorkingArea > End Try > > End Sub > > Now I can position/manipulate the Form based on the Bounds values > associated with the recScreenWorkingArea values. > > There are probably easier ways to do all of this, but like you, I haven't > found them. > > This approach was a quick and dirty method I used for a single application > that I needed for my own use and is in need of cleaning up, but it does > work! > > I hope this helps. If you find something better I'd be interested to hear > about it. > > ShaneO > > There are 10 kinds of people - Those who understand Binary and those who > don't. Bill Nguyen wrote:
> Shane; Bill, what you've posted seems way too much for what you're trying to > I tried but finally got lost! > > achieve! If you take another look at the code I posted you'll see that "Scrn" ends up as a Screen Object Array that holds everything you need. As you only have 2 displays, once you use the code that sets the "gliPrimaryScreen" variable then, in your case, you'll automatically know which Scrn Array Index holds the details of your other display. To use this information, just set "gliDesignatedScreen" value (either 0 or 1 in your case for Primary or Secondary) and Load your next Form. In that Forms Load Event use the code I provided. Here's a full example (watch for wrapping!) - Dim recScreenWorkingArea As Rectangle Try recScreenWorkingArea = Scrn(gliDesignatedScreen).WorkingArea Catch ex As Exception recScreenWorkingArea = Screen.PrimaryScreen.WorkingArea End Try Dim CentreScreen As New Point CentreScreen.X = (recScreenWorkingArea.Width / 2) + (Scrn(gliDesignatedScreen).WorkingArea.Left) - (Me.Width / 2) CentreScreen.Y = (recScreenWorkingArea.Height / 2) - (Me.Height / 2) Me.Location = CentreScreen Set "gliDesignatedScreen" to 0 or 1 and you'll see what happens. Try it and let me know if you need any further assistance. ShaneO There are 10 kinds of people - Those who understand Binary and those who don't. Bill,
I have one form where I 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). If you know the name of the screen you should be able to just use that to "index" into the Screens collection. Something like: SetScreen("\\.\DISPLAY1") Private Sub SetScreen(ByVal deviceName As String) For Each s As Screen In Screen.AllScreens If String.Equals(s.DeviceName, deviceName, StringComparison.OrdinalIgnoreCase) Then Me.Bounds = s.Bounds Return End If Next End Sub If you have a "monitor" index, you should be able to simply index into the array: SetScreen(0) Private Sub SetScreen(ByVal index As Integer) Dim s As Screen = Screen.AllScreens(index) Me.Bounds = s.Bounds End Sub -- Show quoteHide quoteHope this helps Jay B. Harlow ..NET Application Architect, Enthusiast, & Evangelist T.S. Bradley - http://www.tsbradley.net "Bill Nguyen" <billn_nospam_please@jaco.com> wrote in message news:%23vJKm8WFHHA.4580@TK2MSFTNGP05.phx.gbl... > Shane; > I tried but finally got lost! > > Below is a simplified version of the routine I used to display multiple > windows on a desktop. The last part is where I tried to send the new > window to a different "Bound" but it never worked! > > Any suggestion is greatly appreciated. > > Bill > > > > Private Sub loadMaps(ByVal dV As DataView, ByVal mMonitor As Integer) > Dim mdVR As DataRowView > dV.RowFilter = "monitorID = " & mMonitor > If dV.Count <= 0 Then > ' MsgBox("No records found") > Exit Sub > End If > > Dim mUrl, mMPPath As String ' mScreen, mUrl2, mUrl3, mUrl4 As > String > Dim mScreenName, mvehicleID, mButtonName, mButtonText As String > Dim mModulus As Integer > > Dim mPanel As New TableLayoutPanel > Dim mWeb, mWeb1, mWeb2, mWeb3, mWeb4 As New WebBrowser > > Dim mButton, mButton1, mButton2, mButton3, mButton4 As Button > > > > > With mPanel > > .ColumnCount = 2 > .ColumnStyles.Add(New > System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, > 50.0!)) > .ColumnStyles.Add(New > System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, > 50.0!)) > > .RowCount = 2 > .RowStyles.Add(New > System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, > 50.0!)) > .RowStyles.Add(New > System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, > 50.0!)) > > For Each mdVR In dV > > > > mScreenName = mdVR.Item("panelID").ToString.Trim > mvehicleID = mdVR.Item("vehicleID").ToString.Trim > mUrl = "http://masterserver/" & mdVR.Item("mapPath1").Trim > mMPPath = mdVR.Item("mapPath2").ToString > > mModulus = mdVR.Item("panelID") - ((mMonitor - 1) * 4) > mButtonName = mdVR.Item("mapPath2").ToString.Trim > mButtonText = "View GPS trail for vehicle " & mvehicleID & > " in Mappoint" > > > Select Case mModulus > Case 1 > > With mWeb1 > > .Dock = DockStyle.Fill > > .Navigate(mUrl) > > End With > .Controls.Add(mWeb1, 0, 0) > > > Case 2 > With mWeb2 > > .Dock = DockStyle.Fill > .Navigate(mUrl) > > End With > .Controls.Add(mWeb2, 1, 0) > > Case 3 > With mWeb3 > > .Dock = DockStyle.Fill > .Navigate(mUrl) > > End With > .Controls.Add(mWeb3, 0, 1) > Case 4 > > With mWeb4 > > .Dock = DockStyle.Fill > .Navigate(mUrl) > > > End With > .Controls.Add(mWeb4, 1, 1) > Case Else > > > End Select > > .Dock = DockStyle.Fill > > > Next > > > > > End With > > > > > Dim thisX, thisY, thisW, thisH As Integer > thisY = 0 > thisW = 1152 > thisH = 864 > thisX = 1152 * (mMonitor - 1) > ' MsgBox(thisX & " - " & thisY) > ' Dim frmScreen As New frmMultiScreens > Dim frmScreen As New frmBlank > With frmScreen > .Text = "WF Truck Breadcumbs Display" > ' .SetBounds(thisX, thisY, thisW, thisH) > '.SetDesktopBounds(thisX, thisY, thisW, thisH) > .Controls.Add(mPanel) > .WindowState = FormWindowState.Maximized > ' .SetDisplayRectLocation(thisX, thisY) > > .Show() > '.ShowDialog() > End With > > 'Me.Controls.Add(mPanel) > 'Me.WindowState = FormWindowState.Maximized > > End Sub > > "ShaneO" <spc***@optusnet.com.au> wrote in message > news:456b68e1$0$9771$afc38c87@news.optusnet.com.au... >> Bill Nguyen wrote: >>> This has been posted before but received no response: >>> >>> I need to arrange window screens on the total area of a >>> mulitple-mopnitor desktop. >>> As an example, below is the bound info for my 2-monitor PC: >>> >>> Device Name: \\.\DISPLAY1 >>> Bounds: {X=1152,Y=0,Width=1152,Height=864} >>> Primary Screen: False >>> >>> Device Name: \\.\DISPLAY2 >>> Bounds: {X=0,Y=0,Width=1152,Height=864} >>> Primary Screen: True >>> >>> >>> Now I need to display a form on Display1 and another form on Display2 >>> I don't know if this is possible using .NET or not. >>> >>> Any help is greatly appreciated. >>> >>> Bill >>> >>> >>> >> Bill, >> >> I understand your problem as I have 4 screens, however, the only way I've >> ever solved it was by assigning Global Variables to hold screen >> information and then referencing that information from other Forms. >> >> Basically, I have the following in a Global Module - >> >> Public Scrn() As Screen >> Public gliPrimaryScreen, gliDesignatedScreen As UInt16 >> >> In my Main (Startup) Form I have - >> >> Scrn = Screen.AllScreens >> >> Dim X As UInt16 >> For Each S As Screen In Scrn >> If S.Primary Then >> gliPrimaryScreen = X >> Exit For >> End If >> X += 1 >> Next >> >> At this point I know the "Primary" Screen index value (can't always be >> assumed to be "0"). >> >> I can then iterate through the other indexes to determine the layout of >> the entire display area, and what order they're in. >> >> Now, if I want to display a Form on a particular display I simply set the >> "gliDesignatedScreen" variable prior to opening the Form and in that >> Form's Load Event I use something like the following - >> >> Private Sub SecondFrm_Load(ByVal sender As Object, ByVal e As >> System.EventArgs) Handles Me.Load >> >> Dim recScreenWorkingArea As Rectangle >> Try >> recScreenWorkingArea = Scrn(gliDesignatedScreen).WorkingArea >> Catch ex As Exception >> recScreenWorkingArea = Screen.PrimaryScreen.WorkingArea >> End Try >> >> End Sub >> >> Now I can position/manipulate the Form based on the Bounds values >> associated with the recScreenWorkingArea values. >> >> There are probably easier ways to do all of this, but like you, I haven't >> found them. >> >> This approach was a quick and dirty method I used for a single >> application that I needed for my own use and is in need of cleaning up, >> but it does work! >> >> I hope this helps. If you find something better I'd be interested to >> hear about it. >> >> ShaneO >> >> There are 10 kinds of people - Those who understand Binary and those who >> don't. > >
Re: Help needed in using FSO's, TextStreams, etc. --- Code Review and Advice requested
listbox's SelectedIndexChanged keep fire Array Question, Out of Bounds better way to program than this? how to save the textbox contents to sql server database Display Outlook Recipient Window from vb.net Errors when running from LAN server. sqlDataReader does not return correct sorted data Form level focus monitor using file system in web site |
|||||||||||||||||||||||