473,806 Members | 2,583 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

System.Windows. Forms.Screen.Al lScreens

How to force System.Windows. Forms.Screen.Al lScreens to update when attaching
an additional monitor?

Form1 is Loaded and runs the following upon detection of additional monitor:

Dim Screens() As System.Windows. Forms.Screen
Screens = System.Windows. Forms.Screen.Al lScreens
MsgBox("SWFSAsL ength: " & System.Windows. Forms.Screen.Al lScreens.Length &
vbCr & "Screens: " & Screens.Length)

Output:
WSFSAsLength: 1
Screens: 1

If a message box is displayed prior to setting the Screens variable such as
following then System.Windows. Forms.Screens.A llScreens is updated as
follows:

Dim Screens() As System.Windows. Forms.Screen
MsgBox("anythin g")
Screens = System.Windows. Forms.Screen.Al lScreens
MsgBox("SWFSAsL ength: " & System.Windows. Forms.Screen.Al lScreens.Length &
vbCr & "Screens: " & Screens.Length)

Output:
WSFSAsLength: 2
Screens: 2

Need to obtain HxV size of each attached monitor. Is there a better way?

Jan 19 '08 #1
1 7365
It sounds like you want to run the code listed in the help for the Screen
class. As to why you get a different answer after a messagebox, I suggest
putting this in a routine handling the shown event rather than the load
event. It may be that the forms library gets initialized after something is
shown, which in this case, would be your form.

"Allen" wrote:
How to force System.Windows. Forms.Screen.Al lScreens to update when attaching
an additional monitor?

Form1 is Loaded and runs the following upon detection of additional monitor:

Dim Screens() As System.Windows. Forms.Screen
Screens = System.Windows. Forms.Screen.Al lScreens
MsgBox("SWFSAsL ength: " & System.Windows. Forms.Screen.Al lScreens.Length &
vbCr & "Screens: " & Screens.Length)

Output:
WSFSAsLength: 1
Screens: 1

If a message box is displayed prior to setting the Screens variable such as
following then System.Windows. Forms.Screens.A llScreens is updated as
follows:

Dim Screens() As System.Windows. Forms.Screen
MsgBox("anythin g")
Screens = System.Windows. Forms.Screen.Al lScreens
MsgBox("SWFSAsL ength: " & System.Windows. Forms.Screen.Al lScreens.Length &
vbCr & "Screens: " & Screens.Length)

Output:
WSFSAsLength: 2
Screens: 2

Need to obtain HxV size of each attached monitor. Is there a better way?

Jan 19 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1867
by: Brad Shook | last post by:
Ok here is what I a trying to do. I am trying to emulate an operator having to do repetitive tasks on a 3rd party program. Here is what I am doing so far. It works. Start Code Dim myProcess As Process = System.Diagnostics.Process.Start("C:\ca\wb.exe") myProcess.StartInfo.WindowStyle = ProcessWindowStyle.Normal ' wait until the program is ready for input myProcess.WaitForInputIdle(1000) If myProcess.Responding Then
1
7818
by: Patrick | last post by:
need some code for getting screenshots from the secondary monitor on dual monitor display. Here's a bit of the code for a screen from the primary monitor. Bitmap MyImage = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, g1); For the second monitor I can use the Screen.Allscreens method to get and array of the screens. So far that is looking like this...
10
2712
by: WhiteSocksGuy | last post by:
Help! I am new to Visual Basic .Net (version 2002) and I am trying to get a System.Timers.Timer to work for me to display a splash screen for about two seconds and then load the main form. I have two forms (frmSplash and frmMain) and a code Module setup as my startup object. Here is the code that I have, when I try to run this part of the splash screen form shows and then program terminates. What am I doing wrong? Thanks,
5
9892
by: Michael C# | last post by:
Hi all, I set up a System.Timers.Time in my app. The code basically just updates the screen, but since the processing performed is so CPU-intensive, I wanted to make sure it gets updated regularly; like every 1.5 secs. or so. I only ran into one issue - the MyTimer_Elapsed event handler was not updating the screen correctly all the time, often leaving large chunks of the screen un-painted for several seconds. On a whim I decided to...
1
9459
by: Marc the Demi-Programmer | last post by:
I am overriding WncProc to make sure my form's location stays within specified parameters. Basically, it has to stay at the top of the screen and not be off to either of the sides. All that works when the form is in its minimal size. However, when the form is maximized using the appropriate button the code that is supposed to set the location is ignored. When the form is switched back to the standard dimensions through the restore...
2
4504
by: =?Utf-8?B?TmF0aGFuIFdpZWdtYW4=?= | last post by:
Hi, I am wondering why the .NET Framework is quite different from Win32 API when it comes to displaying system modal message boxes. Consider the four following types of system modal message boxes (please see associated source code below): 1) Win32 API with context ("btnWin32WithContext_Click") 2) .NET Framework with context ("btnFrameworkWithContext_Click") 3) Win32 API withOUT context ("btnWin32WithOUTContext_Click")
6
2024
by: jojoba | last post by:
Hi, I am trying to create a .net webservice such that: When a user calls the service, the server creates a System.Windows.Forms.Form and shows it on the server screen. I know this sounds bizarre, but i do have a good reason for doing this. I can get the following to work when i run the service in Visual Studio (c#):
22
6441
by: schneider | last post by:
I need to hook the system mouse down event. I'm trying to replicate how a context menu hides when the mouse clicks outside of the control. Thanks, Schneider
0
3437
by: Sandra Smit | last post by:
Hi, I'm making a dual screen application with WPF. I use the following code but the weatherForcast form is not running on the second screen: protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); Window1 w1 = new Window1();
0
9719
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
10623
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9192
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
6877
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5546
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
5683
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4330
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
2
3852
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3010
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.