winform和vb中锁定窗体和控件

    在vb中和wifnorm中锁定窗体需要调用api,下面分别说下是如何调用的。

vb:

Private Declare Function EnableWindow Lib "user32" (ByVal hwnd As Long, ByVal fEnable As Long) As Long

锁定:  EnableWindow Me.hwnd, 0

解锁:EnableWindow Me.hwnd, 1

winform:

 [DllImport("user32", CharSet = CharSet.Auto)]
        public static extern int EnableWindow(IntPtr   hwnd,bool bEnable );

锁定:EnableWindow(this.Handle,false);

解锁:EnableWindow(this.Handle,true);

锁定控件和窗体一样的,控件.Handle

你可能感兴趣的:(winform和vb中锁定窗体和控件)