gpt4 book ai didi

windows - MFC中如何在CTreeCtrl列表中添加图片

转载 作者:可可西里 更新时间:2023-11-01 10:50:23 27 4
gpt4 key购买 nike

我试图在 CTreeList 控件中的文本之前添加图像,但它没有出现,但我观察到节点名称在一些空间之后开始,就像它为位图留下空间一样,但图像不是显示..这是代码快照:-

CImageList m_ImageList;

CBitmap m_Bitmap1;

m_ImageList.Create(16,16,ILC_COLOR32,1,1);

m_Bitmap1.LoadBitmap(IDB_BITMAP1);

m_ImageList.Add(&m_Bitmap1, RGB(0,0,0));

TreeSoft->Create(WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP |
TVS_HASLINES | TVS_HASBUTTONS | TVS_LINESATROOT |
TVS_SINGLEEXPAND | TVS_SHOWSELALWAYS |
TVS_TRACKSELECT,
CRect(10, 10, 200, 240), this, 0x1221);


TreeSoft->SetImageList(&m_ImageList, TVSIL_NORMAL);

hTree = TreeSoft->InsertItem( L"Software Production",0,0, TVI_ROOT);

hCompany = TreeSoft->InsertItem(L"Microsoft",0,0, hTree);

请告诉我我在这里缺少什么...

最佳答案

现在你只需要为新创建的分支设置图像:

TreeSoft->SetItemImage(hTree , 0, 0); // I think it starts from 0 (if it does not show try 1)

关于windows - MFC中如何在CTreeCtrl列表中添加图片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5960099/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com