CMyWnd继承于CWnd。已知如果父窗口是某个对话框的话那么没有任何问题。可以用getfocus获取焦点。
但是父窗口是桌面时,使用如下方法无法获得焦点:getfocus,SetForegroundWindow ,setwindowpos等等 。请问如何解决。

解决方案 »

  1.   

    CMyWnd是WS_CHILD风格的窗口,恐怖啊
      

  2.   

    GetFocus returns the window with the keyboard focus for the current thread's message queue. If GetFocus returns NULL, another thread's queue may be attached to a window that has the keyboard focus.
      

  3.   

    ChenJF206(峰)  it is right, but how i can get another thread's queue??
      

  4.   

    这个就不太清楚了,要用钩子吧。
    你试下
    GetDesktopWindow()->GetFocus();
    看有没获取到焦点
      

  5.   

    使用偷梁换柱的方法,当创建这个窗口时使用本身程序的某个窗口做父窗口,然后getfocus候再setparent(桌面)。但是这样焦点失去候不能再次获得,除非再次切换父窗口。
    不知对你是否有用。