Send window message to WPF application from another WPF application
<p>I used this code in the server side</p>

<pre><code>    void Window_Loaded(object sender, RoutedEventArgs e)
    {

        HwndSource source = HwndSource.FromHwnd(new WindowInteropHelper(this).Handle);
        source.AddHook(new HwndSourceHook(WndProc));

    }
    private IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
    {
        // Handle messages...

            var htLocation = DefWindowProc(hwnd, msg, wParam, lParam).ToInt32();

            if (msg == 1)
            {
            MessageBox.Show("" + msg);
            }


        return new IntPtr(1);
    }
</code></pre>

<p>And I send the message from the client side like this</p>

<pre><code>SendMessage(m_Process.MainWindowHandle, 1, (IntPtr)(-1), (IntPtr)(-1));
</code></pre>

<p>The problem is that the server side cannot receive this message, why?</p>