473,834 Members | 1,363 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Screen dimensions

6 New Member
I need to create a form and fill it with a number of button decided at run-time..then I need to create this buttons according to their number such that they adapt on the whole screen dimension..
Is there any property or anything that tells me this?
Feb 26 '07 #1
4 4444
4,871 Recognized Expert Specialist
This post is very vague and lacks useful information. It is also very similar to your first post. Please state clearly the problem or error you are having. State the programming language, whether it is windows or web etc. I realise that you may have difficulty with English, but more info at the start should mean a faster response. Thanks.
Feb 26 '07 #2
14 New Member

look, there are a few Objects in the framework... you can use them to know about your screen..

the main object to do it is the Screen Object. I use it to create a form that should not move out the screen...

if (this.Left > Screen.AllScree ns[Screen.AllScree ns.Length - 1].Bounds.Right - Properties.Sett ings.Default.ta manno.Width)
this.Left = Screen.AllScree ns[Screen.AllScree ns.Length - 1].Bounds.Right - (Properties.Set tings.Default.t amanno.Width + 10);
//deja de ser visible del lado izquierdo
if (this.Left < 0)
this.Left = 10;
//no es visible la parte superior
if (this.Top < 0)
this.Top = 10;
//no es visible la parte inferior
if (this.Bottom > Screen.AllScree ns[Screen.AllScree ns.Length - 1].Bounds.Bottom)
this.Top = Screen.AllScree ns[Screen.AllScree ns.Length - 1].Bounds.Bottom - (Properties.Set tings.Default.t amanno.Height + 10 + (Screen.Primary Screen.Bounds.H eight - Screen.PrimaryS creen.WorkingAr ea.Height));
//inicializar combo
for (int i = 0; i < Screen.AllScree ns.Length; i++)
this.comboBox1. Items.Add(Scree n.AllScreens[i].DeviceName);

this is part of my code.. I wope it help you
the screeen object is also an array of screens if you have more than one.
Feb 26 '07 #3
6 New Member
You are right, I should specify a bit better!
I'm working on a Windows app, not Web, with C# language.
The fact is I need this property or something that tells me width and height of the screen I'm using, including the Windows taskbar (I think this is the name in English, meaning the bar at the bottom, with start button, open applications, ...)

Thanx George, but: the Screen you mean is a class of System.Windows. Forms or a property of Microsoft.Visua lBasic.Devices. Computer?

If it's the second, I think I can't use it in C# program, can I?
If it's the first, I tried to call the property Screen.Bounds but it's not static so the compiler asks me to give an object reference..whic h object should I use? Is there anything similar to ThisComputerWor king.Screen.Bou nds?

I'll attach my piece of code:

internal void placeButtons(in t[] dimensions)
int i = 0;
int[] dim = dimensions;
Button[,] buttons = new Button[dim[0], dim[1]];

for (int r = 0; r < dim[0]; r++)
for (int c = 0; c < dim[1]; c++)
//string str = CreateStrName(i );
buttons[r, c] = new Button();
this.SuspendLay out();
i = 0;
for (int r = 0; r < dim[0]; r++)
for (int c = 0; c < dim[1]; c++)
string str = CreateStrName(i );
//int buttH = SystemInformati on.PrimaryMonit orMaximizedWind owSize.Height / dim[0];
//int buttW = SystemInformati on.PrimaryMonit orMaximizedWind owSize.Width / dim[1];
//********trov come indicare le dim del tutto schermo
Rectangle rect = Screen.Bounds;
int buttH = rect.Height / dim[0];
int buttW = rect.Width / dim[1];
int x = buttW * c;
int y = buttH * r;

buttons[r, c].Location = new System.Drawing. Point(x, y);
buttons[r, c].Name = str;
buttons[r, c].Size = new System.Drawing. Size(buttW, buttH);
buttons[r, c].TabIndex = i;
buttons[r, c].Text = str;
buttons[r, c].UseVisualStyle BackColor = true;
Console.WriteLi ne(buttons[r, c].Name + " placed at coordinates: (" + x + "," + y + ")");
for (int r = 0; r < dim[0]; r++)
for (int c = 0; c < dim[1]; c++)
this.Controls.A dd(buttons[r, c]);
Feb 26 '07 #4
14 New Member
you can't use it like that.. you should specify the screen.


Rectangle rect = Screen.AllScree ns[0].Bounds;

you must put AllScreens and the screen wich you mean to check, and then you can obtain the bouds.

i hope it help :D
Feb 27 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

by: Erik | last post by:
I want to write a Server Side PHP program that generates a HTML page client side. How would I get at the clients' screen size, before serving the generated page ? Would it be a two-step process: first let the client execute a piece of JavaScript to generate Height and Width, and then send those values to the PHP server (FORM, PUT) ? Or can it be done in only one PHP program ?
by: Ed | last post by:
Using JavaScript, I'm able to get the user's screen dimensions with screen.availWidth and screen.availHeight. But if I want to store this info in the database using ASP code, how do I go about doing it?
by: David J Patrick | last post by:
I'm trying to rewrite the CSS used in http://s92415866.onlinehome.us/files/ScreenplayCSSv2.html. using the w3.org paged media standards as described at http://www.w3.org/TR/REC-CSS2/page.html The ScreenplayCSS is flawed, for several reasons; -overuse of <div id= tags -doesn't scale screen resolutions (convert from px to in, pt ?) -no media="print" (how much coule be shared between "screen" & "print") -no automatic page breaks (with...
by: allanc | last post by:
i tried using a borderless form + picturebox, which works fine for dimensions smaller than the actual screen dimensions, but for larger sizes the window seems to clip. programs like acdsee seem to have no trouble doing this, how?? Thanks in advance!
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...
by: mukeshgupta.WD | last post by:
Hi, i have seen in many web sites, the size of pages are automatically resized according to screen resolution. generally we create web layout for 800x600 but if we view it in1024x768 then the page open have wide space on right. Is there any kind of coding to overcome this situation.like when we wiew the page created in 800x600 in 1024x768 resol. then it atomatically resized to full screen without having any scroll on browser.
by: prom19 | last post by:
I made my first flash-site, it's based on a top frame that loads the pages and a small bottom frame that doesnt change content. The problem is that the dimensions are fine for my screen (1280X1024), but too big for many other screens, laptops etc. Is there a way to maybe add a line to the index.html that will automatically adapt the dimensions of the flash content in the top frame to make sure that users dont have to scroll to see the whole...
by: Mufasa | last post by:
I have some machines that apparently are having the screen resolution changed based on group policies ( this is what my Network Engineer is telling me ). These machines are at customer sites so we can't see what it going on. The problem is, or at least appears to be, that the code is returning different dimensions then what is really out there. The code I'm using to find out the dimensions is: System.Drawing.Rectangle workingRectangle...
by: =?Utf-8?B?amFtZXNjaGk=?= | last post by:
I'm trying to do is to launch Powerpoint Viever 2007 in my secondary screen. I'm still having issues resizing the pptviewer.exe output when moving the window to the second monitor. Here's my code so far: Process view = new Process(); view.EnableRaisingEvents = true; view.StartInfo.WindowStyle = ProcessWindowStyle.Normal; view.StartInfo.CreateNoWindow = true;
by: dipalipatel | last post by:
Hi, I have one c# smart device application created in .net 2005. I have fixed size form for my one device. Now i have another device and screen size is chaged menas it is more wider and short in size. If i run same application then some of the controls are not visible as screen dimentions chages. So, is there any way i can auto size my forms as per screen dimentions. For exmple if i have screen dimensions like 251 X 300 it works...
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,...
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...
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...
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...
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
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...
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: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
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.