priyamtheone's Profile User Rating: -----

Reputation: 2 Apprentice
Active Members
Active Posts:
75 (0.03 per day)
02-September 08
Profile Views:
Last Active:
User is offline Mar 30 2014 08:56 AM

Previous Fields

Dream Kudos:

Latest Visitors

Icon   priyamtheone has not set their status

Posts I've Made

  1. In Topic: Detecting mouse button down & up events on the system menu of form

    Posted 30 Mar 2014

    Here’s what I found. Though it’s not exactly what I originally posted for but at least it narrows down to my requirement.

    Instead of identifying separately if the user clicked the Close button at the top right corner of the title bar of the form or the ‘Close’ option in the system menu, or he/she pressed the Alt+F4 keys, we can combine these factors together to check if the user is consuming the system command (i.e. any of the above three techniques) to close the form or is doing so programmatically. If the system command is used, action is taken accordingly; else we ignore.

    A button is used to close down the form programmatically without any interruption.

    public partial class Form1 : Form
            private const int WM_SYSCOMMAND = 0x0112;
            private const int SC_CLOSE = 0xF060;
            public Form1()
            protected override void WndProc(ref Message m)
                // Check if the user is consuming the system command to close the form.
                if ((m.Msg == WM_SYSCOMMAND) && ((int)m.WParam == SC_CLOSE))
                    MessageBox.Show("Form closing by system command. Take necessary actions here...");
                base.WndProc(ref m);
            private void btnClose_Click(object sender, EventArgs e)

My Information

Member Title:
D.I.C Head
Age Unknown
Birthday Unknown

Contact Information

Click here to e-mail me


priyamtheone hasn't added any friends yet.


priyamtheone has no profile comments yet. Why not say hello?