Re: How to set focus to the previous app that had it?

Tech-Archive recommends: Fix windows errors by optimizing your registry



"Kerry" <Kerry@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:7BD48F63-F7D5-4EB9-B38A-84A6C357231A@xxxxxxxxxxxxxxxx
When my app first starts, it's going to grab the focus. I want to
immediately give focus back to the previous app that had it


It's easier not to grab the focus to begin with. Call ShowWindow
(SW_SHOWNOACTIVATE) and your window won't steal the focus.


Also, if somebody uses the mouse to interact with my app (drag etc), it
will
again grab the focus. When the user is done dragging, I'd again like to
immediately give focus back to the app it grabbed it from.


This is tricky. I tried storing the HWND passed to your OnSetFocus() which
is the window that previously had the focus. After the drag, call
SetForegroundWindow() for this HWND. But this didn't work. I think the
window wasn't accurate.

I think I ended up saving the old HWND in OnSetCursor(). But this was
awhile ago.

-- David


.



Relevant Pages

  • Re: Choosing between different COM servers?
    ... By the way, what about HWND? ... Window Handles are quaranteed unique for all running processes. ... be your main app. ... PCDInstance pcdInst; ...
    (microsoft.public.vb.com)
  • Re: Trapping Alt-F4
    ... I think 0x02BE is the HWND of the window erroneously processing the ... adjust the log settings in Spy++ to give you better output (such ... If so, you see my dilemma, what good is knowing the HWND if the app has ...
    (microsoft.public.vc.mfc)
  • Re: enlarging sites
    ... While the app box is small, grab the window and move it to the upper left of ... Then grab the lower right and drag it to your desired size. ... Close the app and it should open at the size you closed it. ... I tried to enlarge and file, end, but it does ...
    (microsoft.public.windowsxp.help_and_support)
  • Re: How Determine Window Title of Clipboard Owner
    ... If the window class ... I need to determine the application window title for the app that owns ... clipboard is the Owner (until an app Opens the clipboard with ... Is there a problem with this hWnd belonging to another Process? ...
    (microsoft.public.win32.programmer.kernel)
  • Re: FindDialogWindow?
    ... And if the other app was there it would catch the registered ... message and send the same message back with it's hwnd as the wparam. ... > I currently use FindWindow() to find a dialog window with a fixed title ...
    (microsoft.public.vc.mfc)