Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
Windos
win32.3rdparty
win32.directx.audio
win32.directx.ddk
win32.directx.graphics
win32.directx.input
win32.directx.managed
win32.directx.misc
win32.directx.networking
win32.directx.sdk
win32.directx.video
win32.dirx.grap.shaders
win32.gdi
win32.international
win32.kernel
win32.messaging
win32.mmedia
win32.networks
win32.ole
win32.rtc
win32.tapi
win32.tapi.beta
win32.tools
win32.ui
win32.wince
win32.wmi
windows.mediacenter
winfx.aero
winfx.announcements
winfx.avalon
winfx.collaboration
winfx.fundamentals
winfx.general
winfx.indigo
winfx.sdk
winfx.winfs
  
 
date: Thu, 7 Aug 2008 15:22:25 +0100,    group: microsoft.public.win32.programmer.ui        back       


Restoring focus on WM_ACTIVATEAPP   
Hello all,

I have an (unmanaged) GUI application. The top-level window has a number of 
child windows any of which may have the focus at any one time.

If I alt tab away from the application and then back again the focus is 
always given to the top-level window, regardless of which child window had 
the focus when the app was left.

I've tried saving the focused window at WM_ACTIVATEAPP (wParam==0) and 
restoring it at WM_ACTIVATEAPP (wParam!=0) but the focus is still later 
given to the top level window. A debug breakpoint on WM_SETFOCUS doesn't 
help because that is always called from GetMessage, so I can't see the 
callstack of what called SetFocus().

So, how do I restore focus whence it came when my application is made 
active?

Thanks,

/john
date: Thu, 7 Aug 2008 15:22:25 +0100   author:   JohnD

Re: Restoring focus on WM_ACTIVATEAPP   
"JohnD" wrote:
> I have an (unmanaged) GUI application. The top-level window has 
> a number of child windows any of which may have the focus at any 
> one time.
>
> If I alt tab away from the application and then back again the 
> focus is always given to the top-level window, regardless of 
> which child window had the focus when the app was left.

This is very strange. I have never done anything special to 
maintain a focus in one of child windows. It happens 
automatically. You can test it with any application that contains 
child windows, for example, Windows Explorer. When you Alt+Tab 
between windows pay attention to the window in focus. It is always 
the same window that was before Window Explorer has lost input 
focus.

Alex
date: Thu, 7 Aug 2008 18:15:51 +0300   author:   Alex Blekhman

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us