C #: Isolate the "minimize or restore" effect when clicking on an icon on the taskbar

Source: Internet
Author: User

When you usually click on the icon on the taskbar, the corresponding form implements the "Minimize or restore" effect. However, when minimizing to the tray, do not want to click the taskbar icon to minimize to the tray, that is, you want to intercept these effects (do not allow: by clicking on the taskbar icon, to achieve "minimize or restore" effect);

The specific implementation code is as follows:

        #regionClick on the form icon in the taskbar (Minimize | restore) and click the Minimize buttonPrivate intWm_syscommand =0x112; Private LongSc_minimize =0xf020; protected Override voidWndProc (refMessage m) {            if(M.msg = =Wm_syscommand) {                if(M.wparam.toint64 () = = Sc_minimize && m.lparam.tostring ()! ="0")//m.lparam.tostring ()! = "0" means click on the form icon in the taskbar (minimized | recovery){hidemainform ();//here, the form diagram is directly formatted//this.isminboxhited = true; //Clicking on the Minimize button is not possible through the middle variable.                    return; }            }            Base. WndProc (refm); }        #endregion
View Code

If you want to achieve other effects, you can refer to the following:

    Private intWm_syscommand =0x112; Private LongSc_maximize =0xf030; Private LongSc_minimize =0xf020; Private LongSc_close =0xf060; protected Override voidWndProc (refMessage m) {          if(M.msg = =Wm_syscommand) {              if(M.wparam.toint64 () = =sc_maximize) {                  //MessageBox.Show ("maximize");                 return; }              if(M.wparam.toint64 () = =sc_minimize) {                  //MessageBox.Show ("MINIMIZE");                 return; }              if(M.wparam.toint64 () = =sc_close) {                  //MessageBox.Show ("CLOSE");                 return; }          }          Base. WndProc (refm); }  
View Code

C #: Isolate the "minimize or restore" effect when clicking on an icon on the taskbar

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.