Click to See Complete Forum and Search --> : TVN_ITEMEXPANDING - returning TRUE does not stop the expand/collapse


JetDeveloper
August 12th, 2004, 12:30 PM
If I try to handle the TVN_ITEMEXPANDING message for my tree view, it will always
expand, no matter whether I return TRUE or FALSE. The documentation, however,
says

Return Values
TRUE prevents the list from expanding or collapsing.


The code is something like

case TVN_ITEMEXPANDING:
MessageBox(NULL,"This message box gets displayed!","INFO",MB_OK);
MessageBox(NULL,"Therefore we are receiving the TVN_ITEMEXPANDING","INFO",MB_OK);

// This should prevent the item from expanding
return TRUE;
// But it doesn't
// So the documentation is wrong, or something else is wrong



Please tell me why doesn't it work! Thank you.

usman999_1
August 12th, 2004, 04:23 PM
If I try to handle the TVN_ITEMEXPANDING message for my tree view, it will always
expand, no matter whether I return TRUE or FALSE. The documentation, however,
says


The code is something like

case TVN_ITEMEXPANDING:
MessageBox(NULL,"This message box gets displayed!","INFO",MB_OK);
MessageBox(NULL,"Therefore we are receiving the TVN_ITEMEXPANDING","INFO",MB_OK);

// This should prevent the item from expanding
return TRUE;
// But it doesn't
// So the documentation is wrong, or something else is wrong



Please tell me why doesn't it work! Thank you.
Is it a Dialogbox that is the parent of this TV???
Regards,
Usman.

JetDeveloper
August 12th, 2004, 06:23 PM
Yes it is a DialogBox. What now?

usman999_1
August 13th, 2004, 05:02 AM
I am not sure (since the reutrn should only be true or false) but to return anyother value besides true, false from DialogBoxProc you need to use SetWindowLong with the second param as DWL_MSGRESULT and third param should be the value you are trying to return. Just try returning value by the API i mentioned above and see if it works.
Hope this helps,
Regards,
Usman.

JetDeveloper
August 16th, 2004, 05:47 PM
Thank you usman. That works.

VladimirF
August 16th, 2004, 05:51 PM
And this is yet another reason not to use Dialog-based app design!

JetDeveloper
August 16th, 2004, 10:24 PM
And this is yet another reason not to use Dialog-based app design!

My treeview is in a property sheet dialog for configuration, though.

VladimirF
August 16th, 2004, 10:55 PM
My treeview is in a property sheet dialog for configuration, though.
Ooops... Spoke too soon.