I have an older vb6 app I am working with and a new one in c# and use SendMessage to send messages between them, with the c# program working functionally as a form within the vb6 app.
Sometimes, and not with a pattern I can see, messages do not get sent to the c# program. This can usually be corrected by clicking on the c# program in taskbar and then going back to the vb6 app and trying again at which point it will start working again.
When it is not working I am able to put a breakpoint in the WndProc method and see that it does not trigger.
I have been unable to figure out how to make this communication inconsistent.
Code handling this:
protected override void WndProc(ref Message message)
{
if (message.Msg == 0x400 + 5)
{
if (message.LParam != (IntPtr)0)
{
StringBuilder += (char)message.LParam;
}
else
{
handleIncMessage(StringBuilder);
StringBuilder = "";
}
}
//be sure to pass along all messages to the base also
base.WndProc(ref message);
}
I tried this method: https://stackoverflow.com/a/7033382/821665 but unfortunately it did not work.