1[System.Runtime.InteropServices.DllImport ("user32.dll")]2 PublicStaticexternintSetWindowLong (IntPtr hWnd,intNIndex,intWndProc);3[System.Runtime.InteropServices.DllImport ("user32.dll")]4 PublicStaticextern intGetWindowLong (IntPtr hWnd,intnIndex);5 6 PublicConstintGwl_style =- -;7 Public Constintws_disabled =0x8000000;8 9 PublicStaticvoidSetcontrolenabled (Control C,BOOLenabled)Ten { Oneif(enabled) A{SetWindowLong (C.handle, Gwl_style, (~ws_disabled) &GetWindowLong (C.handle, Gwl_style)); } -Else -{SetWindowLong (C.handle, Gwl_style, ws_disabled +GetWindowLong (C.handle, Gwl_style)); } the } - -PrivatevoidButton2_Click (Objectsender, System.EventArgs e) - { +Setcontrolenabled ( This. button1,false); - This. button1. ForeColor =Color.White; +}
This action does not directly change the enable but removes its mouse bindings
C # enable to False when invariant color