Problem on setting the bottom-right coordinate of the form when it's maximized.

candice

Active member
Joined
Jan 23, 2007
Messages
30
Programming Experience
Beginner
Hi guys,
I have a question here that bothers me for a long time.
I'm now setting the form's WindowState to Maximized which is 1400 by 1050 based my monitor's resolution. And in my program all the buttons location and size on the form are input from an Excel file edited by user.
The problem is once the resolution of monitor is different from 1400 by 1050, the form can't be totoally shown on the screen. Because the buttons' location are saved in the Excel file which doesn't change according to the form's maximized size. Say, if next time the screen resolution is 800 by 600, the button on (1000, 800) will not be shown on the form.
Is there any way to fix the maximized size of the form in spite of the screen's resolution? Say, if I set(1400, 1050) to be the bottom-right coordinate, it will not change and each button will always keep its right location proportional to the form.
Any help will be very appriciated. Thank you!
 
So what youre asking is:

Is there any way to absolutely position buttons so they are positioned relatively?


Answer is: no.

Relative is one concept, Absolute is another..


Have the user re-code the excel file if their screen resolution is too small?
 
pps; if youre asking how to have a maximized form that is not the size of the screen, that too is a nonsense question, given that the definition of a maximised form is one that fits the screen to which it belongs (or with some graphics card hacks, spans multiple monitors)
 
It's the kind of situation you "guard" yourself from by stating required or recommended display resolution for usage of your software. You should also design the form with this in mind, getting info about most common used display resolutions (for example from W3C, see Display Resolutions section) and if possible design from the minimum resolution you want to support, then use the display dynamics provided by .Net form and control objects to let the form dynamically expand for people using greater resolutions. Dynamics include Minimumsize, MaximumSize, Anchor, Dock, using different Containers for flow design etc.
 
Thanks cjard and JohnH,
I'm always trying to fix the bottom-right coordintae of the maximized form because back in VB6 there is a way "Form.resize" to realize it. After setting the size of the form, say, (200,200) and making WindowState to Maximized, the problem can be solved.
Anyway, maybe I can try to write the code that save the button's location relative to the bottom and right sides of the form. Or study on the display dynamics way JohnH mentioned.:)
 
Yep, typically we design forms to resize and have controls move according to their dock and anchor settings


Heres a quick guide:

Anchor: Determines what edge of a control maintains a fixed distance from the edge of its container
Normally its top, left, so all controls stay fixed, when the form resizes

If it were BOTTOM,RIGHT then the control maintains a constant distance from the right and bottom edges of the form

when you anchor on opposite sides, like LEFT RIGHT the only way a control can maintain both a constant distance from its left edge to the forms left edge and its right edge to the forms right edge, is to expand horizontally

same for top/bottom -> causes vertical expansion


Its not quite as good and flexible as Java's GridBagLayout but it does the job. Combined with panels, and judicious use of Dock, you can make a nice ui..
 
Back
Top