System.Windows.Forms.NativeForm.SetNativeEnabled C# (CSharp) Method

SetNativeEnabled() protected method

Natively disables the current form window. Using this method disables / Enables the current form without disabling the underlying controls, thus preventing the form's controls from going grey.
By disabling this form natively, using Form.Show(this) on a new form allows it to display just like a dialog modal (Ex: Form.ShowDialog(this)), but without blocking the thread
protected SetNativeEnabled ( bool enabled ) : void
enabled bool Indicates whether this form is Enabled (true) or Disabled (false)
return void
        protected void SetNativeEnabled(bool enabled)
        {
            SetWindowLong(
                Handle,
                GWL_STYLE,
                GetWindowLong(Handle, GWL_STYLE) & ~WS_DISABLED | (enabled ? 0 : WS_DISABLED)
            );
        }