我在win2000和xp下用BringWindowToTop只有第一能成功,后面窗口只有在任务栏闪
烁。请问大家有没有好方法确保每次都能弹到最前面。

解决方案 »

  1.   

    用SetWindowPos(),第一个参数有&wndTopMost
      

  2.   

    SetWindowPos(wndTopMost, 0, 0, 0, 0, SWP_NOSIZE);
      

  3.   

    SetWindowPos(&wndTopMost, 0, 0, 0, 0, SWP_NOSIZE);
      

  4.   

    上述方法与BringWindowToTop效果一样,只能第一次成功。
      

  5.   

    可以使用 Undocument API SwitchToThisWindow,Win 95/98/ME/NT/2000/XP
    有效:void WINAPI SwitchToThisWindow ( 
         HWND hWnd,    // Handle to the window that should be activated 
         BOOL bRestore // Restore the window if it is minimized 
    ); 该函数只能通过 GetProcAddress 获取:
    typedef void (WINAPI *LPSWITCHTOTHISWINDOW)(HWND, BOOL); LPSWITCHTOTHISWINDOW lpfnSwitchToThisWindow;lpfnSwitchToThisWindow = (LPSWITCHTOTHISWINDOW) GetProcAddress( GetModuleHandle(_T("user32")), _T("SwitchToThisWindow") ); 
      

  6.   

    ::SetWindowPos(AfxGetMainWnd()->m_hWnd,HWND_TOPMOST,
        -1,-1,-1,-1,SWP_NOMOVE/SWP_NOSIZE);
      

  7.   

    多谢大家了,可能是由于我的不是主窗口,所以只有 yaotang(baobao) 的方法灵光。