The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: UPucker on August 28, 2005, 09:01:11 AM

Title: detecting focus
Post by: UPucker on August 28, 2005, 09:01:11 AM
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:           
Title: Re: detecting focus
Post by: Darrel on August 29, 2005, 02:20:15 AM
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
Title: Re: detecting focus
Post by: Tedd on August 29, 2005, 01:17:47 PM
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.)