How to trigger TREEVIEW WM_NOTIFICATION_SEL_CHANGED?

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • How to trigger TREEVIEW WM_NOTIFICATION_SEL_CHANGED?

      ?( case ID_TREEVIEW_0: // Notifications sent by 'Treeview'
      switch(NCode) {
      case WM_NOTIFICATION_CLICKED:
      // USER START (Optionally insert code for reacting on notification message)
      //worked
      // USER END
      break;
      case WM_NOTIFICATION_RELEASED:
      // USER START (Optionally insert code for reacting on notification message)
      //worked
      // USER END
      break;
      case WM_NOTIFICATION_MOVED_OUT:
      // USER START (Optionally insert code for reacting on notification message)
      // USER END
      break;
      case WM_NOTIFICATION_SEL_CHANGED:
      // USER START (Optionally insert code for reacting on notification message)
      //How to trigger???????????????????????????????????????
      // USER END
      break;
      // USER START (Optionally insert additional code for further notification handling)
      // USER END
      }
    • Hi,

      Yes you are right, I have fixed this in the source code and it will be released with the next version of emWin.

      For now you can do this as a workaround. On creating the TREEVIEW widget get its initial selection. On a click message get the current election and compare both. If they differ send a message to the parent of the TREEVIEW.

      C Source Code

      1. static void _cbDialog(WM_MESSAGE * pMsg) {
      2. TREEVIEW_ITEM_Handle hTreeItemCur;
      3. TREEVIEW_ITEM_Handle hTreeItemNew;
      4. WM_HWIN hItem;
      5. int NCode;
      6. int Id;
      7. static int LastSel;
      8. int CurSel;
      9. switch (pMsg->MsgId) {
      10. case WM_INIT_DIALOG:
      11. //
      12. // Initialization of 'Treeview'
      13. //
      14. hItem = WM_GetDialogItem(pMsg->hWin, ID_TREEVIEW_0);
      15. hTreeItemCur = TREEVIEW_GetItem(hItem, 0, TREEVIEW_GET_LAST);
      16. hTreeItemNew = TREEVIEW_ITEM_Create(TREEVIEW_ITEM_TYPE_NODE, "1", 0);
      17. TREEVIEW_AttachItem(hItem, hTreeItemNew, hTreeItemCur, TREEVIEW_INSERT_BELOW);
      18. hTreeItemCur = TREEVIEW_GetItem(hItem, 0, TREEVIEW_GET_LAST);
      19. hTreeItemNew = TREEVIEW_ITEM_Create(TREEVIEW_ITEM_TYPE_NODE, "2", 0);
      20. TREEVIEW_AttachItem(hItem, hTreeItemNew, hTreeItemCur, TREEVIEW_INSERT_BELOW);
      21. hTreeItemCur = TREEVIEW_GetItem(hItem, 0, TREEVIEW_GET_LAST);
      22. hTreeItemNew = TREEVIEW_ITEM_Create(TREEVIEW_ITEM_TYPE_NODE, "3", 0);
      23. TREEVIEW_AttachItem(hItem, hTreeItemNew, hTreeItemCur, TREEVIEW_INSERT_BELOW);
      24. LastSel = TREEVIEW_GetSel(hItem);
      25. break;
      26. case WM_NOTIFY_PARENT:
      27. Id = WM_GetId(pMsg->hWinSrc);
      28. NCode = pMsg->Data.v;
      29. switch(Id) {
      30. case ID_TREEVIEW_0: // Notifications sent by 'Treeview'
      31. switch(NCode) {
      32. case WM_NOTIFICATION_CLICKED:
      33. hItem = WM_GetDialogItem(pMsg->hWin, ID_TREEVIEW_0);
      34. CurSel = TREEVIEW_GetSel(hItem);
      35. if (CurSel != LastSel) {
      36. WM_NotifyParent(hItem, WM_NOTIFICATION_SEL_CHANGED);
      37. LastSel = CurSel;
      38. }
      39. break;
      40. case WM_NOTIFICATION_RELEASED:
      41. break;
      42. case WM_NOTIFICATION_MOVED_OUT:
      43. break;
      44. case WM_NOTIFICATION_SEL_CHANGED:
      45. {
      46. volatile int Temp = 0;
      47. }
      48. break;
      49. }
      50. break;
      51. }
      52. break;
      53. default:
      54. WM_DefaultProc(pMsg);
      55. break;
      56. }
      57. }
      Display All

      Regards,
      Sven