messagewindow not listening after losing focus

Y

yusuf

Hey guys,

I have 2 CF apps where one sends message and the other listens
through a messagewindow. The problem occurs when focus is taken away
from the listener app (e.g. by starting up another app), from that
point on the messagewindow
no longer receives messages even though the sender app is still
sending them. I was wondering if any of you have run into this problem
or have ideas as to what's going on.

Yusuf

Here is some of the code that does the communication:

sender:
Win32_PostMessage(new
IntPtr(HWND_BROADCAST),RegisterWindowMessage(TRIGGER),0, IntPtr.Zero);

receiver (the messagewindow is created in a form):
private int WM_TRIGGER_ID = -1;

public myMessageWindow()
{
WM_TRIGGER_ID = RegisterWindowMessage(TRIGGER)
}

protected override void WndProc(ref Message msg)
{
if (msg.Msg == WM_TRIGGER_ID)
//do stuff
base.WndProc(ref msg);
}
 
A

Alex Feinman [MVP]

Try using CESpy to see if the window is still there and what messages if any
it receives.
The message window can be told from other window by its window class
NETCF_AGL_MSG, or by handle.
 
M

Mohammad Yusuf Haroon

Well I am running the listener app in debug mode and it does not get any
messages after I switch to another app and back i.e. WndProc never gets
called.
 
M

Mohammad Yusuf Haroon

Could it be that once the application loses focus and I come back to it, the
messagewindow is no longer the "top level window" (that is to whom the
broadcast message is sent)? And if that is the case, is there a way around
it?
 
A

Alex Feinman [MVP]

I guess it is possible. Why don't you send the message directly to the
window?
 
M

Mohammad Yusuf Haroon

Then the sender app has to somehow know the windows handle of the
messagewindow in the listener app. But I guess if broadcasting doesn't work,
I'll have to go with that. Thnx for the help Alex.

p.s. I tried using CESpy to look for messages, I can see the window list but
when I click on a specific window, the message button stays disabled so I
cant use the program to look for messages.
 
M

Mohammad Yusuf Haroon

The application class has a couple of useful functions. Thanks for the
direction.
 

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