News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

detecting focus

Started by UPucker, August 28, 2005, 09:01:11 AM

Previous topic - Next topic

UPucker

What message is sent when focus is switched to another window? And when focus returns to my window?

I have a simple animation, and I want to stop it when another window is selected. And then restart it when my window is selected? The animation checks a flag to see if the focus is on it or another window.

I take it this is wrong

Part_6:
            cmp [uMsg],WM_KILLFOCUS
            jnz Part_7
            mov focus, 0
Part_7:           
            cmp [uMsg],WM_SETFOCUS
            jnz Part_8
            mov focus, 1
Part_8:           

Darrel

Hi UPucker,


Have a look at WM_ACTIVATE.

QuoteThe WM_ACTIVATE message is sent when a window is being activated or deactivated.

Hope this helps,

Darrel

Tedd

Both WM_SETFOCUS/KILLFOCUS and WM_ACTIVATE work fine -- the difference between them is quite sublte.
However, just to confuse you even more, there is also the WM_ACTIVATEAPP message, which is probably the most suitable for your needs -- it means your application is losing/gaining focus, not just one of its windows (which is only strictly important if you have multiple windows.)
No snowflake in an avalanche feels responsible.