C # capture the event of minimizing and maximizing forms and closing button events in winform [arrangement]

Source: Internet
Author: User

After some forms are minimized, hide the pallets from the form to the bottom right corner.ProgramGenerally, the processing of several events and properties is not displayed in the task bar. After you click minimize, the system hides the pallets in the lower right corner. Click the tray icon to bring up the program interface. (You can search by yourself for the specific method. I will not write it because it is similar)

However, a problem occurred recently when I was working on a program. Even though it was not displayed in the taskbar after the minimization, the form was reduced to the lower left corner of the screen, and the result still could not be truly hidden.

However, I found out some previously written programs. It's okay to run them. The minimum number will not be reduced to the lower left corner of the screen,CodeThe same is true ~~ It's also a matter of character --!

Currently, this problem cannot be solved using the previous method. We look forward to expert answers ....

Okay, so I went to search for some information, that is, the following code, and solved it perfectly. So I started to study wndproc...

 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. toint32 () = SC _minimize) // whether to minimize the number of clicks {// write the operation code here this. visible = false; // hide the form return;} If (M. wparam. toint32 () = SC _maximize ){//.....................} if (M. wparam. toint32 () = SC _close ){//.....................}} base. wndproc (ref m);} // This function is used to capture the Minimize button event and hide the current form. 

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.