111,120
社区成员
发帖
与我相关
我的任务
分享
public virtual void Clear()
{
this.owner.SuspendLayout();
CommonProperties.xClearAllPreferredSizeCaches(this.owner);
try
{
while (this.Count != 0)
{
this.RemoveAt(this.Count - 1);
}
}
finally
{
this.owner.ResumeLayout();
}
}
public void RemoveAt(int index)
{
this.Remove(this[index]);
}
protected override void Dispose(bool disposing)
{
if (this.GetState(0x200000))
{
object obj2 = this.Properties.GetObject(PropBackBrush);
if (obj2 != null)
{
IntPtr handle = (IntPtr) obj2;
if (handle != IntPtr.Zero)
{
SafeNativeMethods.DeleteObject(new HandleRef(this, handle));
}
this.Properties.SetObject(PropBackBrush, null);
}
}
this.UpdateReflectParent(false);
if (disposing)
{
if (!this.GetState(0x1000))
{
if (this.GetState(0x40000))
{
throw new InvalidOperationException(SR.GetString("ClosingWhileCreatingHandle", new object[] { "Dispose" }));
}
this.SetState(0x1000, true);
this.SuspendLayout();
try
{
this.DisposeAxControls();
ContextMenu menu = (ContextMenu) this.Properties.GetObject(PropContextMenu);
if (menu != null)
{
menu.Disposed -= new EventHandler(this.DetachContextMenu);
}
this.ResetBindings();
if (this.IsHandleCreated)
{
this.DestroyHandle();
}
if (this.parent != null)
{
this.parent.Controls.Remove(this);
}
ControlCollection controls = (ControlCollection) this.Properties.GetObject(PropControlsCollection);
if (controls != null)
{
for (int i = 0; i < controls.Count; i++)
{
Control control = controls[i];
control.parent = null;
control.Dispose();
}
this.Properties.SetObject(PropControlsCollection, null);
}
base.Dispose(disposing);
}
finally
{
this.ResumeLayout(false);
this.SetState(0x1000, false);
this.SetState(0x800, true);
}
}
}
else
{
if (this.window != null)
{
this.window.ForceExitMessageLoop();
}
base.Dispose(disposing);
}
}
[EditorBrowsable(EditorBrowsableState.Advanced), SecurityPermission(SecurityAction.InheritanceDemand, Flags=SecurityPermissionFlag.UnmanagedCode), UIPermission(SecurityAction.LinkDemand, Window=UIPermissionWindow.AllWindows)]
protected virtual void DestroyHandle()
{
if (this.RecreatingHandle && (this.threadCallbackList != null))
{
lock (this.threadCallbackList)
{
if (threadCallbackMessage != 0)
{
NativeMethods.MSG msg = new NativeMethods.MSG();
if (UnsafeNativeMethods.PeekMessage(ref msg, new HandleRef(this, this.Handle), threadCallbackMessage, threadCallbackMessage, 0))
{
this.SetState(0x8000, true);
}
}
}
}
if (!this.RecreatingHandle && (this.threadCallbackList != null))
{
lock (this.threadCallbackList)
{
Exception exception = new ObjectDisposedException(base.GetType().Name);
while (this.threadCallbackList.Count > 0)
{
ThreadMethodEntry entry = (ThreadMethodEntry) this.threadCallbackList.Dequeue();
entry.exception = exception;
entry.Complete();
}
}
}
if ((0x40 & ((int) ((long) UnsafeNativeMethods.GetWindowLong(new HandleRef(this.window, this.InternalHandle), -20)))) != 0)
{
UnsafeNativeMethods.DefMDIChildProc(this.InternalHandle, 0x10, IntPtr.Zero, IntPtr.Zero);
}
else
{
this.window.DestroyHandle();
}
this.trackMouseEvent = null;
}
private void DisposeControls(Control cParent)
{
foreach (Control c in cParent.Controls)
{
DisposeControls(c);
c.Dispose();
}
}