我建立一个类CProcesswnd类,是机遇cwnd的.
然后定义一个对象 CProcesswnd* wndtest=new CProcesswnd;
可是  wndtest->hwnd为0X000000呢?

解决方案 »

  1.   

    CProcesswnd* wndtest=new CProcesswnd; 
    wndtest->Create(............);
      

  2.   

    1. Create
    2. MFC的 DDX_Control
    3. Attach
      

  3.   

    可以详细的吗,我不想建立一个window,想让他不可见,只让他能响应消息,请问这样做对吗?
      

  4.   

    1. Create 
    2. MFC的 DDX_Control 
    3. Attach
      

  5.   

    CWnd( );
    Constructs a CWnd object.The Windows window is not created and attached until the CreateEx or Create member function is called.
    也就是说,调用CWnd()并不能真正的创建对话框。Returns m_hWnd, or NULL if the this pointer is NULL.
    HWND GetSafeHwnd( ) const;
    Return Value
    Returns the window handle for a window. Returns NULL if the CWnd is not attached to a window or if it is used with a NULL CWnd pointer. 
    这个是对m_hWnd的解释。
    也就是说如果没有调用CreateEx,那么m_hWnd始终是NULL,所以没有办法使用。LZ所使用的方法,有没有用到m_hWnd,与界面的联系大吗?如果不大,则可以考虑把这些方法给提取出来,也就是
    所谓的把业务逻辑和用户界面给分开,这样就可以不创建这个窗口,而后使用。如果LZ非要那样,那就没有其他的办法,就创建,然后把它给隐藏起来,不让界面显示出来,然后使用了。
      

  6.   

    窗口对象要创建,即Create()后才会有句柄