|
马上注册,结交更多同行朋友,交流,分享,学习。
您需要 登录 才可以下载或查看,没有帐号?注册
x
VC++中MFC建立的应用程序关闭对话框时出现“0x21016d9f指令引用的0xccccccc8内存,该内存不能为read”!
请问高手这是怎么回事?是不是内存释放有问题,或者没有调用析构函数?
部分代码如下:
// bianxiaodlg.cpp : implementation file
//
#include "stdafx.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#include "featuremodeling.h"
#include "bianxiaodlg.h"
#include <stdio.h>
#include <math.h>
#include <uf.h>
#include <uf_defs.h>
#include <uf_exit.h>
#include <uf_ui.h>
#include <uf_styler.h>
#include <uf_mb.h>
#include <uf_part_types.h>
#include <uf_part.h>
#include <uf_modl.h>
#include <uf_obj.h>
#include <uf_obj_types.h>
#include <windows.h>
#include <Winuser.h>
/////////////////////////////////////////////////////////////////////////////
// Cbianxiaodlg dialog
Cbianxiaodlg::Cbianxiaodlg(CWnd* pParent /*=NULL*/)
: CDialog(Cbianxiaodlg::IDD, pParent)
{
//{{AFX_DATA_INIT(Cbianxiaodlg)
//}}AFX_DATA_INIT
}
void Cbianxiaodlg:: DoDataExchange(CDataExchange* pDX)
{
CDialog:: DoDataExchange(pDX);
//{{AFX_DATA_MAP(Cbianxiaodlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(Cbianxiaodlg, CDialog)
//{{AFX_MSG_MAP(Cbianxiaodlg)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// Cbianxiaodlg message handlers
BOOL Cbianxiaodlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
UpdateData(TRUE);
PLD=(CEdit *)GetDlgItem(IDC_EDIT1);
PLR=(CEdit *)GetDlgItem(IDC_EDIT3);
PLn=(CEdit *)GetDlgItem(IDC_EDIT4);
LR=(CEdit *)GetDlgItem(IDC_EDIT5);
L2RT=(CEdit *)GetDlgItem(IDC_EDIT6);
L2A=(CEdit *)GetDlgItem(IDC_EDIT7);
L2B=(CEdit *)GetDlgItem(IDC_EDIT8);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void Cbianxiaodlg::OnOK()
{
// TODO: Add extra validation here
CString D,R,n,RL,RT,A,B;
tag_t part,new_part2;
tag_t m_part2=NULL_TAG;
UF_PART_load_status_t error_status;
int num_of_exp=0,i,ok;
char partname[]="E:\\ug1\\WP7_1.prt";
unsigned int aa=1;
tag_t *exps=&aa,exp_tag;
char *string,*lhs_str,*rhs_str;
int type=1,unit=4;
// char* title=null;
int m_type2;
double exp_value=50;
char cc='q';
char *s=&cc;
char *p1="PL_D",*p2="PL_R",*p3="PL_n",*p4="L_R",*p5="L2_RT",*p6="L2_A",*p7="L2_B";
UF_UI_selection_options_t opts;
UF_UI_mask_t mask = {UF_solid_type, 0, UF_UI_SEL_FEATURE_BODY};
/* Make sure User Function is available. */
UF_initialize();
if ( UF_initialize()!= 0)
// return ( UF_UI_CB_CONTINUE_DIALOG );
MessageBox("初始化失败");
/* ---- Enter your callback code here ----- */
opts.num_mask_triples = 5;
opts.mask_triples = &mask;
opts.scope = UF_UI_SEL_SCOPE_WORK_PART;
PLD->GetWindowText(D);
PLR->GetWindowText(R);
PLn->GetWindowText(n);
LR->GetWindowText(RL);
L2RT->GetWindowText(RT);
L2A->GetWindowText(A);
L2B->GetWindowText(B);
UF_PART_open(partname,&part,&error_status);
part=UF_PART_ask_display_part();
/* fail=UF_MODL_ask_mass_props_3d(&part,
num_part,
type,
unit,
density,
accuracy,
acc_val,
massprop,
massprop_stat);
*/
UF_MODL_ask_exps_of_part(part,&num_of_exp,&exps);
for(i=0;i <num_of_exp;i++)
{
UF_MODL_ask_exp_tag_string(exps,&string);
UF_MODL_dissect_exp_string(string,&lhs_str,&rhs_str,&exp_tag);
UF_MODL_eval_exp(lhs_str,&exp_value);
if(strcmp(lhs_str,p1)==0)
{
s=lhs_str;
strcat(s,"=");
rhs_str=(char *)(LPCTSTR)D;
strcat(s,rhs_str);
UF_MODL_edit_exp(s);
}
else if(strcmp(lhs_str,p2)==0)
{
rhs_str=(char *)(LPCTSTR)R;
s=lhs_str;
strcat(s,"=");
strcat(s,rhs_str);
UF_MODL_edit_exp(s);
}
else if(strcmp(lhs_str,p3)==0)
{
rhs_str=(char *)(LPCTSTR)n;
s=lhs_str;
strcat(s,"=");
strcat(s,rhs_str);
UF_MODL_edit_exp(s);
}
else if(strcmp(lhs_str,p4)==0)
{
rhs_str=(char *)(LPCTSTR)RL;
s=lhs_str;
strcat(s,"=");
strcat(s,rhs_str);
UF_MODL_edit_exp(s);
}
else if(strcmp(lhs_str,p5)==0)
{
rhs_str=(char *)(LPCTSTR)RT;
s=lhs_str;
strcat(s,"=");
strcat(s,rhs_str);
UF_MODL_edit_exp(s);
}
else if(strcmp(lhs_str,p6)==0)
{
rhs_str=(char *)(LPCTSTR)A;
s=lhs_str;
strcat(s,"=");
strcat(s,rhs_str);
UF_MODL_edit_exp(s);
}
else if(strcmp(lhs_str,p7)==0)
{
rhs_str=(char *)(LPCTSTR)B;
s=lhs_str;
strcat(s,"=");
strcat(s,rhs_str);
UF_MODL_edit_exp(s);
}
}
UF_MODL_update();
new_part2=UF_PART_ask_display_part();
//UF_PART_ask_families(part,&num_part,m_part);
// UF_UI_select_with_class_dialog("Select solid bodies",title,&opts,&response,
// &num,&m_part);
m_type2=UF_solid_type;
UF_OBJ_cycle_objs_in_part( new_part2, m_type2, &m_part2 );
UF_free(lhs_str);
UF_free(string);
UF_free(exps);
//UF_free(m_part);
ok=UF_PART_save();
UF_terminate ();
CDialog::OnOK();
}
void Cbianxiaodlg::OnCancel()
{
// TODO: Add extra cleanup here
CDialog::OnCancel();
}
[ 本帖最后由 tinlyjoanna 于 2008-8-26 11:12 编辑 ] |
|