Exemplo n.º 1
0
        private IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
        {
            RECT rect;

            switch ((WM)msg)
            {
            case WM.SHOWWINDOW:
                if ((int)lParam == 3 && this.Visibility != Visibility.Visible) // 3 == SW_PARENTOPENING
                {
                    handled = true;                                            //handle this message so window isn't shown until we want it to
                }
                break;

            case WM.MOUSEACTIVATE:
                handled = true;
                if (this.ownerHandle != IntPtr.Zero)
                {
                    Standard.NativeMethods.SendMessage(this.ownerHandle, Standard.WM.ACTIVATE, wParam, lParam);
                }
                return(new IntPtr(3));

            case WM.LBUTTONDOWN:
                if (this.ownerHandle != IntPtr.Zero && UnsafeNativeMethods.GetWindowRect(this.ownerHandle, out rect))
                {
                    Point pt;
                    if (WinApiHelper.TryGetRelativeMousePosition(this.handle, out pt))
                    {
                        NativeMethods.PostMessage(this.ownerHandle, (uint)WM.NCLBUTTONDOWN, (IntPtr)this.getHitTestValue(pt, rect), IntPtr.Zero);
                    }
                }
                break;

            case WM.NCHITTEST:
                Cursor cursor = null;
                if (this._owner.ResizeMode == ResizeMode.NoResize || this._owner.ResizeMode == ResizeMode.CanMinimize)
                {
                    cursor = this._owner.Cursor;
                }
                else
                {
                    if (this.ownerHandle != IntPtr.Zero && UnsafeNativeMethods.GetWindowRect(this.ownerHandle, out rect))
                    {
                        Point pt;
                        if (WinApiHelper.TryGetRelativeMousePosition(this.handle, out pt))
                        {
                            cursor = this.getCursor(pt, rect);
                        }
                    }
                }
                if (cursor != null && cursor != this.Cursor)
                {
                    this.Cursor = cursor;
                }
                break;
            }
            return(IntPtr.Zero);
        }
Exemplo n.º 2
0
 internal void UpdateCore(Native.RECT rect)
 {
     NativeMethods.SetWindowPos(this.handle, this.ownerHandle,
                                (int)(this.getLeft(rect)),
                                (int)(this.getTop(rect)),
                                (int)(this.getWidth(rect)),
                                (int)(this.getHeight(rect)),
                                SWP.NOACTIVATE);
 }