Rather than attach an image you should have better debugged your code to see what, where and why goes wrong or at least unexpected!
Second note: despite you put your code between the Code tags it is not so easy to read/understand. It is just because of inproper code indentations!
pDispInfo->item.pszText needs to be a pointer to the text. You don't copy the text itself - you just set pszText to point to the start of the text to be stored. I don't know the structure of testing but try pDispInfo->item.pszText = node->strFileName;
which gives me the error
error C2440: 'type cast' : cannot convert from 'struct testing' to 'long'
No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
As node is now an auto structure on the stack its address can't be used as an element of lvi as the address will be invalid when OnGetdispinfoList1 is called. A quick and dirty workaround for this is to make node static and then pass its addess to lvi
If you allocate memory for node on the heap by using new, then you will need to deallocate that memory once you are finished with it using delete otherwise you will have a memory leak.
Node is defined as a pointer to testing with memory allocated for that structure - which just contains a pointer to a char. So the node->strFileName = data2.cFileName will set this char pointer to the addess of the cFileName entry in data2. However, data2 is overwritten every time you go through the loop to get the next file name!
So you also need to allocate memory for the string held within node and then copy the contents of cFileName to that memory. Something like
Code:
testing *node = new testing();
node->strFileName = new char[lstrlen(data2.cFileName) + 1];
lstrcpy(node->strFileName, data2.cFileName);
Note that when finished with the file names then the memory pointed to by strFileName need to be deleted first then the memory pointed to by node is then deleted - otherwise you have a memory leak!
Why are you using LPSTR_TEXTCALLBACK? If all you are trying to do is to populate a list box with file names then this can be done directly without using callback.
Whoops, sorry - I've had a long day and brain is frazzled! Doing it this way you don't need to allocate memory as that would cause a memory leak! You just need lvi.pszText = data2.cFileName. My FindNextFile line somehow got corrupted when copied. The code should be
In your find file code you are also not closing the find handle when finished. This will cause a resource leak. Once all the file names have been obtained then the handle should be closed as in
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.