HIWORD() static private method

static private HIWORD ( IntPtr value ) : int
value System.IntPtr
return int
Beispiel #1
0
        /// <summary>
        /// Process Windows-based messages.
        /// </summary>
        /// <param name="m">A Windows-based message.</param>
        protected override void WndProc(ref Message m)
        {
            // We need to snoop the need to show a context menu
            if (m.Msg == PI.WM_CONTEXTMENU)
            {
                // Only interested in overriding the behavior when we have a krypton context menu...
                if (KryptonContextMenu != null)
                {
                    // Extract the screen mouse position (if might not actually be provided)
                    Point mousePt = new Point(PI.LOWORD(m.LParam), PI.HIWORD(m.LParam));

                    // If keyboard activated, the menu position is centered
                    if (((int)((long)m.LParam)) == -1)
                    {
                        mousePt = new Point(Width / 2, Height / 2);
                    }
                    else
                    {
                        mousePt = PointToClient(mousePt);

                        // Mouse point up and left 1 pixel so that the mouse overlaps the top left corner
                        // of the showing context menu just like it happens for a ContextMenuStrip.
                        mousePt.X -= 1;
                        mousePt.Y -= 1;
                    }

                    // If the mouse posiiton is within our client area
                    if (ClientRectangle.Contains(mousePt))
                    {
                        // Show the context menu
                        KryptonContextMenu.Show(this, PointToScreen(mousePt));

                        // We eat the message!
                        return;
                    }
                }
            }

            if (!IsDisposed)
            {
                base.WndProc(ref m);
            }
        }
        private bool ProcessNonClientMouseDown(ref Message m)
        {
            // Extract the x and y mouse position from message
            Point screenPt = new Point(PI.LOWORD((int)m.LParam), PI.HIWORD((int)m.LParam));

            // Ask the popup if this message causes the entire stack to be killed
            if (_current.DoesCurrentMouseDownEndAllTracking(m, ScreenPtToClientPt(screenPt)))
            {
                EndAllTracking();
            }

            // Do any of the current popups want the mouse down to be eaten?
            bool processed = false;

            if (_current != null)
            {
                processed = _current.DoesMouseDownGetEaten(m, screenPt);
                if (!processed)
                {
                    // Search from end towards the front, the last entry is the most recent 'Push'
                    VisualPopup[] popups = _stack.ToArray();
                    for (int i = 0; i < popups.Length; i++)
                    {
                        // Ignore disposed popups
                        VisualPopup popup = popups[i];
                        if (!popup.IsDisposed)
                        {
                            processed = popup.DoesMouseDownGetEaten(m, screenPt);
                            if (processed)
                            {
                                break;
                            }
                        }
                    }
                }
            }

            return(processed);
        }