找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 928|回复: 0

在一显示的树上编辑时, 有个项不能改名的问题, 为什么改不过来? 谢谢![问题]

[复制链接]
发表于 2002-1-24 11:42:54 | 显示全部楼层 |阅读模式

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

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

×
在一显示的树上编辑时, 有一个项改名的问题: 如点击某一接线, 如发电机功率P<10000KW, 出现
-----------------------
|发电机功率P<10000KW   |
-----------------------
修改为:
-----------------------
|发电机功率P>10000KW   |
-----------------------
但点击其他项时, 还是发电机功率P<10000KW, 为什么改不过来?
谢谢!

接线
   [] 接线1
   |    |发电机1台
   |    |电路1回
   |
   [] 接线2
   |    |发电机1台
   |    |电路2回
   |
   [] 接线3
   |    |发电机2台
   |    |线路1回
   |    |发电机功率P<10000KW
   |                        
   |                        
   |                     
代码如下:
// MyExam07Dlg.cpp : implementation file
//

#include "stdafx.h"
#include "MyExam07Dlg.h"
#include "exam07.h"

#define ATTRIB_SIZE 80
struct attribute
{
        char attrib[ATTRIB_SIZE];
        attribute *next;
}at;

#define NAME_SIZE 80
struct object
{
        char name[NAME_SIZE];
        attribute *alist;
};

#define MAX 1024
struct object k_base[MAX];
struct attribute *p;


int l_pos=-1;
int r_pos=-1;
void clear_kbase()
{
        int t;
        struct attribute *p,*p2;
        for (t=0;t<l_pos;t++) {
                p=k_base[t].alist;
                while (p) {
                        p2=p->next;
                        free(p);
                        p=p2;
                }
        }
}


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

MyExam07Dlg::MyExam07Dlg(CWnd* pParent /*=NULL*/)
        : CAcUiDialog(MyExam07Dlg::IDD, pParent)
{
        //{{AFX_DATA_INIT(MyExam07Dlg)
        //}}AFX_DATA_INIT
}

void MyExam07Dlg::DoDataExchange(CDataExchange* pDX)
{
        CAcUiDialog::DoDataExchange(pDX);
        //{{AFX_DATA_MAP(MyExam07Dlg)
        DDX_Control(pDX, ARXDBG_TR_SYS_REG, m_tv);
        //}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(MyExam07Dlg, CAcUiDialog)
        //{{AFX_MSG_MAP(MyExam07Dlg)
        ON_NOTIFY(NM_RCLICK, ARXDBG_TR_SYS_REG, OnRclickTrSysReg)
        ON_NOTIFY(TVN_BEGINLABELEDIT, ARXDBG_TR_SYS_REG, OnBeginlabeleditTrSysReg)
        ON_NOTIFY(TVN_ENDLABELEDIT, ARXDBG_TR_SYS_REG, OnEndlabeleditTrSysReg)
        //}}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_LIST_BLOCKS, MOVEX, 20 },
                { IDC_LIST_BLOCKS, ELASTICY, 100 },
                { IDC_LIST_BLOCKS, ELASTICX, 80 },
                { IDC_COMBO_REGAPPS, MOVEY, 100 },
                { IDC_COMBO_REGAPPS, ELASTICX, 20 },
        };

        int t,x;
        struct attribute *p,*oldp;
        FILE *fp;
        if ((fp=fopen("expert.dat","r"))==0) {
                acutPrintf("找不到文件");
                return TRUE;
        }
        acutPrintf("装入内存\n");
        clear_kbase();
        t=0;
                HTREEITEM noderoot,nodeson,nodeson1;
        noderoot=m_tv.InsertItem("root");

        for (;;++t) {
                if ((k_base[t].name[0]=getc(fp))==0) break;

                for (x=1;x<=sizeof(k_base[t].name);x++)
                        k_base[t].name[x]=getc(fp);

                k_base[t].alist=(struct attribute *)malloc(sizeof(at));
                p=k_base[t].alist;
                                nodeson=m_tv.InsertItem (k_base[t].name, noderoot);
                if (!p) {
                        return TRUE;
                }
                for (;;) {
                        for (x=0;x<sizeof(p->attrib);x++) p->attrib[x]=getc(fp);
                        nodeson1=m_tv.InsertItem (p->attrib, nodeson);

                        if (!p->attrib[0]) {
                                oldp->next='\0';
                                break;
                        }
                        p->next=(struct attribute *)malloc(sizeof(at));
                        if (!p->next) {
                                break;
                        }
                        oldp=p;
                        p=p->next;
                }
        }
        fclose(fp);

        l_pos=t-1;
        //return t-1;       
                //DisplayRegApps();
        return TRUE;

}


void MyExam07Dlg::OnOK()
{
        CAcUiDialog::OnOK();
}


void MyExam07Dlg::OnRclickTrSysReg(NMHDR* pNMHDR, LRESULT* pResult)
{
        // TODO: Add your control notification handler code here

    CMenu menu;
        //CAcModuleResourceOverride(ArxDbgApp::getApp()->dllInstance());
    CPoint point;
    if (menu.LoadMenu(ARXDBG_MNU_OBJSET)) {
        CMenu* pContextMenu = menu.GetSubMenu(0);
        
        if (pContextMenu) {
            ClientToScreen(&point);
            pContextMenu->TrackPopupMenu(TPM_LEFTALIGN | TPM_LEFTBUTTON, point.x, point.y, this);
            return;
        }
    }
        *pResult = 0;
}

void MyExam07Dlg::OnBeginlabeleditTrSysReg(NMHDR* pNMHDR, LRESULT* pResult)
{
        TV_DISPINFO* pTVDispInfo = (TV_DISPINFO*)pNMHDR;
        // TODO: Add your control notification handler code here
        acutPrintf("begin");
        *pResult = 0;
}

void MyExam07Dlg::OnEndlabeleditTrSysReg(NMHDR* pNMHDR, LRESULT* pResult)
{
        TV_DISPINFO* pTVDispInfo = (TV_DISPINFO*)pNMHDR;
        // TODO: Add your control notification handler code here
        int t,x;
        struct attribute *p;
        FILE *fp;
        if ((fp=fopen("expert.dat","w"))==0) {
                printf("cannot open file \n");
                return;
        }
        acutPrintf("Saving knowledge base. \n");
        for (t=0;t<=l_pos;++t) {
                for (x=0;x<=sizeof(k_base[t].name);x++)
                        putc(k_base[t].name[x],fp);
                p=k_base[t].alist;
            while (p) {
                        for (x=0;x<sizeof(p->attrib);x++)
                                putc(p->attrib[x],fp);
                        p=p->next;
                }
            for (x=0;x<sizeof(p->attrib);x++) putc('\0',fp);
        }
        putc(0,fp);
        fclose(fp);


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

本版积分规则

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

GMT+8, 2024-5-12 18:33 , Processed in 0.369035 second(s), 31 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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