- UID
- 181
- 积分
- 0
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2002-1-10
- 最后登录
- 1970-1-1
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
在树编辑时项不能改名的问题已解决, 代码如下. 下一个问题是: 在某一接线, 点击鼠标右键, 为什么不能出现下拉菜单? 谢谢!
- #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)
- ON_NOTIFY(NM_RETURN, ARXDBG_TR_SYS_REG, OnReturnTrSysReg)
- //}}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("电气主接线");
- 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());
- if (menu.LoadMenu(ARXDBG_MNU_OBJSET)) {
- CMenu* pContextMenu = menu.GetSubMenu(0);
-
- if (pContextMenu) {
- CPoint point;
- GetCursorPos(&point);
- //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;
- *pResult = 0;
- if (pTVDispInfo->item.mask & TVIF_TEXT) {
- HTREEITEM item = m_tv.GetSelectedItem();
- if (item == NULL)
- return;
- CString oldName = m_tv.GetItemText(item);
- CString newName = pTVDispInfo->item.pszText;
- //acutPrintf("%s",oldName);
- //acutPrintf("%s",newName);
- // if it hasn't changed, don't do anything
- if (newName.CompareNoCase(oldName) == 0)
- return;
-
- m_tv.SetItemText(item, newName);
-
- /*
- if (renameCurrentItem(oldName, newName)) {
- // set new item name and re-sort entries in this node of tree
- m_tv.SetItem(&(pTVDispInfo->item));
- m_tv.SortChildren(m_tv.GetParentItem(item));
- }
- */
- }
- }
|
|