继承一个类,cwnd,在把cwnd改为cdialog。
在另外一个类中定义一个对象。我用m_mydialog.createEx();
创建不起来啊。请大大提出一个可行方案。

解决方案 »

  1.   

    直接继承CDialog不行,需要控件id,那就好像要加入对话框,我想创建一个纯代码的对话框。
      

  2.   

    CDialog 类或子类中的 Create 函数,都是根据对话框模板的,你不提供一个模板给它,它怎么创建呢?要不你试试在该类的构造函数中,用 CreateWindowEx() 函数创建一个吧
    或者自己写一个 CreateEx 函数来覆盖默认的,然后在里面调用 CreateWindowEx 函数
      

  3.   

    但是我调用的是CreateEx啊。他是cwnd的函数啊。
    cwnd就是对CreateWindowEx的封装。有必要去调用createWindowEx吗?
      

  4.   

    还有:
    HWND CreateWindowEx(
      DWORD dwExStyle,      // extended window style
      LPCTSTR lpClassName,  // registered class name
      LPCTSTR lpWindowName, // window name
      DWORD dwStyle,        // window style
      int x,                // horizontal position of window
      int y,                // vertical position of window
      int nWidth,           // window width
      int nHeight,          // window height
      HWND hWndParent,      // handle to parent or owner window
      HMENU hMenu,          // menu handle or child identifier
      HINSTANCE hInstance,  // handle to application instance
      LPVOID lpParam        // window-creation data
    );
    用CreateWindowEx的hInstance要怎么得到呢?
      

  5.   

    如果要创建对话框,就需要有一个对话框模板(通常用资源的形式)。
    如果要创建一个非对话框窗口,可以自己注册一个类,然后用CreateWindowEx创建。
      

  6.   

    直接继承CDialog,然后把id删了