SendMessage doesn't work when window has ShowInTaskbar set to false

B

Bobby D

I have two applications, one is sending a message, one is receiving.
The sending app's code is as follows:

------------------------------------------------------------------------
private void Main()
{
Process p = Process.GetProcessesByName("MyApp")[0];
SendMessage(p.MainWindowHandle, 0xA123, IntPtr.Zero, IntPtr.Zero);
}

[DllImport("user32.dll", CharSet=CharSet.Auto, SetLastError=true)]
private static extern IntPtr SendMessage(IntPtr hwnd, uint Msg, IntPtr
wParam, IntPtr lParam);

------------------------------------------------------------------------

The code for the window receiving the message is as follows:

------------------------------------------------------------------------

protected override void WndProc(ref Message m)
{
if(m.Msg == 0xA123)
{
MessageBox.Show("Called");
}
base.WndProc(ref m);
}

....

this.ShowInTaskbar = false;

------------------------------------------------------------------------

Messages are not received when ShowTaskbar is set to false. Any ideas
on solving this issue?

Thx
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top