Turn off the button to gray

Source: Internet
Author: User
[Dllimport ("user32.dll")] public static extern int getsystemmenu (INT hwnd, int brevert); [dllimport ("user32.dll")] public static extern int removemenu (INT hmenu, int nposition, int wflags); // <summary> // return value. If the value is not zero, the operation is successful. If the value is zero, the operation fails. /// </Summary> /// <Param name = "ihwnd"> handle of the window </param> /// <returns> whether the window is successful </returns> Public int removexbutton (INT ihwnd) {int isysmenu; const int mf_bycommand = 0x400; // 0x400-Disable isysmenu = getsystemmenu (this. handle. toint32 (), 0); Return removemenu (isysmenu, 6, mf_bycommand);} private void form1_load (Object sender, eventargs E) {// you can determine whether the objective is achieved through the return value of the function. In the constructor, you can determine whether the objective is achieved: int ireturn = removexbutton (this. h Andle. toint32 (); If (ireturn = 0) // If the returned value is non-zero, the operation succeeds. If the returned value is zero, the operation fails. {MessageBox. Show ("error! ");} Else {MessageBox. Show (" success! ");}}

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.