dssbljth 2015-06-01 08:55 采纳率: 100%
浏览 1593
已采纳

MFC实现一个SDI程序,要求

MFC实现一个SDI程序,要求包含一个对话框,输入文字,运用文件读写技术,将文字画在窗体上

  • 写回答

2条回答

  • devmiao 2015-06-01 09:04
    关注
     新建一个叫CSDIDlgApp的程序
    
    在你的Doc里面加入
    public:
        CString text;
    
    void CSDIDlgAppView::OnDraw(CDC* pDC)
    {
        CSDIDlgAppDoc* pDoc = GetDocument();
        ASSERT_VALID(pDoc);
        // TODO: add draw code for native data here
        pDC->TextOut(0, 0, pDoc->text);
    }
    
    新建一个对话框叫CEditDlg
    映射文本框m_text
    
    void CEditDlg::OnOK() 
    {
        // TODO: Add extra validation here
        this->UpdateData();
        CDialog::OnOK();
    }
    
    新建一个菜单
    ID_EDITDLG
    
    在Frame中
    #include "editdlg.h"
    #include "SDIDlgAppDoc.h"
    
    
    void CMainFrame::OnEditdlg() 
    {
        // TODO: Add your command handler code here
        CEditDlg dlg;
        if (dlg.DoModal() == IDOK)
        {
            ((CSDIDlgAppDoc *)this->GetActiveDocument())->text = dlg.m_text;
            this->GetActiveDocument()->UpdateAllViews(NULL);
        }
    }
    
    void CMainFrame::OnFileSave() 
    {
        // TODO: Add your command handler code here
        CFileDialog dlg(FALSE);
        dlg.DoModal();
        CFile file(dlg.GetFileName(), CFile::modeCreate | CFile::modeWrite); 
        CArchive ar(&file, CArchive::store);
        ar << ((CSDIDlgAppDoc *)this->GetActiveDocument())->text;
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog