毕设用mfc编程

bysjcg 2016-04-11 03:35:35
在主对话框中添加菜单,用菜单分别关联了几个子对话框,为什么成功运行完一个子对话框关闭后再点菜单弹出另一个对话框运行就会崩溃?

整个程序用到了画图,和简单的输入输出
...全文
92 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
bysjcg 2016-04-11
  • 打赏
  • 举报
回复
[code=c// bianq_dlg.cpp : implementation file // #include "stdafx.h" #include "zong2.h" #include "bianq_dlg.h" #include "matlib.h" #include "bianquancg.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // bianq_dlg dialog bianq_dlg::bianq_dlg(CWnd* pParent /*=NULL*/) : CDialog(bianq_dlg::IDD, pParent) { //{{AFX_DATA_INIT(bianq_dlg) m_f = _T("f.txt"); m_x1 = _T("x1.txt"); m_m = 3; m_n = 8; m_wenjian = _T("qwe.txt"); m_alf1 = 0.2; m_alf2 = 0.4; m_em = 0.0; //}}AFX_DATA_INIT IsFirse1 = true; } void bianq_dlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(bianq_dlg) DDX_Text(pDX, IDC_EDIT_alf1, m_alf1); DDX_Text(pDX, IDC_EDIT_alf2, m_alf2); DDX_Text(pDX, IDC_EDIT_em, m_em); DDX_Text(pDX, IDC_EDIT_f, m_f); DDX_Text(pDX, IDC_EDIT_m, m_m); DDX_Text(pDX, IDC_EDIT_n, m_n); DDX_Text(pDX, IDC_EDIT_wenjian, m_wenjian); DDX_Text(pDX, IDC_EDIT_x1, m_x1); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(bianq_dlg, CDialog) //{{AFX_MSG_MAP(bianq_dlg) ON_BN_CLICKED(IDC_BUTTON1, OnButton1) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // bianq_dlg message handlers void bianq_dlg::OnButton1() { // TODO: Add your control notification handler code here UpdateData(true); initM(MATCOM_VERSION); Mm File_Name_c1 ,File_Name_c2, E1_m,File_Name_c3; int Length_Name1, Length_Name2, Length_Name3 ; ///////////////////////// Length_Name1 = m_f.GetLength(); File_Name_c1 = zeros(1,Length_Name1); for(int i = 1; i < Length_Name1+1; i++) File_Name_c1.r(i) = m_f[i-1]; ///////////////////////// Length_Name2 = m_x1.GetLength(); File_Name_c2 = zeros(1,Length_Name2); for( i = 1; i < Length_Name2+1; i++) File_Name_c2.r(i) = m_x1[i-1]; ///////////////////////// Length_Name3 = m_wenjian.GetLength(); File_Name_c3 = zeros(1,Length_Name3); for( i = 1; i < Length_Name3 +1; i++) File_Name_c3.r(i) = m_wenjian[i-1]; ////////////画图区域初始化//////////////// clf(); //figure((CL(1.0))); Mm plothandle1; //设定画图区域 CWnd *p1 = NULL; p1 = (CWnd *)GetDlgItem(IDC_STATIC_tu); plothandle1 = winaxes(p1->m_hWnd); if(IsFirse1 == true) { IsFirse1 = false; figure_close(); } E1_m = bianquancg(m_n, m_m, m_alf1, m_alf2, File_Name_c1 ,File_Name_c2,File_Name_c3 ); m_em = E1_m.r(1,1); UpdateData(false); exitM(); } ][/code]
bysjcg 2016-04-11
  • 打赏
  • 举报
回复
主对话框 // zong2Dlg.cpp : implementation file // #include "stdafx.h" #include "zong2.h" #include "zong2Dlg.h" #include "zhibycl_dlg.h" #include "bianq_dlg.h" #include "ccfx_dlg.h" #include "mohpg_dlg.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CAboutDlg dialog used for App About class CAboutDlg : public CDialog { public: CAboutDlg(); // Dialog Data //{{AFX_DATA(CAboutDlg) enum { IDD = IDD_ABOUTBOX }; //}}AFX_DATA // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(CAboutDlg) protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support //}}AFX_VIRTUAL // Implementation protected: //{{AFX_MSG(CAboutDlg) //}}AFX_MSG DECLARE_MESSAGE_MAP() }; CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD) { //{{AFX_DATA_INIT(CAboutDlg) //}}AFX_DATA_INIT } void CAboutDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CAboutDlg) //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) //{{AFX_MSG_MAP(CAboutDlg) // No message handlers //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CZong2Dlg dialog CZong2Dlg::CZong2Dlg(CWnd* pParent /*=NULL*/) : CDialog(CZong2Dlg::IDD, pParent) { //{{AFX_DATA_INIT(CZong2Dlg) // NOTE: the ClassWizard will add member initialization here //}}AFX_DATA_INIT // Note that LoadIcon does not require a subsequent DestroyIcon in Win32 m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); } void CZong2Dlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CZong2Dlg) // NOTE: the ClassWizard will add DDX and DDV calls here //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CZong2Dlg, CDialog) //{{AFX_MSG_MAP(CZong2Dlg) ON_WM_SYSCOMMAND() ON_WM_PAINT() ON_WM_QUERYDRAGICON() ON_COMMAND(ID_MENUITEM32771, OnMenuitem_zbycl) ON_COMMAND(ID_MENUITEM32772, OnMenuitem_ccfx) ON_COMMAND(ID_MENUITEM32773, OnMenuitem_bquan) ON_COMMAND(ID_MENUITEM32774, OnMenuitem_mohpg) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CZong2Dlg message handlers BOOL CZong2Dlg::OnInitDialog() { CDialog::OnInitDialog(); // Add "About..." menu item to system menu. // IDM_ABOUTBOX must be in the system command range. ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX); ASSERT(IDM_ABOUTBOX < 0xF000); CMenu* pSysMenu = GetSystemMenu(FALSE); if (pSysMenu != NULL) { CString strAboutMenu; strAboutMenu.LoadString(IDS_ABOUTBOX); if (!strAboutMenu.IsEmpty()) { pSysMenu->AppendMenu(MF_SEPARATOR); pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu); } } // Set the icon for this dialog. The framework does this automatically // when the application's main window is not a dialog SetIcon(m_hIcon, TRUE); // Set big icon SetIcon(m_hIcon, FALSE); // Set small icon // TODO: Add extra initialization here return TRUE; // return TRUE unless you set the focus to a control } void CZong2Dlg::OnSysCommand(UINT nID, LPARAM lParam) { if ((nID & 0xFFF0) == IDM_ABOUTBOX) { CAboutDlg dlgAbout; dlgAbout.DoModal(); } else { CDialog::OnSysCommand(nID, lParam); } } // If you add a minimize button to your dialog, you will need the code below // to draw the icon. For MFC applications using the document/view model, // this is automatically done for you by the framework. void CZong2Dlg::OnPaint() { if (IsIconic()) { CPaintDC dc(this); // device context for painting SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0); // Center icon in client rectangle int cxIcon = GetSystemMetrics(SM_CXICON); int cyIcon = GetSystemMetrics(SM_CYICON); CRect rect; GetClientRect(&rect); int x = (rect.Width() - cxIcon + 1) / 2; int y = (rect.Height() - cyIcon + 1) / 2; // Draw the icon dc.DrawIcon(x, y, m_hIcon); } else { CDialog::OnPaint(); } } // The system calls this to obtain the cursor to display while the user drags // the minimized window. HCURSOR CZong2Dlg::OnQueryDragIcon() { return (HCURSOR) m_hIcon; } void CZong2Dlg::OnMenuitem_zbycl() { // TODO: Add your command handler code here zhibycl_dlg infodlg; infodlg.DoModal(); } void CZong2Dlg::OnMenuitem_ccfx() { // TODO: Add your command handler code here ccfx_dlg infodlg; infodlg.DoModal(); } void CZong2Dlg::OnMenuitem_bquan() { // TODO: Add your command handler code here bianq_dlg infodlg; infodlg.DoModal(); } void CZong2Dlg::OnMenuitem_mohpg() { // TODO: Add your command handler code here mohpg_dlg infodlg; infodlg.DoModal(); }
bysjcg 2016-04-11
  • 打赏
  • 举报
回复
qq_34502495 2016-04-11
  • 打赏
  • 举报
回复
把代码贴出来才好分析,看这个没什么用哦,目测可能是内存泄漏问题, 查看一下你所定义的指针初始化和释放问题。
cang1994cang 2016-04-11
  • 打赏
  • 举报
回复
这个错误报的是未知异常代码,你放下程序看看
qq_34502495 2016-04-11
  • 打赏
  • 举报
回复
也可能是你使用了中文没有注释掉,都有可能 这个问题我也遇到过,不过得看你的源代码才懂,最好是复制放上来
bysjcg 2016-04-11
  • 打赏
  • 举报
回复

16,472

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧