|
-
Apr 16th, 2012, 04:27 AM
#1
Thread Starter
Hyperactive Member
Form Resizing Nightmare.
Having a bit of a nightmare with my application. I have developed my application in 1366 x 768. When moving onto other resolutions, the form looks totally wrong. Is there a way to have the application force itself to open up in a box that will fit the screen?
(I'm more than happy to pay someone today or tomorrow who could look at making sure that my form gracefully up / down scales). This really is pretty urgent in that respect. If you have the ability to gracefully scale a form up / down and can do so for me either today or tomorrow, let me know of your price. (Possibly a bit naughty to pop this into the forums but I am willing to pay to get this sorted asap).
Last edited by intraman; Apr 16th, 2012 at 04:37 AM.
-
Apr 16th, 2012, 04:59 AM
#2
Re: Form Resizing Nightmare.
I take it you want the form to keep the same aspect ratio (proportion of height to width). Otherwise you could just maximize the form, couldn't you?
It's not too difficult to do:
1. Calculate the aspect ratio (height/width) of the form.
2. Get the current screen size (or screen working area size, i.e. the area above the Taskbar, whichever you prefer). Calculate the aspect ratio (height/width) of the screen.
3. If the form aspect ratio is more than the screen aspect ratio, that means the form is taller and narrower than the screen. So:
- set the form height equal to the screen height.
- calculate the new width of the form (new form height / form aspect ratio).
4. If the form aspect ratio is less than that of the screen, it means the form is wider and flatter than the screen. In that case:
- set the form width equal to the screen width.
- calculate the new height of the form (new form width * aspect ratio).
In fact it takes a lot less lines of code than it does to describe it, but maybe you'd like to work it out for yourself and save your boss a few pennies .
BB
-
Apr 16th, 2012, 05:11 AM
#3
Thread Starter
Hyperactive Member
Re: Form Resizing Nightmare.
Thanks for your reply.
The difficulty I am having is that certain elements of the form have a fixed left / top location and I have no idea how to have that changed dependent on the screen resolution. I know I should have developed in a lower resolution
-
Apr 16th, 2012, 06:04 AM
#4
Re: Form Resizing Nightmare.
Have you tried positioning all the controls using their Anchor property? Anchoring is easiest in the designer but you can also do it in code for example:
Code:
Button1.Anchor = AnchorStyle.Left Or AnchorStyle.Top Or AnchorStyle.Right
This example will keep the button a constant distance from the top but it will scale the button horizontally if the form size changes. I think I got the syntax right but check!
An alternative would be to put some or all of your controls into a TableLayoutPanel. If you dock the TLP into the form and dock each control into a cell of the TLP, all the controls will scale in proportion to the form. If you do that, you may also want to scale the fonts appropriately too. You could alternatively use anchoring to position the controls relative to their cell boundaries. You can also spread a control across multiple cells e.g. some controls could be 3 columns wide, others 1.
If this doesn't help you, maybe you should post an image of your form with some annotations to show what behaviour you would like to get.
BB
-
Apr 16th, 2012, 11:35 AM
#5
Re: Form Resizing Nightmare.
I, too, would look at anchoring, as that will solve most of your problems. However, if the form gets crushed down far enough, anchoring will still result in problems. That generally isn't an issue if the form is full screen, but becomes an issue if the form is in a window that can be sized dynamically. The reason is that no screen is all that small anymore, whereas a window can be shrunk down to unreason. Still, paying attention to the achnoring will make even that part work as well as possible.
The easiest way to go about testing an anchoring scheme is to make the form sizeable, set the anchoring, then test stretching and shrinking the form to see what happens.
My usual boring signature: Nothing
 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|