简体   繁体   English

MFC项目组合:如何将不带文档类的SDI应用程序添加到MDI应用程序?我应该使用子窗口吗?[MFC]

[英]MFC Project Combination: How to add a SDI application without document class to a MDI application?should I use child window?[MFC]

I'am now working with a MDI MFC app and want to add a console/command-line function to the app. 我现在正在使用MDI MFC应用程序,并希望向该应用程序添加控制台/命令行功能。 The only function I want to take from QuickWin(see below) is to use its text area and the process function which captures input. 我想从QuickWin中获取的唯一功能(请参见下文)是使用其文本区域和捕获输入的处理功能。 If I can add it to a popup dialog or a dock bar, it will be great! 如果我可以将其添加到弹出对话框或停靠栏中,那就太好了! And I got the src-code of a SDI Applization without Document Class like this( link:http://www.codeproject.com/.../QuickWin-... ): 而且我得到了没有文档类的SDI应用程序的src代码,像这样( link:http://www.codeproject.com /.../ QuickWin -... ):

My Question is: can I add the app into my MDI app, and how to deal with source or head files like: MainFrm.cpp/MainFrm.h and class like: CQuickWinApp/CQuickView?(If I can pop up a child window to implement the function, better:)) 我的问题是:我可以将该应用程序添加到我的MDI应用程序中,以及如何处理诸如MainFrm.cpp / MainFrm.h之类的源文件或头文件以及诸如CQuickWinApp / CQuickView之类的类吗?(如果可以弹出子窗口,实现功能,更好:))

在此处输入图片说明

In QuickWin's mainframe, it has something to do with client area, which is difficule to deal with: 在QuickWin的大型机中,它与客户区有关,这很难处理:

BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext) 
{
    // create splitter without views
    m_wndSplitter.CreateStatic(this, 2, 1);

    CCreateContext Context;
    Context.m_pNewViewClass = RUNTIME_CLASS(CQuickView);
    Context.m_pCurrentDoc = NULL;
    Context.m_pNewDocTemplate = NULL;
    Context.m_pLastView = NULL;
    Context.m_pCurrentFrame = this;

    // Create the Stdio QuickView
    m_pStdioView  = (CQuickView*)CreateView(&Context, AFX_IDW_PANE_FIRST);
    if (m_pStdioView == NULL)
    {
        TRACE("Failed to create QuickWin Stdio View\n");
        return FALSE;       // fail to create
    }

    // Create the Stderr QuickView
    m_pStderrView  = (CQuickView*)CreateView(&Context, AFX_IDW_PANE_FIRST);
    if (m_pStderrView == NULL)
    {
        TRACE("Failed to create QuickWin Stderr View\n");
        return FALSE;       // fail to create
    }
    m_pStderrView->SetReadOnly(TRUE);

    ShowSplitter(theApp.m_bShowSplitter);
    return TRUE;
}

in My MDI app: 在我的MDI应用中:

The MDI app has 3 doctemplates: MDI应用程序具有3个文档模板:

//BCGPVisualStudioGUIDemo.cpp //BCGPVisualStudioGUIDemo.cpp

m_pDocTemplateCpp = new CMultiDocTemplate(
    IDR_BCGDEVTYPE_CPP,
    RUNTIME_CLASS(CBCGPVisualStudioGUIDemoDoc),
    RUNTIME_CLASS(CChildFrame), // custom MDI child frame
    RUNTIME_CLASS(CBCGPVisualStudioGUIDemoView));
AddDocTemplate (m_pDocTemplateCpp);

m_pDocTemplateWeb = new CMultiDocTemplate(
    IDR_BCGDEVTYPE_WEB,
    RUNTIME_CLASS(CBCGPVisualStudioGUIDemoDoc),
    RUNTIME_CLASS(CChildFrame), // custom MDI child frame
    RUNTIME_CLASS(CBCGPVisualStudioGUIDemoView));
AddDocTemplate (m_pDocTemplateWeb);

m_pStartDocTemplate = new CMultiDocTemplate(
    IDR_BCGDEVTYPE0,
    RUNTIME_CLASS(CNetworkMapEditorDemoDoc),
    RUNTIME_CLASS(CChildFrame), // custom MDI child frame
    RUNTIME_CLASS(CNetworkMapEditorDemoView));
AddDocTemplate(m_pStartDocTemplate);

The app also has some dock bars: 该应用程序还具有一些停靠栏:

//MainFrm.cpp //MainFrm.cpp

    //------------------
    // Create config bar:
    //------------------    

if (!m_wndClassView.Create (_T("config"), this, CRect (0, 0, 200, 200),
        TRUE, 
        ID_VIEW_CLASS,
        WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_LEFT | CBRS_FLOAT_MULTI))
    {
        TRACE0("Failed to create Class View bar\n");
        return FALSE;      // fail to create
    }

    //------------------
    // Create output bar:
    //------------------

    if (!m_wndOutputView.Create (_T("output"), this, CRect (0, 0, 200, 100),
        TRUE, 
        ID_VIEW_OUTPUT,
        WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_BOTTOM | CBRS_FLOAT_MULTI))
    {
        TRACE0("Failed to create output bar\n");
        return FALSE;      // fail to create
    }

    //------------------
    // Create help bar:
    //------------------

    if (!m_wndDynamicHelpView.Create (_T("help"), this, CRect (0, 0, 200, 200),
        TRUE, 
        ID_VIEW_DYNAMICHELP,
        WS_CHILD | WS_VISIBLE | CBRS_RIGHT | CBRS_FLOAT_MULTI))
    {
        TRACE0("Failed to create Dynamic Help Bar\n");
        return FALSE;       // fail to create
    }

    //------------------
    // Create watch bar:
    //------------------

    if (!m_wndWatchBar.Create (_T("watch"), this, CRect (0, 0, 300, 100),
        TRUE, 
        ID_VIEW_WATCH,
        WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_BOTTOM | CBRS_FLOAT_MULTI))
    {
        TRACE0("Failed to create watch bar\n");
        return FALSE;      // fail to create
    }

    //------------------
    // Create property bar:
    //------------------

    if (!m_wndPropertiesBar.Create (_T("property"), this, CRect (0, 0, 300, 200),
        TRUE, 
        ID_VIEW_PROPERTIES,
        WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_RIGHT | CBRS_FLOAT_MULTI))
    {
        TRACE0("Failed to create Properties Bar\n");
        return FALSE;       // fail to create
    }

Can I add the QuickWin app's text function into my app's dock bar or into a doctemplate or just a popup window? 是否可以将QuickWin应用程序的文本功能添加到应用程序的停靠栏中或文档模板中,或者仅添加一个弹出窗口?

All you need to integrate the functionality of QuickWin into your application are 3 textboxes (one for stdin, stdout and stderr) and the following classes from the Quickwin project: 您需要将QuickWin的功能集成到您的应用程序中的是三个文本框(一个用于stdin,stdout和stderr),以及来自Quickwin项目的以下类:

  • CRedirect C重定向
  • CRedir CRedir
  • CParamDlg (only optical fluff, not essential) CParamDlg(仅绒毛,不是必需的)

The CRedirect-class manages the creation of the new process as well as the redirection of stdin/stdout/stderr (in combination with CRedir). CRedirect类管理新进程的创建以及stdin / stdout / stderr的重定向(与CRedir结合使用)。

You have to modify CRedir::OnChildWrite and -Started and -Terminate to fit your needs. 您必须修改CRedir::OnChildWrite以及CRedir::OnChildWriteCRedir::OnChildWrite以适合您的需求。 These methods actually write the content to the view/textbox/whatever. 这些方法实际上将内容写入视图/文本框/任何内容。 It is helpful to look at CMainFrame::OnCopyData and CQuickView::Append on how this can be done. 查看CMainFrame::OnCopyDataCQuickView::Append对如何完成此操作很有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM