private static IntPtr _WndProc(IntPtr hwnd, Standard.WM msg, IntPtr wParam, IntPtr lParam)
        {
            IntPtr zero = IntPtr.Zero;

            Standard.MessageWindow target = null;
            if (msg == Standard.WM.CREATE)
            {
                Standard.CREATESTRUCT createstruct = (Standard.CREATESTRUCT)Marshal.PtrToStructure(lParam, typeof(Standard.CREATESTRUCT));
                target = (Standard.MessageWindow)GCHandle.FromIntPtr(createstruct.lpCreateParams).Target;
                s_windowLookup.Add(hwnd, target);
            }
            else if (!s_windowLookup.TryGetValue(hwnd, out target))
            {
                return(Standard.NativeMethods.DefWindowProc(hwnd, msg, wParam, lParam));
            }
            Standard.WndProc proc = target._wndProcCallback;
            if (proc != null)
            {
                zero = proc(hwnd, msg, wParam, lParam);
            }
            else
            {
                zero = Standard.NativeMethods.DefWindowProc(hwnd, msg, wParam, lParam);
            }
            if (msg == Standard.WM.NCDESTROY)
            {
                target._Dispose(true, true);
                GC.SuppressFinalize(target);
            }
            return(zero);
        }
        public MessageWindow(Standard.CS classStyle, Standard.WS style, Standard.WS_EX exStyle, Rect location, string name, Standard.WndProc callback)
        {
            this._wndProcCallback = callback;
            this._className       = "MessageWindowClass+" + Guid.NewGuid().ToString();
            Standard.WNDCLASSEX lpwcx = new Standard.WNDCLASSEX {
                cbSize        = Marshal.SizeOf(typeof(Standard.WNDCLASSEX)),
                style         = classStyle,
                lpfnWndProc   = s_WndProc,
                hInstance     = Standard.NativeMethods.GetModuleHandle(null),
                hbrBackground = Standard.NativeMethods.GetStockObject(Standard.StockObject.NULL_BRUSH),
                lpszMenuName  = "",
                lpszClassName = this._className
            };
            Standard.NativeMethods.RegisterClassEx(ref lpwcx);
            GCHandle handle = new GCHandle();

            try
            {
                handle = GCHandle.Alloc(this);
                IntPtr lpParam = (IntPtr)handle;
                this.Handle = Standard.NativeMethods.CreateWindowEx(exStyle, this._className, name, style, (int)location.X, (int)location.Y, (int)location.Width, (int)location.Height, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, lpParam);
            }
            finally
            {
                handle.Free();
            }
        }