src/Misc/EFTools/DesignXmlCore/VirtualTreeGrid/UI/VirtualTreeControl.cs
/// <summary>
///     Called when a mouse message is received by the inplace control. This callback
///     should only be used by controls that need to support transparent edit regions.
/// </summary>
/// <param name="message">Message structure passed to WndProc</param>
/// <returns>True to indicate that the message has been handled and should not be forwarded to base.WndProc</returns>
Called when a mouse message is received by the inplace control. This callback
should only be used by controls that need to support transparent edit regions.
Called when a mouse message is received by the inplace control . This callback should only be used by controls that need to support transparent edit regions .
public override bool OnMouseMessage(ref Message message)
            {
                if (Parent != null)
                {
                    var messageId = message.Msg;
                    if (NativeMethods.WM_MOUSEFIRST <= messageId
                        && messageId <= NativeMethods.WM_MOUSELAST)
                    {
                        var correspondingDownMessage = 0;
                        var correspondingDoubleClickMessage = 0;
                        switch (messageId)
                        {
                            case NativeMethods.WM_LBUTTONDBLCLK:
                            case NativeMethods.WM_MBUTTONDBLCLK:
                            case NativeMethods.WM_RBUTTONDBLCLK:
                            case NativeMethods.WM_XBUTTONDBLCLK:
                            case NativeMethods.WM_MOUSEMOVE:
                                {
                                    var loc = InPlaceControl.Location;
                                    message.Result = NativeMethods.SendMessage(
                                        Parent.Handle, messageId, (int)message.WParam,
                                        NativeMethods.MAKELONG(
                                            NativeMethods.SignedLOWORD(message.LParam) + loc.X,
                                            NativeMethods.SignedHIWORD(message.LParam) + loc.Y));
                                    return true;
                                }
                            case NativeMethods.WM_MOUSEWHEEL:
                                message.Result = NativeMethods.SendMessage(
                                    Parent.Handle, messageId, (int)message.WParam, (int)message.LParam);
                                return true;
                            case NativeMethods.WM_LBUTTONDOWN:
                            case NativeMethods.WM_RBUTTONDOWN:
                            case NativeMethods.WM_MBUTTONDOWN:
                            case NativeMethods.WM_XBUTTONDOWN:
                                if (myLaunchMessage == messageId)
                                {
                                    myLaunchMessage = -messageId;
                                }
                                else
                                {
                                    myLaunchMessage = 0;
                                }
                                break;
                            case NativeMethods.WM_LBUTTONUP:
                                correspondingDownMessage = NativeMethods.WM_LBUTTONDOWN;
                                correspondingDoubleClickMessage = NativeMethods.WM_LBUTTONDBLCLK;
                                break;
                            case NativeMethods.WM_MBUTTONUP:
                                correspondingDownMessage = NativeMethods.WM_MBUTTONDOWN;
                                correspondingDoubleClickMessage = NativeMethods.WM_MBUTTONDBLCLK;
                                break;
                            case NativeMethods.WM_RBUTTONUP:
                                correspondingDownMessage = NativeMethods.WM_RBUTTONDOWN;
                                correspondingDoubleClickMessage = NativeMethods.WM_RBUTTONDBLCLK;
                                break;
                            case NativeMethods.WM_XBUTTONUP:
                                correspondingDownMessage = NativeMethods.WM_XBUTTONDOWN;
                                correspondingDoubleClickMessage = NativeMethods.WM_XBUTTONDBLCLK;
                                break;
                        }
                        if (correspondingDownMessage != 0
                            && myLaunchMessage != 0)
                        {
                            if (myLaunchMessage == -correspondingDownMessage)
                            {
                                myLaunchMessage = 0; 
                                var testTime = NativeMethods.GetMessageTime();
                                if ((testTime > myLaunchMessageTime)
                                    && ((testTime - myLaunchMessageTime) <= SystemInformation.DoubleClickTime))
                                {
                                    var loc = InPlaceControl.Location;
                                    NativeMethods.SendMessage(
                                        Parent.Handle, correspondingDoubleClickMessage, (int)message.WParam,
                                        NativeMethods.MAKELONG(
                                            NativeMethods.SignedLOWORD(message.LParam) + loc.X,
                                            NativeMethods.SignedHIWORD(message.LParam) + loc.Y));
                                }
                            }
                            else
                            {
                                myLaunchMessage = 0; 
                            }
                        }
                    }
                }
                return false;
            }
public override bool OnMouseMessage ( ref Message message ) { if ( Parent != null ) { var messageId = message . Msg ; if ( NativeMethods . WM_MOUSEFIRST <= messageId && messageId <= NativeMethods . WM_MOUSELAST ) { var correspondingDownMessage = 0 ; var correspondingDoubleClickMessage = 0 ; switch ( messageId ) { case NativeMethods . WM_LBUTTONDBLCLK : case NativeMethods . WM_MBUTTONDBLCLK : case NativeMethods . WM_RBUTTONDBLCLK : case NativeMethods . WM_XBUTTONDBLCLK : case NativeMethods . WM_MOUSEMOVE : { var loc = InPlaceControl . Location ; message . Result = NativeMethods . SendMessage ( Parent . Handle , messageId , ( int ) message . WParam , NativeMethods . MAKELONG ( NativeMethods . SignedLOWORD ( message . LParam ) + loc . X , NativeMethods . SignedHIWORD ( message . LParam ) + loc . Y ) ) ; return true ; } case NativeMethods . WM_MOUSEWHEEL : message . Result = NativeMethods . SendMessage ( Parent . Handle , messageId , ( int ) message . WParam , ( int ) message . LParam ) ; return true ; case NativeMethods . WM_LBUTTONDOWN : case NativeMethods . WM_RBUTTONDOWN : case NativeMethods . WM_MBUTTONDOWN : case NativeMethods . WM_XBUTTONDOWN : if ( myLaunchMessage == messageId ) { myLaunchMessage = - messageId ; } else { myLaunchMessage = 0 ; } break ; case NativeMethods . WM_LBUTTONUP : correspondingDownMessage = NativeMethods . WM_LBUTTONDOWN ; correspondingDoubleClickMessage = NativeMethods . WM_LBUTTONDBLCLK ; break ; case NativeMethods . WM_MBUTTONUP : correspondingDownMessage = NativeMethods . WM_MBUTTONDOWN ; correspondingDoubleClickMessage = NativeMethods . WM_MBUTTONDBLCLK ; break ; case NativeMethods . WM_RBUTTONUP : correspondingDownMessage = NativeMethods . WM_RBUTTONDOWN ; correspondingDoubleClickMessage = NativeMethods . WM_RBUTTONDBLCLK ; break ; case NativeMethods . WM_XBUTTONUP : correspondingDownMessage = NativeMethods . WM_XBUTTONDOWN ; correspondingDoubleClickMessage = NativeMethods . WM_XBUTTONDBLCLK ; break ; } if ( correspondingDownMessage != 0 && myLaunchMessage != 0 ) { if ( myLaunchMessage == - correspondingDownMessage ) { myLaunchMessage = 0 ; var testTime = NativeMethods . GetMessageTime ( ) ; if ( ( testTime > myLaunchMessageTime ) && ( ( testTime - myLaunchMessageTime ) <= SystemInformation . DoubleClickTime ) ) { var loc = InPlaceControl . Location ; NativeMethods . SendMessage ( Parent . Handle , correspondingDoubleClickMessage , ( int ) message . WParam , NativeMethods . MAKELONG ( NativeMethods . SignedLOWORD ( message . LParam ) + loc . X , NativeMethods . SignedHIWORD ( message . LParam ) + loc . Y ) ) ; } } else { myLaunchMessage = 0 ; } } } } return false ; }
Called when a mouse message is received by the inplace control.
Called when a mouse message is received by the inplace control .
// Don't pass through down/up as these have lots of side effects that are // very invasive to work around (like constantly refreshing the selection). However, // pushing through double clicks and mouse moves enables tooltips and double // click actions on the underlying control. // UNDONE: See if we can get drag-drop working correctly. May have to forward directly // with a new helper method as LBUTTONDOWN has lots of other side effects (like grabbing focus) // These messages all have client coordinates packed into the lparam. We need to adjust the // coordinates into client coordinates of the parent, then let the parent handle the message. // Only check once // Only check once
True to indicate that the message has been handled and should not be forwarded to base.WndProc
True to indicate that the message has been handled and should not be forwarded to base . WndProc
Message
ref
message
Message structure passed to WndProc
Message structure passed to WndProc