C # disable closing and dragging forms. [vulnerability]

Source: Internet
Author: User

 

* I also copied it from others. It is okay to disable it. Of course, you only need to disable it in the Process Manager. Haha

If you do not want to drag, you can use the icon menu on the left of the title bar to drag the form.

[The solution should be this. position]

 

Private const int SC _close = 0xf060; <br/> private const int mf_enabled = 0x00000000; <br/> private const int mf_grayed = 0x00000001; <br/> private const int mf_disabled = 0x00000002; </P> <p> [dllimport ("user32.dll", entrypoint = "getsystemmenu")] <br/> Private Static extern intptr getsystemmenu (intptr hwnd, int brevert); <br/> [dllimport ("user32.dll")] <br/> Public static extern bool enablemenuitem (intptr hmenu, int uidenableitem, int uenable); </P> <p> private void form1_load (Object sender, eventargs E) <br/>{< br/> intptr hmenu = getsystemmenu (this. handle, 0); <br/> enablemenuitem (hmenu, SC _close, mf_disabled | mf_grayed ); </P> <p >}</P> <p> protected override createparams <br/>{< br/> Get <br/>{< br/> const int cs_noclose = 0 x200; <br/> createparams CP = base. createparams; <br/> CP. classstyle = CP. classstyle | cs_noclose; <br/> return CP; <br/>}</P> <p> protected override void wndproc (ref message m) <br/>{< br/> base. wndproc (ref m); </P> <p> If (M. MSG = 0x84 & M. result = (intptr) 2) // do not drag the title bar <br/>{< br/> M. result = (intptr) 1; <br/>}< br/> If (M. MSG = 0xa3) // double-click the title bar without any response <br/>{< br/> M. wparam = system. intptr. zero; <br/>}</P> <p>}

 

 

 

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.