小弟在编程的过程中碰到这样一个难题,在单文档视图中,窗口分成左右两部分,左边嵌入一个form视图,右面是程序生成的框架,我现在的问题是,怎么通过点击左边form视图的一个按钮,右边框架显示一个对话框程序,此对话框是一个完整的可执行程序,要求此对话框程序很好的嵌在右边的框架内。我找了很多资料,不知道怎么搞定,往高手指点一二。

解决方案 »

  1.   

    Form视图向右边框架发送一消息,在框架的消息处理函数中显示对话框。
      

  2.   

    左边响应事件,然后运行对话框程序(用WinExec等),
    然后用MoveWindow吧
      

  3.   

    在按钮函数里ShellExecute(NULL,"open","calc.exe","","",SW_SHOW );打开你的对话框应用程序。FindWindow得到对话框程序的句柄再SetWindowPos
      

  4.   

    我相信这个一定是你要找的:void CFromView::OnButton2() 
    {
    CMainFrame *mainf=(CMainFrame *)::AfxGetApp()->GetMainWnd();
    CWnd *parent=mainf->m_split.GetPane(0,1);
        //打程序
    ShellExecute(NULL,"open","notepad.exe","","",SW_SHOW );

    CWnd *temp=this->GetDesktopWindow()->GetWindow(HLD_CHILD);
    CString txtcap;
    while(temp)
    {
    temp->GetWindowText(txtcap);
    if(txtcap="未定标题 - 记事本"))
    {
    temp->SetParent(parent);
    break;
    }
     
    temp=temp->GetWindow(HLD_NEXT); }
    }
      

  5.   

    楼上的正解,不过while的时候判断条件是(NULL==temp),找到窗口的以后,计算位置,然后movewindow或者setwindowpos都可以,
      

  6.   

    对不起上面的两个参数错了:
    这下面的是对了我试过:
    void CFromView::OnButton2() 
    {
    CMainFrame *mainf=(CMainFrame *)::AfxGetApp()->GetMainWnd();
    CWnd *parent=mainf->m_split.GetPane(0,1);
        //打程序
    ShellExecute(NULL,"open","notepad.exe","","",SW_SHOW );

    CWnd *temp=this->GetDesktopWindow()->GetWindow(GW_CHILD);
    CString txtcap;
    while(temp)
    {
    temp->GetWindowText(txtcap);
    if(txtcap=="未定标题 - 记事本")
    {
    temp->SetParent(parent);
    break;
    }
     
    temp=temp->GetWindow(GW_HWNDNEXT); }
    }