我建立了单文档工程文件,想在单文档的主窗口弹出时,下半部分显示对话框,别人的能实现我的不行,求解,工程文件.cpp中的部分代码如下:
SetRegistryKey(_T("Local AppWizard-Generated Applications")); LoadStdProfileSettings();  // Load standard INI file options (including MRU)//  Register the application's document templates.  Document templates
//  serve as the connection between documents, frame windows and views.



SetDialogBkColor(RGB(210,230,210), RGB ( 0 ,0 , 0 ) );
    CSingleDocTemplate* pDocTemplate;
pDocTemplate = new CSingleDocTemplate(
IDR_MAINFRAME,
RUNTIME_CLASS(CWinPingDoc),
RUNTIME_CLASS(CMainFrame),       // main SDI frame window
RUNTIME_CLASS(SCANPLAN));    //SCANPLAN为我想显示的对话框对应的类
AddDocTemplate(pDocTemplate);          // Parse command line for standard shell commands, DDE, file open
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo); // Dispatch commands specified on the command line
if (!ProcessShellCommand(cmdInfo))
return FALSE;

// The one and only window has been initialized, so show and update it.
SCANPLAN *pDlg;
pDlg=new SCANPLAN;
    pDlg->Create(IDD_SCANPLAN_DIALOG,NULL);
pDlg->UpdateWindow();
pDlg->ShowWindow(SW_SHOW);
m_pMainWnd=pDlg;

m_pMainWnd->ShowWindow(SW_SHOW);
m_pMainWnd->UpdateWindow();
以上代码运行后对话框不在主窗口内部,都能显示,但不符合要求。谢谢高手解答。散分100!

解决方案 »

  1.   

     pDlg->Create(IDD_SCANPLAN_DIALOG,this);
      

  2.   

    pDlg->Create(IDD_SCANPLAN_DIALOG,this);
    这样报错,把this改为NULL就没错误。
      

  3.   

    知道为什么会错误么???
    你也不看看当前this指针完全建立好了么!当前窗口创建好了么?既然当前窗口么有创建好,那么请问你怎么把窗口显示在主窗口中?
    所以说你的代码要改!
    怎么改?自己去想想,比如说:OnCreate() OnInitialUpDate()等等函数之后再去执行窗口自己的窗口
      

  4.   

    还有,你的this指针是什么指针?我看你程序,发现你是在App程序中去创建窗口,所以this指针不是继承与Cwnd的类的指针,当然也会出错,最好的方法是在CMainFrame 的OnCreate函数最后加入你要创建的对话框的代码
      

  5.   

    zhouyongku:
    你好!以上的代码是在CMainFrame的InitInstance()函数里写的,刚才我又在Oncreate函数里试了一下,还是不行,你能给我讲讲吗?谢谢了。
      

  6.   

    直接把你的代码发到我邮箱,我瞬间就给你改了![email protected]
      

  7.   

    比方像word文档,上面有菜单栏,下面空白的地方可以写,就相当于是两个部分,我要实现的功能与这个类似,上面有菜单栏,下面显示的是我要显示的对话框,并作为主窗口。不知道有没有说清楚。
      

  8.   

    我把CDialog类改为CFormView后,有没有Create这个成员函数,种种问题快把我弄的烦死了了。
      

  9.   

    新建一个工程SDI,最后一步,View类的基类选择CFormView即可
      

  10.   

    在view类的OnInitialUpDate()函数中得到view类的RECT,再MoveWindow(&rect)就好了
      

  11.   

    zhouyongku
    现在怎么不说话了?刚才还大言不惭的说“瞬间”就改了?
    估计是改不出来吧?郁闷