Re: Bring top-level window to the front

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Janusz (erfan_at_poczta.onet.pl)
Date: 09/28/04


Date: Tue, 28 Sep 2004 13:20:20 +0200


> void CMFCHelper::ActivateAndShowWnd(CWnd *pWnd)
> {
> DWORD tMe,tTop;
>
> tMe=GetCurrentThreadId();
> tTop=GetWindowThreadProcessId(GetForegroundWindow(),NULL);
> if (tMe!=tTop){
> AttachThreadInput(tTop,tMe,TRUE);
> pWnd->SetForegroundWindow();
> pWnd->SetFocus();
> AttachThreadInput(tTop,tMe,FALSE);
> } else {
> pWnd->SetForegroundWindow();
> pWnd->SetFocus();
> }
> }
>
> Regards / Ruben

Thanks, I found this function some time ago in the net but it also failed to
do what I need.
For those who are interested, here's the tip:
The SetForegroundWindow description in the MSDN explains why it is so hard
to bring any window to the top and how it can be achived (the only problem
is that it works only for WINVER >= 5.0)

Best
Janusz



Relevant Pages

  • Re: Logoff / Slow Bootups / Outlook attachements / Outlook Not res
    ... With regards to trying the administrator log on this problem only actually ... click to check the "Hide All Microsoft Services" ... Click OK to close the MSConfig window. ... attach. ...
    (microsoft.public.windows.server.sbs)
  • Re: Why cant I see static variables in debug window
    ... Best regards ... HDC hdc; ... Auto pane of the variable window, because you're about to use it (to add ... you can use the Locals pane to see everything... ...
    (microsoft.public.windowsce.embedded)
  • Fehribach to Guido
    ... window. ... Her software was front, novel, and regards next to the ... jurisdiction. ...
    (sci.crypt)
  • YA Win skeleton
    ... Locals - window handle, window class structure and message structure ... fmul dword [onep5] ... fld dword ... i resd 1 ...
    (alt.lang.asm)
  • Re: Logoff / Slow Bootups / Outlook attachements / Outlook Not res
    ... Sorry for taking so long to get back to you with regards to these issues. ... and when the Shut down Windows dialogue window opens the only option they get ... We have had SBS W2K3 running for a long time now with very few problems ... ipconfig /all> c:\serverip.txt ...
    (microsoft.public.windows.server.sbs)