Retriving data from item.lParam (TreeView) - Programmer
This is a discussion on Retriving data from item.lParam (TreeView) - Programmer ; Hello!
I am trying to implement a treeview and do the following:
...............
TVINSERTSTRUCT tvis;
....................
tvis.hParent = NULL;
tvis.hInsertAfter = TVI_ROOT;
tvis.item.mask = TVIF_IMAGE | TVIF_TEXT | TVIF_SELECTEDIMAGE |
TVIF_CHILDREN | TVIF_PARAM;
tvis.item.lParam = 0;
tvis.item.iImage = shfi.iIcon;
tvis.item.iSelectedImage ...
-
Retriving data from item.lParam (TreeView)
Hello!
I am trying to implement a treeview and do the following:
...............
TVINSERTSTRUCT tvis;
....................
tvis.hParent = NULL;
tvis.hInsertAfter = TVI_ROOT;
tvis.item.mask = TVIF_IMAGE | TVIF_TEXT | TVIF_SELECTEDIMAGE |
TVIF_CHILDREN | TVIF_PARAM;
tvis.item.lParam = 0;
tvis.item.iImage = shfi.iIcon;
tvis.item.iSelectedImage = shfi.iIcon;
tvis.item.pszText = szDisplayName;// <--- if I replace this with
//LPSTR_TEXTCALLBACK .How can I later retrieve this name?
//How to pass some extra data with:
tvis.item.lParam = (LPARAM)extradata; // I want to store a PIDL
hitemParent = TreeView_InsertItem(hwndTree,&tvis);
Later proccessing WM_NOTIFY message I dont know how to display name of
items.
And also want to retrieve PIDL stored in item.lParam for any item.
case WM_NOTIFY:
{
case IDC_TREEVIEW:
{
switch(((LPNMHDR)lParam)->code)
{
case NM_DBLCLK:
break;
case TVN_GETDISPINFO:
{
//I know that something should be written here
// but ....
}*/
Thank you!
-
Re: Retriving data from item.lParam (TreeView)
Slav,
You're correct in thinking that you need to code a handler for the
TVN_GETDISPINFO notification message. To do this, you must cast the
LPARAM to a LPNMTVDISPINFO, and then use the "item" member in that
structure to set your text, e.g.:
case TVN_GETDISPINFO:
{ // LPARAM points to a NMTVDISPINFO struct:
LPNMTVDISPINFO pd = (LPNMTVDISPINFO)lParam;
// Now the 'item' member of pd-> contains our TVITEM struct
if (pd->item.mask & TVIF_TEXT)
{
pd->item.pszText = "Hello world"; // set the item
text
}
}
break;
Good luck,
Les Matheson
Integral Concepts, Inc.
http://www.ivsds.com
zestrea@yahoo.com (Slav) wrote in message news:<93d2a655.0402130552.3ed6db50@posting.google.com>...
> Hello!
>
> I am trying to implement a treeview and do the following:
> ..............
> TVINSERTSTRUCT tvis;
> ...................
> tvis.hParent = NULL;
> tvis.hInsertAfter = TVI_ROOT;
> tvis.item.mask = TVIF_IMAGE | TVIF_TEXT | TVIF_SELECTEDIMAGE |
> TVIF_CHILDREN | TVIF_PARAM;
> tvis.item.lParam = 0;
> tvis.item.iImage = shfi.iIcon;
> tvis.item.iSelectedImage = shfi.iIcon;
> tvis.item.pszText = szDisplayName;// <--- if I replace this with
> //LPSTR_TEXTCALLBACK .How can I later retrieve this name?
> //How to pass some extra data with:
> tvis.item.lParam = (LPARAM)extradata; // I want to store a PIDL
>
> hitemParent = TreeView_InsertItem(hwndTree,&tvis);
>
> Later proccessing WM_NOTIFY message I dont know how to display name of
> items.
> And also want to retrieve PIDL stored in item.lParam for any item.
>
> case WM_NOTIFY:
> {
> case IDC_TREEVIEW:
> {
> switch(((LPNMHDR)lParam)->code)
> {
> case NM_DBLCLK:
> break;
> case TVN_GETDISPINFO:
> {
> //I know that something should be written here
> // but ....
> }*/
>
> Thank you!