tab控件每个page对应一个对话框,对话框上有好多控件,如何得到各个控件的ID

wang_bluebird 2004-11-26 11:29:49
假如page1 对应m_dialog,m_dialog上有控件m_tree,如何得到m_tree的ID号?
...全文
113 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
wang_bluebird 2004-11-28
  • 打赏
  • 举报
回复
把一个深层次的树保存在一个文件中,再次读入时
: 有能很快的按照上次的层次排列显示出来?
Project Name:E ,SDI interface

class CEDoc :public CDocument;
class CEView:public CTreeview;

void CEDoc::Serialize(CArchive& ar)
{
POSITION position=GetFirstViewPosition ();
//get treeview
CEView* view=(CEView* )this->GetNextView (position);
CString strItemText;
HTREEITEM hCurrent=NULL;
HTREEITEM hTest=NULL;
//ctreectrl* m_ptree

m_ptree=&(view->GetTreeCtrl ());
if (ar.IsStoring())
{
// TODO: add storing code here
//ar<<m_ptree->GetCount();
//UINT m_iNest
//to save position of next item relative to this ite
m
m_iNest=0;
if(m_ptree->GetCount()=0)//no items
return;
//access the whole tree
hCurrent=m_ptree->GetRootItem( );
m_iDirection=CHILD;
while(m_iDirection!=OVER)
{
switch(m_iDirection)
{
case CHILD:
char szBuffer[256];
TV_ITEM item;
item.hItem = hCurrent;
item.mask = TVIF_TEXT | TVIF_CHILDREN;
item.pszText = szBuffer;
item.cchTextMax = 255;
m_ptree->GetItem(&item);
//save information
ar<<m_iNest;
strItemText=szBuffer;
ar<<strItemText;
m_iDirection=CHILD;//get child item if possible
//getchild item
if( m_ptree->ItemHasChildren(hCurrent))
{
m_iNest=1;//next item is the child of this item
hCurrent= m_ptree->GetChildItem(hCurrent);
m_iDirection=CHILD;
break;
}
else//no child item
{
//set base item nest if item has no child
m_iNest=0;
// Try next sibling item.
hTest = m_ptree->GetNextSiblingItem(hCurrent);
if(hTest!=NULL)
{
hCurrent=hTest;
m_iDirection=CHILD;
break;
}
else
{
//No slibing, goto parent
hTest= m_ptree->GetParentItem(hCurrent);
if(hTest==NULL)//no parent,no sibling,i.e. end of tree
m_iDirection=OVER;
else
{
hCurrent=hTest;
m_iNest=-1;
m_iDirection=PARENT;
}
break;
}
}
case PARENT:
// Try next sibling item.
hTest = m_ptree->GetNextSiblingItem(hCurrent);
if(hTest!=NULL)
{
hCurrent=hTest;
m_iDirection=CHILD;
break;
}
else
{
//No slibing, goto parent
hTest= m_ptree->GetParentItem(hCurrent);

if(hTest==NULL)//no parent,no sibling,i.e.end of tree
{
m_iDirection=OVER;
break;
}
hCurrent=hTest;
m_iNest--;
m_iDirection=PARENT;
break;
}
}
}
ar<<32767;//end of file

}
else
{
// TODO: add loading code here
//clear contents
m_ptree->DeleteAllItems();
ar>>m_iNest;
//the first interger must be 0
if(m_iNest!=0){
MessageBox(NULL,"非法文件头!","错误",MB_OK);
return;
}
ar>>strItemText;
hCurrent=m_ptree->InsertItem(strItemText);
while(hCurrent!=NULL)
{
ar>>m_iNest;
if(m_iNest==32767)//end of file
return;
ar>>strItemText;
if(m_iNest==1)
{
hCurrent=m_ptree->InsertItem(strItemText,hCurrent);
m_ptree->EnsureVisible(hCurrent);
continue;
}
while(m_iNest<0)
{
hCurrent=m_ptree->GetParentItem(hCurrent);
m_iNest++;
}
//get parent;if root,set root.
hTest=m_ptree->GetParentItem(hCurrent);
if(hTest==NULL)
hTest=TVI_ROOT;
m_ptree->InsertItem(strItemText,hTest);

}
}
}
wang_bluebird 2004-11-26
  • 打赏
  • 举报
回复
我定义一个宏
#define MY m_pageone.m_tree.GetDlgCtrlID()
为何报错 MY CXX0017: 错误: 没有找到符号“MY”

aoosang 2004-11-26
  • 打赏
  • 举报
回复
GetDlgCtrlID

16,472

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧