Esempio n. 1
0
        private IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
        {
            if (msg == (int)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
                }
            }
            if (msg == (int)WM.MOUSEACTIVATE)
            {
                handled = true;
                return(new IntPtr(3));
            }

            if (msg == (int)WM.LBUTTONDOWN)
            {
                var pt = new Point((int)lParam & 0xFFFF, ((int)lParam >> 16) & 0xFFFF);
                SafeNativeMethods.PostMessage(ownerHandle, (uint)WM.NCLBUTTONDOWN, (IntPtr)getHitTestValue(pt), IntPtr.Zero);
            }
            if (msg == (int)WM.NCHITTEST)
            {
                var    ptScreen = new Point((int)lParam & 0xFFFF, ((int)lParam >> 16) & 0xFFFF);
                Point  ptClient = PointFromScreen(ptScreen);
                Cursor cursor   = getCursor(ptClient);
                if (cursor != Cursor)
                {
                    Cursor = cursor;
                }
            }

            return(IntPtr.Zero);
        }