C # Overload WndProc, implementation of overriding "Minimize" _c# tutorial

Source: Internet
Author: User
Code #1
Copy Code code as follows:

private void Form1_sizechanged (object sender, EventArgs e)//Minimize hidden form
if (this. WindowState = = formwindowstate.minimized)//form state is minimized
stoprecttimer.enabled = false;
This. Visible = false;
This.notifyIcon1.Visible = true; Show system tray icon
This.notifyIcon1.Text = this. Text; Set the text that the icon displays
This. ShowInTaskbar = false; The form is hidden in the task mark
Reghotkey ();
Open Otoolstripmenuitem.text = "open (&o)";

Obviously, if you open the lyric state, how can you minimize the size of the form without changing it? I think of overloading "minimize", but how to overload it? A scheme for overloading WndProc is given here:
Copy Code code as follows:

const int wm_syscommand = 0x112;
Const int sc_close = 0xf060;
Const int sc_minimize = 0xf020;
Const int sc_maximize = 0xf030;
protected override void WndProc (ref message m)
if (m.msg = = Wm_syscommand)
if (m.wparam.to Int32 () = = Sc_minimize)
this. Visible = false;
base. WndProc (ref m);
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.