Making form constantly maximized
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7

Thread: Making form constantly maximized

  1. #1
    Join Date
    Mar 2014
    Posts
    13

    Making form constantly maximized

    So,as the title says, I need my form to be either constantly maximized or constantly having it's maximized size, but the first option is prefered. What I've been trying to do is:
    1. I've set form border style to FixedSingle so it's not resizable.
    2. I made it start as maximized and disabled maximize box.
    But when you drag the window it changes it's size to default 300x300 so I've also done this:
    3.
    Code:
    private: System::Void MyForm_Load(System::Object^  sender, System::EventArgs^  e) {
    
    				 ScreenX = this->ClientSize.Width;
    				 ScreenY = this->ClientSize.Height;
    				 this->Size = System::Drawing::Size(ScreenX, ScreenY);
    	}
    It SHOULD save maximized screen size into my two variables and then set the default screen size to be always maximized size, but it does not.So, when I drag the window it still resizes to 300x300.
    Also, if there's such an option , I'd prefer it to be always maximized.
    Thx in advance.

  2. #2
    Join Date
    Jun 2010
    Location
    Germany
    Posts
    2,594

    Re: Making form constantly maximized

    Perhaps the first questiin to ask is: Why do you want your program to behave like that? What is the high-level (probably equivalent to user-level) goal you're trying to achieve?

    I can imagine a few approaches that possibly may go into the direction of what you're trying to do, but I can't tell you anything concrete as long as I don't know what it actually is that you're trying to do.
    I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.

    This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.

  3. #3
    Join Date
    Mar 2014
    Posts
    13

    Re: Making form constantly maximized

    Well, I'm not very experienced in C++/CLI programming and I have no idea how to make scrollbars, so I tought that the easiest way to deal with the problem of resizing my form would be to make it constantly maximized. This way I wouldn't have to worry about the scrollbars.

    EDIT: By "making" the scrollbars i mean making them work.
    Last edited by Fides Facit Fortis; March 26th, 2014 at 04:14 PM.

  4. #4
    Join Date
    Jun 2010
    Location
    Germany
    Posts
    2,594

    Re: Making form constantly maximized

    Quote Originally Posted by Fides Facit Fortis View Post
    [...] This way I wouldn't have to worry about the scrollbars.
    I don't see how a "constantly maximized" form could help to consistently avoid the need for scroll bars. What, for instance, if you want to work on something that's even larger than the entire screen?

    Most of the time, developers wouldn't need to worry too much about scroll bars anyway. Many controls (including the Form class itself, BTW) handle scroll bar management more or less autonomuously, most notably these are the controll classes derived from ScrollableControl, in particular Panel, ContainerControl and their numerous derivates.
    I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.

    This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.

  5. #5
    Join Date
    Mar 2014
    Posts
    13

    Re: Making form constantly maximized

    I made controls in my form scale with the form's size upon load( so for example a button has 10% in form's width and 5% in form's height etc) so it should always fit into the form no matter what the screen size is.

    Most of the time, developers wouldn't need to worry too much about scroll bars anyway. Many controls (including the Form class itself, BTW) handle scroll bar management more or less autonomuously, most notably these are the controll classes derived from ScrollableControl, in particular Panel, ContainerControl and their numerous derivates.
    What do you mean? My form doesn't have any scrollbars attached by default and if I place them in the designer they don't do anything...

  6. #6
    Join Date
    Jun 2010
    Location
    Germany
    Posts
    2,594

    Re: Making form constantly maximized

    Quote Originally Posted by Fides Facit Fortis View Post
    What do you mean? My form doesn't have any scrollbars attached by default and if I place them in the designer they don't do anything...
    Right, they don't have scroll bars by default. But adding scroll bars yourself using the designer (or programmatically) actually is hardly ever necessary and requres quite some programming effort on your side to make the whole thing behave reasonably.

    Instead, just set the form's AutoScroll property to true. Then the form wil automatically get equipped with scroll bars that behave like one would expect as soon as not all controls on the form are visible completely (or, in techno speak, there are controls that extend beyond the form's client area). (If you want your form to start up with scroll bars and only contain controls you placed there using the designer, you'd need to reduce the form's size after placing the controls but before the form is shown. You'd do that either manually in designer or programmatically at runtime.)

    I made controls in my form scale with the form's size upon load( so for example a button has 10% in form's width and 5% in form's height etc) so it should always fit into the form no matter what the screen size is.
    Sure, this is an option, but it may lead to an off-standard GUI design which usually isn't recommended. There is, however, a similar approach that's absolutely standard-conformant and commonly used: If the form is arranged around one or a few large controls like a text box, list view or the like, with some aditional smaller controls placed along the edges of the form, you may just adjust the big control(s) to form size changes while the smaller controls maintain their sizes and just adjust their positions if required. In many cases this can be achieved without any programming effort at all on your side, just by adequately setting up the Anchor properties of the controls at design time.

    This is a form where I used that approach in one of my own projects:

    Name:  FileAge.jpg
Views: 34
Size:  32.6 KB

    Here, the prevalent chart control is anchored to all edges, all other controls are anchored Bottom, Left, except for the Close button, which is anchored Bottom, Right.
    I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.

    This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.

  7. #7
    Join Date
    Mar 2014
    Posts
    13

    Re: Making form constantly maximized

    set the form's AutoScroll property to true
    THX!
    setting up the Anchor properties of the controls
    whoa thx a lot.Wondering why my book doesn't contain this information.It's so simple and usefull!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center