我想做个程序,可以把某个程序设定为当前窗口,不知道有什么办.用
pActiveWnd=this->GetForegroundWindow();可以获取当前窗口,但是却不能用
this->SetForegroundWindow()来将某个窗口设定为当前窗口.
请各位老兄指教.

解决方案 »

  1.   

    this->SetForegroundWindow()
    是设置this为当前窗口吧?
    你要“某个”?得使用::SetForegroundWindow(hnd???)
      

  2.   

    获得那个窗口的句柄,然后调用SetForegroundWindow
      

  3.   

    窗口的指针已经知道啦,但就是用SetForegroundWindow()不起任何作用的
    不能设定为当前窗口
      

  4.   

    这样的问题,可以挨个试试SetActiveWindow、SetFocus、SetForegroundWindow,如果都不行,可能BringWindowToTop可以起到作用
      

  5.   

    看到一段代码,这是将自己设为当前窗口,要设定“某个”,稍微改改就好了。
    AttachThreadInput(GetWindowThreadProcessId(::GetForegroundWindow(),NULL), GetCurrentThreadId(),TRUE);
    SetForegroundWindow();
    SetFocus(); 
    AttachThreadInput(GetWindowThreadProcessId(::GetForegroundWindow(),NULL), GetCurrentThreadId(),FALSE);