internal static IntPtr ApplicationMessageFilter( IntPtr hwnd, int message, IntPtr wParam, IntPtr lParam, ref bool handled) { // Handle messages passed to the visual. switch (message) { // Handle the left and right mouse button up messages. case WM_LBUTTONUP: case WM_RBUTTONUP: System.Windows.Point pt = new System.Windows.Point(); pt.X = (uint)lParam & (uint)0x0000ffff; // LOWORD = x pt.Y = (uint)lParam >> 16; // HIWORD = y MyShape.OnHitTest(pt, message); break; } return(IntPtr.Zero); }