找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 941|回复: 4

[求助]:我定义了一个线型, 下面代码把Y.LIN在对话框中显示, 但如何根据对话框中修改

[复制链接]
发表于 2002-7-24 09:10:45 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

×
我定义了一个线型Y.SHX, 作为防护林用。 下面代码把Y.LIN在对话框中显示, 但如何根据对话框中修改值来存盘?

y.lin is as followed:
*YYL1,F2 circle
A,0,[CIRC2,Y.shx,s=1],-50



//The following is the code of diaplaying and editing y.lin
#include "stdafx.h"
#include "MyExam07Dlg.h"
#include "exam07.h"

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

/////////////////////////////////////////////////////////////////////////////
// MyExam07Dlg dialog


MyExam07Dlg::MyExam07Dlg(CWnd* pParent /*=NULL*/)
        : CAcUiDialog(MyExam07Dlg::IDD, pParent)
{
        //{{AFX_DATA_INIT(MyExam07Dlg)
                // NOTE: the ClassWizard will add member initialization here
        //}}AFX_DATA_INIT
}


void MyExam07Dlg::DoDataExchange(CDataExchange* pDX)
{
        CAcUiDialog::DoDataExchange(pDX);
        //{{AFX_DATA_MAP(MyExam07Dlg)


        DDX_Control(pDX, IDC_EDIT_YPT, m_ctrlYPtEdit);
        DDX_Control(pDX, IDC_EDIT_XPT, m_ctrlXPtEdit);


        //}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(MyExam07Dlg, CAcUiDialog)
        //{{AFX_MSG_MAP(MyExam07Dlg)

         
        //}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// MyExam07Dlg message handlers

BOOL MyExam07Dlg::OnInitDialog()
{   



        SetDialogName("exam07:MyExam07Dlg");
        CAcUiDialog::OnInitDialog();
        DLGCTLINFO dlgSizeInfo[]= {
                { IDC_STATIC_GROUP1, ELASTICX, 20 },
                { IDC_STATIC_GROUP1, ELASTICY, 100 },
                { IDC_EDIT_XPT,ELASTICX, 20 },
                { IDC_EDIT_YPT,ELASTICX, 20 },
               
                { IDC_STATIC_GROUP3, MOVEY, 100 },
                { IDC_STATIC_GROUP3, ELASTICX, 20 },
         
               
                { IDOK,MOVEX, 100 },
                { IDCANCEL, MOVEX, 100 },
        };

        const DWORD numberofentries =
                sizeof dlgSizeInfo / sizeof DLGCTLINFO;
        SetControlProperty(dlgSizeInfo, numberofentries);

          DisplayPoint();
       
        SetWindowText("Forrest Lines");

        return TRUE;
}

  
void MyExam07Dlg::OnOK()
{   FILE *fp;
    if ((fp=fopen("y.lin","w"))==0) {
             acutPrintf("cannot open file \n");
             return;
     }   
         

    fclose(fp);

        CAcUiDialog::OnOK();

}


void MyExam07Dlg::DisplayPoint()
{   FILE *fp;
   
        if ((fp=fopen("y.lin","r"))==0) {
             acutPrintf("cannot open file \n");
             return;
     }
   
    //AfxMessageBox("m_str");
/*
    acutPrintf("%c fir\n", getc(fp));
    acutPrintf("%c fir\n", getc(fp));
    acutPrintf("%c fir\n", getc(fp));*/

    m_str=getc(fp);
        acutPrintf("%s first\n", m_str);
        while (m_str != EOF) {
                if (m_str == '=')  {
               
                        m_strXPt=getc(fp);

                ch=getc(fp);
                        while (ch != ']' ) {
              m_strXPt=m_strXPt+ch;
              ch=getc(fp);
                        }
                }

                if (m_str == '-')  {
                        m_strYPt=getc(fp);
            ch=getc(fp);
                        while (ch !=EOF) {
              m_strYPt=m_strYPt+ch;
              ch=getc(fp);
                        }
       
                }


      m_str=getc(fp);
        }

    acutPrintf("%s radius\n", m_strXPt);
    acutPrintf("%s offset\n", m_strYPt);

        /*
    m_strXPt=getc(fp);
        if (m_strXPt = "*")  m_strXPt=getc(fp);
        m_strXPt+=getc(fp);
    m_strYPt=getc(fp);   
    */

        m_ctrlXPtEdit.SetWindowText(m_strXPt);
        m_ctrlXPtEdit.Convert();
        m_ctrlYPtEdit.SetWindowText(m_strYPt);
        m_ctrlYPtEdit.Convert();
    fclose(fp);
}
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
 楼主| 发表于 2002-7-24 16:24:39 | 显示全部楼层
编译出错,怎样改? 谢谢
F:\DRIVER\7\MyExam07Dlg.cpp(115) : error C2664: 'fputc' : cannot convert parameter 1 from 'class CString' to 'int'
        No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called

MyExam07Dlg.cpp(115)是 fputc(m_strXPt,fp);                   m_strXPt 如此定义CString m_strXPt;

void MyExam07Dlg::OnOK()
{   FILE *fp;
    //char *cha;
    if ((fp=fopen("y.lin","w"))==0) {
             acutPrintf("cannot open file \n");
             return;
     }   
        //fputc
    fputc('A',fp);
        fputc(',',fp);
        fputc('0',fp);
        fputc(',',fp);
        fputc('[',fp);
        fputc('C',fp);
    fputc('I',fp);
        fputc('R',fp);
        fputc('C',fp);
        fputc('2',fp);
        fputc(',',fp);
        fputc('Y',fp);
        fputc('.',fp);
        fputc('S',fp);
        fputc('H',fp);
        fputc('X',fp);
        fputc(',',fp);
        fputc('S',fp);
        fputc('=',fp);
        m_ctrlXPtEdit.Convert();
        m_ctrlXPtEdit.GetWindowText(m_strXPt);
        acutPrintf("%s x\n", m_strXPt);
        //cha = m_strXPt;
        fputc(m_strXPt,fp);
        fputc(']',fp);       
        fputc(',',fp);
        fputc('-',fp);
        m_ctrlYPtEdit.Convert();
        m_ctrlYPtEdit.GetWindowText(m_strYPt);
    acutPrintf("%s y\n", m_strYPt);
    fputc(m_strYPt,fp);

    fclose(fp);

        CAcUiDialog::OnOK();

}

y.lin如下:
A,0,[CIRC2,Y.SHX,S=1],-50
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

 楼主| 发表于 2002-7-25 08:59:27 | 显示全部楼层
fputs代替fputc就可解决上面的问题,但新问题是怎样自动加入修改的LIN文件?
void MyExam07Dlg::OnOK()
{   FILE *fp;
    //char *cha;
    if ((fp=fopen("y.lin","w"))==0) {
             acutPrintf("cannot open file \n");
             return;
     }   
        //fputc
        fputs("*YYL1,F2 circle     0     0     0     0     0     0     0",fp);
        fputc(13,fp);
        fputc(10,fp);
    fputc('A',fp);
        fputc(',',fp);
        fputc('0',fp);
        fputc(',',fp);
        fputc('[',fp);
        fputc('C',fp);
    fputc('I',fp);
        fputc('R',fp);
        fputc('C',fp);
        fputc('2',fp);
        fputc(',',fp);
        fputc('Y',fp);
        fputc('.',fp);
        fputc('S',fp);
        fputc('H',fp);
        fputc('X',fp);
        fputc(',',fp);
        fputc('S',fp);
        fputc('=',fp);
        m_ctrlXPtEdit.Convert();
        m_ctrlXPtEdit.GetWindowText(m_strXPt);
    acutPrintf("%s x\n", m_strXPt);
        //cha = m_strXPt;
        fputs(m_strXPt,fp);

        fputc(']',fp);       
        fputc(',',fp);
        fputc('-',fp);
        m_ctrlYPtEdit.Convert();
        m_ctrlYPtEdit.GetWindowText(m_strYPt);
    acutPrintf("%s y\n", m_strYPt);
    fputs(m_strYPt,fp);

    fclose(fp);
  acedCommand(RTSTR,"linetype",RTSTR,L,RTSTR,F,RTSTR,y.lin,RTSTR,YYL1,RTSTR,Y,RTSTR,RTNONE);


        CAcUiDialog::OnOK();

}
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

 楼主| 发表于 2002-7-25 10:52:53 | 显示全部楼层
运行出错,“Unhandled exception c0000005 (Access violation reading 0X1388) at address 78003abfh”
错在加入线型:
acedCommand(RTSTR,_T("_linetype"),RTSTR,_T("_L"),RTSTR,_T("_F"),RTSTR,_T("_y.lin"),RTSTR,_T("_YYL1"),RTSTR,_T("_Y"),RTSTR,RTNONE);

把Y.LIN装入, 线型名是YYL1, 怎么改? 谢谢!
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

 楼主| 发表于 2002-7-26 09:25:57 | 显示全部楼层
acedCommand改为:acedCommand(RTSTR,"linetype",RTSTR,"L","YYL1", RTSTR,"Y.LIN",RTSTR,"Y",RTSTR,RTNONE);
运行出错”Invalid type in acutBuildList() arg #5“,怎么改?谢谢!
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|申请友链|Archiver|手机版|小黑屋|辽公网安备|晓东CAD家园 ( 辽ICP备15016793号 )

GMT+8, 2024-5-3 10:03 , Processed in 0.435133 second(s), 39 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表