473,396 Members | 1,859 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Screen dimensions

6
Hi!
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?
Thanx!!!
Davide
Feb 26 '07 #1
4 4430
kenobewan
4,871 Expert 4TB
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
Hi.

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.AllScreens[Screen.AllScreens.Length - 1].Bounds.Right - Properties.Settings.Default.tamanno.Width)
this.Left = Screen.AllScreens[Screen.AllScreens.Length - 1].Bounds.Right - (Properties.Settings.Default.tamanno.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.AllScreens[Screen.AllScreens.Length - 1].Bounds.Bottom)
this.Top = Screen.AllScreens[Screen.AllScreens.Length - 1].Bounds.Bottom - (Properties.Settings.Default.tamanno.Height + 10 + (Screen.PrimaryScreen.Bounds.Height - Screen.PrimaryScreen.WorkingArea.Height));
//inicializar combo
for (int i = 0; i < Screen.AllScreens.Length; i++)
this.comboBox1.Items.Add(Screen.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
lupus
6
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.VisualBasic.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..which object should I use? Is there anything similar to ThisComputerWorking.Screen.Bounds?

I'll attach my piece of code:

internal void placeButtons(int[] 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();
i++;
}
}
this.SuspendLayout();
i = 0;
for (int r = 0; r < dim[0]; r++)
{
for (int c = 0; c < dim[1]; c++)
{
string str = CreateStrName(i);
//int buttH = SystemInformation.PrimaryMonitorMaximizedWindowSiz e.Height / dim[0];
//int buttW = SystemInformation.PrimaryMonitorMaximizedWindowSiz e.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].UseVisualStyleBackColor = true;
Console.WriteLine(buttons[r, c].Name + " placed at coordinates: (" + x + "," + y + ")");
i++;
}
}
for (int r = 0; r < dim[0]; r++)
{
for (int c = 0; c < dim[1]; c++)
{
this.Controls.Add(buttons[r, c]);
}
}
}
Feb 26 '07 #4
you can't use it like that.. you should specify the screen.

ej.

Rectangle rect = Screen.AllScreens[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

13
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:...
3
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...
48
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 ...
6
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...
1
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...
7
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...
3
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),...
1
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...
0
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...
4
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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,...
0
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...

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.