ClearCanvas.Desktop.View.WinForms.BindingTreeView.XTreeView.WndProc C# (CSharp) Method

WndProc() protected method

protected WndProc ( Message &m ) : void
m System.Windows.Forms.Message
return void
			protected override void WndProc(ref Message m)
			{
				// intercept the message that sets the state image list, and pass on a fixed image list
				// instead of the modified 16x16 version. the control will take care of the internal
				// modified image list it created - we just need to handle disposal for our own image list
				const int TVSIL_STATE = 2;
				if (m.Msg == (int) WindowsMessages.TVM_SETIMAGELIST)
				{
					if (_fixedInternalStateImageList != null)
					{
						DisposeAll(_fixedInternalStateImageList.Images);
						_fixedInternalStateImageList.Dispose();
						_fixedInternalStateImageList = null;
					}

					if (m.WParam.ToInt32() == TVSIL_STATE && m.LParam != IntPtr.Zero && this.StateImageList != null)
					{
						// setup a new image list as a rough clone of the real one
						_fixedInternalStateImageList = new ImageList();
						_fixedInternalStateImageList.ColorDepth = this.StateImageList.ColorDepth;
						_fixedInternalStateImageList.ImageSize = this.StateImageList.ImageSize;
						_fixedInternalStateImageList.TransparentColor = this.StateImageList.TransparentColor;

						// add the dummy image (we still need to do this because otherwise the image indexes are shifted by 1)
						_fixedInternalStateImageList.Images.Add(string.Empty, new Bitmap(1, 1));

						// copy over the original images
						for (int n = 0; n < this.StateImageList.Images.Count; n++)
							_fixedInternalStateImageList.Images.Add((Image) this.StateImageList.Images[n].Clone());

						m.LParam = _fixedInternalStateImageList.Handle;
					}
				}
				base.WndProc(ref m);
			}
		}