Solved

Suppress form maximization on title double-click

Posted on 2010-11-18
3
310 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
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 85

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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

743 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now