我在A类,继承于CButton类,弹出B类,(B类使用api方式创建,是一个窗口),
   我的程序里要求B类窗口弹出时,B类窗口并不得到焦点,(当前焦点并不改变)。
   

解决方案 »

  1.   

    使用SetFocus或者SetForeGroundwindow之类的把A类的窗口再设为有焦点
      

  2.   

    如果你显示B类的时候用的是ShowWindow的话,你可以这样调用ShowWindow(SW_SHOWNA);
    也可以重载CWnd,处理WM_SHOWWINDOW,在OnShowWindow(BOOL bShow,UINT nStatus);中激活窗口A
      

  3.   

    都不行啊,是我描述的不够清楚?我是这么做的啊
    HWND hWnd = ::CreateWindowEx(WS_EX_TOPMOST,"11","11",WS_POPUP|WS_BORDER|WS_VISIBLE,rect.left,rect.top,rect.Width(),rect.Height(),m_hWnd,NULL,wndcls.hInstance,NULL);
    ::ShowWindow(hWnd,SW_SHOWNA);
      

  4.   

    HWND hWnd = ::CreateWindowEx(WS_EX_TOPMOST,"11","11",WS_POPUP|WS_BORDER|WS_VISIBLE,rect.left,rect.top,rect.Width(),rect.Height(),m_hWnd,NULL,wndcls.hInstance,NULL); 
    ::ShowWindow(hWnd,SW_SHOWNA);
    ::SetActiveWindow(m_hWnd);
      

  5.   

    创建的时候去掉:WS_EX_TOPMOSTWS_EX_TOPMOST :
        Specifies that a window created with this style should be placed above all non-topmost windows and should stay above them, even when the window is deactivated. To add or remove this style, use the SetWindowPos function.