Page 1 of 1

PostPosted: Tue Nov 05, 2002 12:50 pm
by chrisleeuk
Does anyone know of an easy way to capture an event when an application gains or looses focus?

I am using the eventmsg command to details windows events and messages.

PostPosted: Tue Nov 05, 2002 9:09 pm
by guy
I don't think you can do it with eventmsg(), or with the current version of CEAPI.

The new version of CEAPI has a method of capturing windows messages that are sent directly to a window rather than being queued. To use it you would have to use the full windows messaging CEAPI setup, declare that you want to watch WM_ACTIVATE (I think) messages to the main window, then handle them in your message loop.

You can only watch messages to windows that are created with the CEAPI CreateWindow() and CreateWindowEx() functions, which means that you need to define the CEAPI_WIN32 macro before including any of the header files, then create your own application class and main window. You can then call CEAPISetRepost() for WM_ACTIVATE on the main window.

I'll try to remember to update the header files so that they actually contain WM_ACTIVATE when I release the CEAPI update.

I don't think that you can do it with normal PocketC. You might try looking for PM_PAINT messages going to GUIID 1.

PocketC CE API interface:
PCForm and CE API forum: