Beispiel #1
0
        /*-- Initialize ListBox display -------------------------*/

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            Win32MsgForDisplay msg = new Win32MsgForDisplay();

            msg.msg         = "Message";
            msg.value       = String.Format("{0}", "Msg Value");
            msg.renderCount = String.Format("{0}", "Render Count");
            listBox1.Items.Insert(0, msg);

            // Had to wait to add hook until after the window was completed
            src.AddHook(new HwndSourceHook(HandleMessages));
        }
Beispiel #2
0
        /*-- Hook to Handle Win32 Messages ----------------------*/

        IntPtr HandleMessages(IntPtr hwnd, int message, IntPtr wParam, IntPtr lParam, ref bool handled)
        {
            string name = MessageNameLookup(message);

            if (name != "")
            {
                // don't show mouse messages unless user requests it

                if (name != "WM_MOUSEMOVE" | (bool)checkBox1.IsChecked)
                {
                    Win32MsgForDisplay msg = new Win32MsgForDisplay();
                    msg.msg         = name;
                    msg.value       = String.Format("{0:X}", message);
                    msg.renderCount = String.Format("{0}", RenderCount);
                    listBox1.Items.Insert(1, msg);
                }
            }
            return(System.IntPtr.Zero);
        }