Solved

Suppress form maximization on title double-click

Posted on 2010-11-18
3
318 Views
Last Modified: 2012-06-21
I'm using c# 4.0. I have a form that has a title bar. I want to suppress the ability to maximize the form by double clicking it.

I've tried

 
private void Form1_Load(object sender, EventArgs e) {
this.SetStyle(ControlStyles.StandardDoubleClick, false);
this.UpdateStyles();
}

Open in new window


but that doesn't do it. I've tried trapping the click event but don't know how to suppress it.

Ideas?
0
Comment
Question by:BlearyEye
[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
3 Comments
 
LVL 28

Expert Comment

by:strickdd
ID: 34168152
Do you allow resizing of the window? If not, make sure you specify the max window size. If you do allow resizing, I don't think this can be changed.
0
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 500 total points
ID: 34168304
Like this?
http://www.experts-exchange.com/Programming/Languages/C_Sharp/Q_24050566.html

Code:
public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        const int HTCAPTION = 0x2;
        const int WM_NCLBUTTONDBLCLK = 0xA3;

        protected override void WndProc(ref Message m)
        {
            switch (m.Msg)
            {
                case WM_NCLBUTTONDBLCLK:
                    if (m.WParam.ToInt32() == HTCAPTION)
                    {
                        return;
                    }
                    break;
            };
            base.WndProc(ref m);
        }

    }

Open in new window

0
 
LVL 1

Author Closing Comment

by:BlearyEye
ID: 34168976
Perfect, thanksl
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

726 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