Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

C# Windows Form odd behavior (maximize)

Posted on 2009-07-13
5
Medium Priority
?
655 Views
Last Modified: 2013-12-17
I have an app where I need to position some objects based on user-defined settings (I'm using the Properties.Settings), so I can't simply use align and dock methods.  The application runs maximized and I only want to have the cancel button shown.

I'm using the form.clientsize property to help with object positioning and have uncovered some odd behavior.  If I set WindowState = maximized, the value of this.ClientSize will vary depending on how I set MinimizeBox and MaximizeBox (true/false).  I've realized that it's because with the Min and Max boxes disabled, the form will run full-screen and extend itself underneath the taskbar.  Seems odd to me.

Any idea why this happens?  More importantly, can anyone tell me how to run the form so that it maximizes only to the visible area, yet with the Min and Max buttons hidden?  I know I could manually find the working area of the screen and subtract out the height of the taskbar, but wanted to see if there was a more direct and logical way.

Thanks.

PS - I'm using VS 2008, and I know I'm not imagining things b/c I found this post describing the same thing:
http://bytes.com/groups/net/790544-vs2008-taskbar-hidden-when-windowstate-maximized-maximizebox-false
0
Comment
Question by:JCDBNRH
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
5 Comments
 
LVL 1

Expert Comment

by:smousavi
ID: 24843626
try this :

this.WindowState = FormWindowState.Maximized;

this will maximize the form programatically , no need to have a maximize button
0
 

Author Comment

by:JCDBNRH
ID: 24843665
Please re-read my posting.  I don't want to have a maximize button.  I am maximizing the form in the code at run-time.  The problem is that with the Min and Max buttons set to false, the form size is not accurate.
0
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 750 total points
ID: 24844041
You can get the "working area" DIRECTLY, thus removing any fudging/guesswork for the TaskBar size/position:

        private void Form1_Load(object sender, EventArgs e)
        {
            Rectangle working = Screen.GetWorkingArea(this);
            this.SetBounds(working.X, working.Y, working.Width, working.Height);
        }

0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 24844051
*This also takes into account any other AppBar type applications that have properly registered themselves with the system.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question