|
|
Home » U++ Library support » TreeCtrl » TreeCtrl - how to change images dynamically? [SOLVED + FIXED]
|
Re: TreeCtrl - how to change images dynamically? [message #2314 is a reply to message #2312] |
Sat, 08 April 2006 01:14 |
|
fudadmin
Messages: 1321 Registered: November 2005 Location: Kaunas, Lithuania
|
Ultimate Contributor Administrator |
|
|
fudadmin wrote on Fri, 07 April 2006 21:20 | in TreeCtrl
There are methods:
void Set(int id, Value value);
void Set(int id, Value key, Value value);
but no for images...
How to change images dynamically?
(other than add or insert!!!)
|
I haven't done a lot of thinking but this works for me:
void TreeCtrl::Set(int id, const Image& img)
{
Item& m = item[id];
// if(m.ctrl) { //Edit: in fact this dosn't work ?
m.image = img;
RefreshItem(id);
// }
}
If there is no other way, maybe it would be good to have added something like above?
Also, question arises, how to add a series of images?
[Updated on: Sat, 08 April 2006 01:24] Report message to a moderator
|
|
|
|
|
|
|
Re: TreeCtrl - how to change images dynamically? [message #2337 is a reply to message #2335] |
Sat, 08 April 2006 15:09 |
|
fudadmin
Messages: 1321 Registered: November 2005 Location: Kaunas, Lithuania
|
Ultimate Contributor Administrator |
|
|
luzr wrote on Sat, 08 April 2006 13:05 |
I had tried this unsuccessfully... That's why I asked.
tree.SetNode(editid, tree.GetNode(editid).SetImage(CtrlImg::ImgEdit()));
E:\AriUppApps1\ideAris1\main.cpp(26) : error C2662: 'TreeCtrl::Node::SetImage' : cannot convert 'this' pointer from
'const TreeCtrl::Node' to 'TreeCtrl::Node &'
|
Quote: |
Ah... Well, one of rare cases when C++ does not play well...
Try
TreeCtrl::Node n = tree.GetNode(editid);
n.SetImage(CtrlImg::ImgEdit());
tree.SetNode(editid, n);
Thinking about it, it would probably be better here to return Node value instead of constant reference... what do you think? (Constant reference is faster, however in this case it is very likely you are about to change the value in most cases).
Mirek
|
It works this morning... I can't believe it didn't work yesterday ... Something magic. Maybe I was too tired and did a typo mistake once again somewhere. And I knew about that const...
Anyway, thank you very much for confirming it because I was going mad and suspected bugs everywhere...
And I couldn't understand the reason of not returning Node... but I have not much against const if it works...
[Updated on: Sat, 08 April 2006 15:11] Report message to a moderator
|
|
|
Re: TreeCtrl - how to change images dynamically? [message #2339 is a reply to message #2337] |
Sat, 08 April 2006 16:33 |
|
mirek
Messages: 14105 Registered: November 2005
|
Ultimate Member |
|
|
fudadmin wrote on Sat, 08 April 2006 09:09 |
luzr wrote on Sat, 08 April 2006 13:05 |
I had tried this unsuccessfully... That's why I asked.
tree.SetNode(editid, tree.GetNode(editid).SetImage(CtrlImg::ImgEdit()));
E:\AriUppApps1\ideAris1\main.cpp(26) : error C2662: 'TreeCtrl::Node::SetImage' : cannot convert 'this' pointer from
'const TreeCtrl::Node' to 'TreeCtrl::Node &'
|
Quote: |
Ah... Well, one of rare cases when C++ does not play well...
Try
TreeCtrl::Node n = tree.GetNode(editid);
n.SetImage(CtrlImg::ImgEdit());
tree.SetNode(editid, n);
Thinking about it, it would probably be better here to return Node value instead of constant reference... what do you think? (Constant reference is faster, however in this case it is very likely you are about to change the value in most cases).
Mirek
|
It works this morning... I can't believe it didn't work yesterday ... Something magic. Maybe I was too tired and did a typo mistake once again somewhere. And I knew about that const...
Anyway, thank you very much for confirming it because I was going mad and suspected bugs everywhere...
And I couldn't understand the reason of not returning Node... but I have not much against const if it works...
|
Well, I have changed it to return value instead of reference... so no more confusion there
Mirek
|
|
|
Goto Forum:
Current Time: Fri Nov 01 00:08:18 CET 2024
Total time taken to generate the page: 0.01711 seconds
|
|
|