自己的窗口不一定是激活的窗口,但是一定要显示到最前面,那位高手知道

解决方案 »

  1.   

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

  2.   

    SetWindowPos(HWND,HWND_TOPMOST,0,0,0,0,SWP_NOMOVE);
      

  3.   

    同意上述方法,如果你的程序有闪屏,在2000,xp下运行时,会有一些问题,
    以下方法较好:
    在2K/XP下我们可以用 AttachThreadInput 和SetForegroundWindow来有效的获取焦点。//捕捉并设置当前焦点窗口为我们的窗口
    AttachThreadInput(
        GetWindowThreadProcessId(
            ::GetForegroundWindow(),NULL),
        GetCurrentThreadId(),TRUE);//置我们的为焦点窗口
    SetForegroundWindow();
    SetFocus(); //释放thread
    AttachThreadInput(
        GetWindowThreadProcessId(
            ::GetForegroundWindow(),NULL),
        GetCurrentThreadId(),FALSE);
      

  4.   

    BOOL SetForegroundWindow( );
      

  5.   

    int rsAlwaysTop(LPSTR WINTITLE, bool onTop){
      HWND hd=FindWindow(NULL,WINTITLE);  if(hd)
        return SetWindowPos(hd,onTop ? HWND_TOPMOST : HWND_NOTOPMOST,0,0,0,0,3);
      return 0;
    }