| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1258 人关注过本帖
标题:求助:为什么我的程序执行时自己退出了???
只看楼主 加入收藏
tinlyjoanna
Rank: 1
等 级:新手上路
帖 子:8
专家分:0
注 册:2008-8-5
收藏
 问题点数:0 回复次数:7 
求助:为什么我的程序执行时自己退出了???
我用MFC做了个系统界面,编译连接都没有问题,但是为什么单步执行时一到
    CString X1;
    CString X2;
    D_X1->GetWindowText(m_D_X1);
    D_X2->GetWindowText(m_D_X2);

就自动退出了,搞不懂啊,望高手指教,
小女刚刚入门,望大家说得详细一点啊!
先谢过大家了
2008-08-05 21:26
missiyou
Rank: 5Rank: 5
等 级:贵宾
威 望:16
帖 子:531
专家分:218
注 册:2007-10-9
收藏
得分:0 
最喜欢帮助美女了,好像我也不知道问题出在那哦。呵呵,多多交流啊!!
2008-08-05 21:47
l290933157
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2008-8-5
收藏
得分:0 
2008-08-05 22:20
l290933157
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2008-8-5
收藏
得分:0 
新建C C++群 8609438
欢迎有兴趣的朋友加入
2008-08-05 22:21
lovelifeVC
Rank: 1
等 级:新手上路
帖 子:20
专家分:0
注 册:2008-8-6
收藏
得分:0 
能把源码贴上来看看吗
2008-08-06 14:30
tinlyjoanna
Rank: 1
等 级:新手上路
帖 子:8
专家分:0
注 册:2008-8-5
收藏
得分:0 
程序源码
// lunpandlg.cpp : implementation file
//

#include "stdafx.h"
#include "featuremodeling.h"
#include "lunpandlg.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>




#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////

extern void ufsta (char *param, int *retcode, int rlen)
{
  
  if ( (UF_initialize()) != 0)
      return;
 
  UF_terminate();
  return;
}

////////////////////////////////////////////////////////////////////////////

void main(int argc,char **argv)
{

        UF_initialize();

        UF_terminate();
}

int my(int a,int b,int c,int d,int e,int f,int g,int h,int p,int j,int k,int l,int m,int n,int o)
{
    
    tag_t part;
    UF_PART_load_status_t error_status;
    int num_of_exp=0,i,ok;
    char partname[]="E:\ug\panti.prt";
    char partname1[]="E:\ug1\panti.prt";
    tag_t *exps,exp_tag;
    char *string,*lhs_str,*rhs_str;
    CString rhs_str1;

    double exp_value=50;
    char *name[15],*s;
    /* Make sure User Function is available. */  
     if ( UF_initialize() != 0)
          return ( UF_UI_CB_CONTINUE_DIALOG );

     /* ---- Enter your callback code here ----- */
     UF_PART_open(partname,&part,&error_status);
     name[0]="D_X1";
     name[1]="D_X2";
     name[2]="D_R1";
     name[3]="D_R2";
     name[4]="D_R3";
     name[5]="D_R4";
     name[6]="D_R5";
     name[7]="D_R6";
     name[8]="D_X3";
     name[9]="D_X4";
     name[10]="D_W";
     name[11]="D_W1";
     name[12]="D_W2";
     name[13]="D_W3";
     name[14]="D_WT";
    
    
     part=UF_PART_ask_display_part();
    
     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[i],&string);
        UF_MODL_dissect_exp_string(string,&lhs_str,&rhs_str,&exp_tag);
     switch(*lhs_str){
        case 'D_X1':   
                        *rhs_str=a;
                        s=lhs_str;
                        strcat(s,"=");
                        strcat(s,rhs_str);
                        s="D_X1=20.0";
                        UF_MODL_edit_exp(s);
                        break;
        case 'D_X2':       
                        *rhs_str=b;
                        s=lhs_str;
                        strcat(s,"=");
                        strcat(s,rhs_str);
                        s="D_X2=17.5";
                        UF_MODL_edit_exp(s);
                          break;
        case 'D_R1':  
                        *rhs_str=c;
                        s=lhs_str;
                        strcat(s,"=");
                        strcat(s,rhs_str);
                        UF_MODL_edit_exp(s);
                        break;
        case 'D_R2':  
                        *rhs_str=d;
                        s=lhs_str;
                        strcat(s,"=");
                        strcat(s,rhs_str);
                        s="D_R2=208.0";
                        UF_MODL_edit_exp(s);
                        break;
        case 'D_R3':  
                        *rhs_str=e;
                        s=lhs_str;
                        strcat(s,"=");
                        strcat(s,rhs_str);
                        s="D_R3=130.0";
                        UF_MODL_edit_exp(s);
                        break;
        case 'D_R4':  
                        *rhs_str=f;
                        s=lhs_str;
                        strcat(s,"=");
                        strcat(s,rhs_str);
                        s="D_R4=80.0";
                        UF_MODL_edit_exp(s);
                        break;
        case 'D_R5':  
                        *rhs_str=g;
                        s=lhs_str;
                        strcat(s,"=");
                        strcat(s,rhs_str);
                        s="D_R5=84.5";
                        UF_MODL_edit_exp(s);
                        break;
        case 'D_R6':  
                        *rhs_str=h;
                        s=lhs_str;
                        strcat(s,"=");
                        strcat(s,rhs_str);
                        s="D_R6=91.0";
                        UF_MODL_edit_exp(s);
                        break;
        case 'D_X3':  
                        *rhs_str=p;
                        s=lhs_str;
                        strcat(s,"=");
                        strcat(s,rhs_str);
                        s="D_X3=162.0";
                        UF_MODL_edit_exp(s);
                        break;
        case 'D_X4':  
                        *rhs_str=j;
                        s=lhs_str;
                        strcat(s,"=");
                        strcat(s,rhs_str);
                        s="D_X4=190.0";
                        UF_MODL_edit_exp(s);
                        break;
        case 'D_W':  
                        *rhs_str=k;
                        s=lhs_str;
                        strcat(s,"=");
                        strcat(s,rhs_str);
                        s="D_W=43.0";
                        UF_MODL_edit_exp(s);
                        break;
        case 'D_W1':  
                        *rhs_str=l;
                        s=lhs_str;
                        strcat(s,"=");
                        strcat(s,rhs_str);
                        s="D_W1=22.0";
                        UF_MODL_edit_exp(s);
                        break;
        case 'D_W2':  
                        *rhs_str=m;
                        s=lhs_str;
                        strcat(s,"=");
                        strcat(s,rhs_str);
                        s="D_W2=17.0";
                        UF_MODL_edit_exp(s);
                        break;
        case 'D_W3':  
                        *rhs_str=n;
                        s=lhs_str;
                        strcat(s,"=");
                        strcat(s,rhs_str);
                        s="D_W3=5.0";
                        UF_MODL_edit_exp(s);
                        break;
        case 'D_WT':  
                        *rhs_str=o;
                        s=lhs_str;
                        strcat(s,"=");
                        strcat(s,rhs_str);
                        s="D_WT=48.0";
                        UF_MODL_edit_exp(s);
                        break;
        default :
                    break;
        }             

        
     }
     UF_free(lhs_str);
     UF_free(string);
     UF_MODL_update();
       UF_free(exps);
     ok=UF_PART_save_as(partname1);
     UF_terminate ();
     return ok;
}


// Clunpandlg dialog


Clunpandlg::Clunpandlg(CWnd* pParent /*=NULL*/)
    : CDialog(Clunpandlg::IDD, pParent)
{
    //{{AFX_DATA_INIT(Clunpandlg)
    m_D_R1 = _T("");
    m_D_R6 = _T("");
    m_D_W3 = _T("");
    m_D_X3 = _T("");
    m_D_X1 = _T("");
    m_D_X4 = _T("");
    m_D_X2 = _T("");
    m_D_R2 = _T("");
    m_D_R3 = _T("");
    m_D_W = _T("");
    m_D_WT = _T("");
    m_D_R4 = _T("");
    m_D_W1 = _T("");
    m_D_R5 = _T("");
    m_D_W2 = _T("");
    //}}AFX_DATA_INIT
}


void Clunpandlg::DoDataExchange(CDataExchange* pDX)
{
    CDialog::DoDataExchange(pDX);
    //{{AFX_DATA_MAP(Clunpandlg)
    DDX_Text(pDX, IDC_EDIT1, m_D_R1);
    DDX_Text(pDX, IDC_EDIT10, m_D_R6);
    DDX_Text(pDX, IDC_EDIT11, m_D_W3);
    DDX_Text(pDX, IDC_EDIT12, m_D_X3);
    DDX_Text(pDX, IDC_EDIT13, m_D_X1);
    DDX_Text(pDX, IDC_EDIT14, m_D_X4);
    DDX_Text(pDX, IDC_EDIT15, m_D_X2);
    DDX_Text(pDX, IDC_EDIT2, m_D_R2);
    DDX_Text(pDX, IDC_EDIT3, m_D_R3);
    DDX_Text(pDX, IDC_EDIT4, m_D_W);
    DDX_Text(pDX, IDC_EDIT5, m_D_WT);
    DDX_Text(pDX, IDC_EDIT6, m_D_R4);
    DDX_Text(pDX, IDC_EDIT7, m_D_W1);
    DDX_Text(pDX, IDC_EDIT8, m_D_R5);
    DDX_Text(pDX, IDC_EDIT9, m_D_W2);
    //}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(Clunpandlg, CDialog)
    //{{AFX_MSG_MAP(Clunpandlg)
    //}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// Clunpandlg message handlers

BOOL Clunpandlg::OnInitDialog()
{
    CDialog::OnInitDialog();
    
    // TODO: Add extra initialization here

     UpdateData(TRUE);

     D_X1=(CEdit *)GetDlgItem(IDC_EDIT13);
     D_X2=(CEdit *)GetDlgItem(IDC_EDIT15);
     D_R1=(CEdit *)GetDlgItem(IDC_EDIT1);
     D_R2=(CEdit *)GetDlgItem(IDC_EDIT2);
     D_R3=(CEdit *)GetDlgItem(IDC_EDIT3);
     D_R4=(CEdit *)GetDlgItem(IDC_EDIT6);
     D_R5=(CEdit *)GetDlgItem(IDC_EDIT8);
     D_R6=(CEdit *)GetDlgItem(IDC_EDIT10);
     D_X3=(CEdit *)GetDlgItem(IDC_EDIT12);
     D_X4=(CEdit *)GetDlgItem(IDC_EDIT14);
     D_W=(CEdit *)GetDlgItem(IDC_EDIT4);
     D_W1=(CEdit *)GetDlgItem(IDC_EDIT7);
     D_W2=(CEdit *)GetDlgItem(IDC_EDIT9);
     D_W3=(CEdit *)GetDlgItem(IDC_EDIT11);
     D_WT=(CEdit *)GetDlgItem(IDC_EDIT5);
    
    return TRUE;  // return TRUE unless you set the focus to a control
                  // EXCEPTION: OCX Property Pages should return FALSE
}



void Clunpandlg::OnOK()
{
    // TODO: Add extra validation here
    
    


    tag_t part,new_part;
    tag_t m_part=NULL_TAG;
    UF_PART_load_status_t error_status;
    int num_of_exp=0,i,ok;
    char partname[]="E:\\ug\\panti.prt";
    char partname1[]="E:\\ug1\\panti.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_type;
    double  acc_val[11] = {.01,0,0,0,0,0,0,0,0,0,0};


    UF_UI_selection_options_t opts;
    UF_UI_mask_t mask = {UF_solid_type, 0, UF_UI_SEL_FEATURE_BODY};



    double exp_value=50;
    char bb[15]={'a','b','c','d','e','f','g','h','p','j','k','l','m','n','o'};

    char cc='q';
    char *name=&bb[15],*s=&cc;



    /* Make sure User Function is available. */  
    if(name==NULL)
       MessageBox("name为空");
    if(s==NULL)
       MessageBox("s为空");
     if(exps==NULL)
       MessageBox("exps为空");


    UF_initialize();

    if ( UF_initialize()!= 0)
         // return ( UF_UI_CB_CONTINUE_DIALOG );

         MessageBox("初始化失败");

     /* ---- Enter your callback code here ----- */
    opts.num_mask_triples = 1;
    opts.mask_triples = &mask;
    opts.scope = UF_UI_SEL_SCOPE_WORK_PART;




    CString R1;    CString R2;
    CString R3;
    CString R4;
    CString R5;
    CString R6;
    CString X3;
    CString X4;
    CString W;
    CString W1;
    CString W2;
    CString W3;
    CString WT;
    CString X1;
    CString X2;



     D_X1->GetWindowText(m_D_X1);
     D_X2->GetWindowText(m_D_X2);
     D_R1->GetWindowText(m_D_R1);
     D_R2->GetWindowText(m_D_R2);
     D_R3->GetWindowText(m_D_R3);
     D_R4->GetWindowText(m_D_R4);
     D_R5->GetWindowText(m_D_R5);
     D_R6->GetWindowText(m_D_R6);
     D_X3->GetWindowText(m_D_X3);
     D_X4->GetWindowText(m_D_X4);
     D_W->GetWindowText(m_D_W);
     D_W1->GetWindowText(m_D_W1);
     D_W2->GetWindowText(m_D_W2);
     D_W3->GetWindowText(m_D_W3);
     D_WT->GetWindowText(m_D_WT);


     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[i],&string);
        UF_MODL_dissect_exp_string(string,&lhs_str,&rhs_str,&exp_tag);
    switch(*lhs_str)
        {
        case 'D_X1':   
                    rhs_str=(char *)(LPCTSTR)m_D_X1;
                    s=lhs_str;
                    strcat(s,"=");
                    strcat(s,rhs_str);
                    UF_MODL_edit_exp(s);
                    break;
        case 'D_X2':       
                        rhs_str=(char *)(LPCTSTR)m_D_X2;
                        s=lhs_str;
                        strcat(s,"=");
                        strcat(s,rhs_str);
                        UF_MODL_edit_exp(s);
                          break;
        case 'D_R1':  
                        rhs_str=(char *)(LPCTSTR)m_D_R1;
                        s=lhs_str;
                        strcat(s,"=");
                        strcat(s,rhs_str);
                        UF_MODL_edit_exp(s);
                        break;
        case 'D_R2':  
                        rhs_str=(char *)(LPCTSTR)m_D_R2;
                        s=lhs_str;
                        strcat(s,"=");
                        strcat(s,rhs_str);
                        UF_MODL_edit_exp(s);
                        break;
        case 'D_R3':  
                        rhs_str=(char *)(LPCTSTR)m_D_R3;
                        s=lhs_str;
                        strcat(s,"=");
                        strcat(s,rhs_str);
                        UF_MODL_edit_exp(s);
                        break;
        case 'D_R4':  
                        rhs_str=(char *)(LPCTSTR)m_D_R4;
                        s=lhs_str;
                        strcat(s,"=");
                        strcat(s,rhs_str);
                        UF_MODL_edit_exp(s);
                        break;
        case 'D_R5':  
                        rhs_str=(char *)(LPCTSTR)m_D_R5;
                        s=lhs_str;
                        strcat(s,"=");
                        strcat(s,rhs_str);
                        UF_MODL_edit_exp(s);
                        break;
        case 'D_R6':  
                        rhs_str=(char *)(LPCTSTR)m_D_R6;
                        s=lhs_str;
                        strcat(s,"=");
                        strcat(s,rhs_str);
                        UF_MODL_edit_exp(s);
                        break;
        case 'D_X3':  
                        rhs_str=(char *)(LPCTSTR)m_D_X3;
                        s=lhs_str;
                        strcat(s,"=");
                        strcat(s,rhs_str);
                        UF_MODL_edit_exp(s);
                        break;
        case 'D_X4':  
                        rhs_str=(char *)(LPCTSTR)m_D_X4;
                        s=lhs_str;
                        strcat(s,"=");
                        strcat(s,rhs_str);
                        UF_MODL_edit_exp(s);
                        break;
        case 'D_W':  
                        rhs_str=(char *)(LPCTSTR)m_D_W;
                        s=lhs_str;
                        strcat(s,"=");
                        strcat(s,rhs_str);
                        UF_MODL_edit_exp(s);
                        break;
        case 'D_W1':  
                        rhs_str=(char *)(LPCTSTR)m_D_W1;
                        s=lhs_str;
                        strcat(s,"=");
                        strcat(s,rhs_str);
                        UF_MODL_edit_exp(s);
                        break;
        case 'D_W2':  
                        rhs_str=(char *)(LPCTSTR)m_D_W2;
                        s=lhs_str;
                        strcat(s,"=");
                        strcat(s,rhs_str);
                        UF_MODL_edit_exp(s);
                        break;
        case 'D_W3':  
                        rhs_str=(char *)(LPCTSTR)m_D_W3;
                        s=lhs_str;
                        strcat(s,"=");
                        strcat(s,rhs_str);
                        UF_MODL_edit_exp(s);
                        break;
        case 'D_WT':  
                        rhs_str=(char *)(LPCTSTR)m_D_WT;
                        s=lhs_str;
                        strcat(s,"=");
                        strcat(s,rhs_str);
                        UF_MODL_edit_exp(s);
                        break;


                        default :
                        break;
        }             

        
     }
     UF_MODL_update();
     new_part=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_type=UF_solid_type;
     UF_OBJ_cycle_objs_in_part( new_part, m_type, &m_part );


         UF_free(lhs_str);
        UF_free(string);
    
        UF_free(exps);
      //UF_free(m_part);


     ok=UF_PART_save_as(partname1);

     UF_terminate ();
    CDialog::OnOK();


}

void Clunpandlg::OnCancel()
{
    // TODO: Add extra cleanup here
    
    CDialog::OnCancel();
}
2008-08-06 18:40
crosoli
Rank: 1
等 级:新手上路
帖 子:57
专家分:0
注 册:2007-4-24
收藏
得分:0 
太多了不好看 QQ上交流把。
2008-08-06 19:20
missiyou
Rank: 5Rank: 5
等 级:贵宾
威 望:16
帖 子:531
专家分:218
注 册:2007-10-9
收藏
得分:0 
CString X1;
    CString X2;
    D_X1->GetWindowText(m_D_X1);
    D_X2->GetWindowText(m_D_X2);
这个里面的传参不一致! 定义了二个变量,下面传参不知道是不是传上面的。X1,X2 ;D_X1,D_X2;m_D_X1
2008-08-06 20:19
快速回复:求助:为什么我的程序执行时自己退出了???
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.019662 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved