该窗口创建信息如下:
CalWndClassName =AfxRegisterWndClass (CS_BYTEALIGNWINDOW | CS_PARENTDC | CS_SAVEBITS, 
     ::LoadCursor (NULL, IDC_ARROW));
dwStyle=WS_CHILD |WS_BORDER, CWnd::CreateEx (WS_EX_TOOLWINDOW,
   CalWndClassName, 
   NULL,
   dwStyle,
   Rect.left,
   Rect.top,
   Rect.Width(),
   Rect.Height(),
   GetDesktopWindow()->GetSafeHwnd(), 
   (HMENU) NULL);

解决方案 »

  1.   

    我记得使控件获得焦点是发一个WM_SetFocus消息,你只要改写这个窗口的窗口函数,使系统先调用你的窗口函数,从而使你的函数先截获此消息,并且阻断这个消息的传递,这样可是控件无法获得焦点.
      

  2.   

    WS_EX_TOOLWINDOW本身就获取不了焦点
      

  3.   

    不好意思,上面有误, 可以这样
    m_cWnd.SetWindowPos(&wndTop, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
    m_cWnd是你创建的窗口对象
      

  4.   

    vcmute(横秋) :这不是一个dialog。这是继承于cwnd的一个窗口对象。
    goodboyws(深夜不眠者) m_cWnd.SetWindowPos(&wndTop, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
    没有用。
    在这个创建的窗口中动态创建一个CEdit控件。我在cdialog用同样的实现方法就可以获得焦点。
      

  5.   

    CWnd::SetForegroundWindow();ResPuts the thread that created the window into the foreground and activates the window. Keyboard input is directed to the window, and various visual cues are changed for the user. The foreground window is the window with which the user is currently working. The foreground window applies only to top-level windows (frame windows or dialogs boxes).