OK! I am little confused between the terms "resizing" application and changing the resolution of screen....any way little hint or piece of code for me to work on please.....
Printable View
OK! I am little confused between the terms "resizing" application and changing the resolution of screen....any way little hint or piece of code for me to work on please.....
Resizing the application means, you should redesign your UI to make it work on any reasonable resolution the display might happen to be in.
Changing the resolution of the screen means running your application in full screen mode or in windowed mode typically.
Changing the resolution also means that you alter the user's display settings. For example, because your program can only handle 1024 x 768 resolution, the program programatically changes the system resolution to 1024 x 768.
As mentioned in a previous post, a well behaved program should not alter user display settings.
Yes Exactly! I thought it would be easier to change the resolution of computer until i got answer from you guys.......the programs I designed have picbox, buttons etc...If computer's resolution is not in exactly 1024 X 768 the whole orientation goes wrong...so what should i do to avoid this....
I can't really stress the importance of leaving the user settings alone.
Imagine if I wrote a program that moved the taskbar to the left side of the screen, change the resolution to 640 x480 and minimized all open applications to the taskbar. Then after running for 5 minutes, I closed all other running programs.
Do you think users would like this app?
Proper app design means that your app runs in the environment is it given and doesn't alter that environment.
Although WPF applications are a lot easier to scale to window sizes/resolutions, you can still do the same in WinForm.
I suggest taking a look at the Docking patterns that WinForm (and WPF) provides. With docking, you can essentially force UI elements to alway stay a certain distance away from edges of other UI elements, or borders of the window. This will allow the UI to scale as the size changes.
As explained earlier, you need to respond to resize events and resize the controls. See the attached app and look at the Anchor styles for each control. Between this style and an the Dock style mentioned by Mario, you can get the controls on the form to auto-resize. The first step is to get the form to resize it's controls when the user changes the size of the form (by dragging the resize chevron in the lower right corner of the form).
See the attached project for a basic form that resizes the controls when the user changes the form size.
Once you get that down, then the next step is to respond to an DisplaySettings change event (as already outlined in the other post) and programmatically set the form size. If you've done the resizing work here (as shown by the attached project), then the controls will resize when you set the form size.
Here's my advice. Give the picture box fixed dimensions and do the same for the buttons. Change your screen resolution to the minimum resolution you intend to support. Try the application in that resolution and make any adjustments necessary. I've not seen anything in your requirements that indicates the screen has to scale up or down depending on the resolution. You should be able to disable the 'Maximise' button so that your form always has the size (i.e. just big enough to fit all the controls inside it. That way it will look the same in all the resolutions you want to support. Of course under higher higher resolutions your form will take up less space...
Superb!! Exactly what I wanted....Thanks......
See if any of this is helpful:
http://social.msdn.microsoft.com/For...e-85e7df854e99
and also:
http://msdn.microsoft.com/en-us/libr...ms.screen.aspx
Suppose I have lots of adjecent rtfboxes side by side(say 20)....So only the rightmost rtf box is stretched......is there any way to make this streching or resizing rationally?? ie every rtf boxes should strech equally......
Is this code valid?? not workin with me....Code:int HtScreen = SystemInformation.PrimaryMonitorSize.Height;
int WtScreen = SystemInformation.PrimaryMonitorSize.Width;
if (HtScreen < 1030 || HtScreen > 805 && WtScreen<770||WtScreen>595) // checks the screen resolution
{
this.ClientSize = new System.Drawing.Size(1024, 768); //resizes the size of screen
this.rtfBox1.Size = new System.Drawing.Size(80, 200); //resizes from 30,200->80,200
}
Now that I have learned to resize my form according to the screen resolution(I think it is working....do I have to place anchoring code for buttons after resizing too??Code:
this.Resize += new System.EventHandler(this.ResizeMy_Resize);
//My Event Defintion
private void ResizeMy_Resize(object sender, System.EventArgs e)
{
int HtScreen = SystemInformation.PrimaryMonitorSize.Height;
int WtScreen = SystemInformation.PrimaryMonitorSize.Width;
//this.ClientSize = new System.Drawing.Size(WtScreen , HtScreen );
this.rtfBox1.Size = new System.Drawing.Size(80, 200);
}
secondly....this.rtfBox1.Size=new System.Drawing.Size(80,200) is not working..........
Anchoring/Docking is a one time setup. Do it in your designer view or in the control setup code.