emwin calendar

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

    • emwin calendar

      Hi
      In my parent window when i click a button i open a calendar dialog. i would like to know once i click in someother part of parent window how the calendar dialog can be hidden like under which event i can handle this situation. i tried during WM_PAINT where i am keep checking whether calendar window is visible && has not captured touch && has focus i will disable but its happening once i create the calendar i want to handle this kind of feature when user touches any other place other than widgets in parent window the calendar dialog gets hidden.
    • Hi,

      Simply react on WM_TOUCH of the parent window (the dialog in the example below) and delete the calendar.

      C Source Code

      1. #include "DIALOG.h"
      2. /*********************************************************************
      3. *
      4. * Externals
      5. *
      6. **********************************************************************
      7. */
      8. /*********************************************************************
      9. *
      10. * Defines
      11. *
      12. **********************************************************************
      13. */
      14. #define ID_WINDOW_0 (GUI_ID_USER + 0x00)
      15. #define ID_BUTTON_0 (GUI_ID_USER + 0x01)
      16. /*********************************************************************
      17. *
      18. * Static data
      19. *
      20. **********************************************************************
      21. */
      22. /*********************************************************************
      23. *
      24. * _aDialogCreate
      25. */
      26. static const GUI_WIDGET_CREATE_INFO _aDialogCreate[] = {
      27. { WINDOW_CreateIndirect, "Window", ID_WINDOW_0, 0, 0, 480, 272, 0, 0x0, 0 },
      28. { BUTTON_CreateIndirect, "Calendar", ID_BUTTON_0, 20, 20, 80, 20, 0, 0x0, 0 },
      29. };
      30. /*********************************************************************
      31. *
      32. * Static code
      33. *
      34. **********************************************************************
      35. */
      36. /*********************************************************************
      37. *
      38. * _cbDialog
      39. */
      40. static void _cbDialog(WM_MESSAGE * pMsg) {
      41. WM_HWIN hItem;
      42. int NCode;
      43. int Id;
      44. switch (pMsg->MsgId) {
      45. case WM_NOTIFY_PARENT:
      46. Id = WM_GetId(pMsg->hWinSrc);
      47. NCode = pMsg->Data.v;
      48. switch(Id) {
      49. case ID_BUTTON_0: // Notifications sent by 'Calendar'
      50. switch(NCode) {
      51. case WM_NOTIFICATION_RELEASED:
      52. //
      53. // Get CALENDAR handle and check if already opened, if not create a calendar
      54. //
      55. hItem = WM_GetDialogItem(pMsg->hWin, GUI_ID_CALENDAR0);
      56. if (!hItem) {
      57. CALENDAR_Create(pMsg->hWin, 20, 20, 2018, 5, 8, 2, GUI_ID_CALENDAR0, WM_CF_SHOW);
      58. }
      59. break;
      60. }
      61. break;
      62. }
      63. break;
      64. case WM_TOUCH:
      65. //
      66. // On touch, check if CALENDAR is present, if true delete it
      67. //
      68. hItem = WM_GetDialogItem(pMsg->hWin, GUI_ID_CALENDAR0);
      69. if (hItem) {
      70. WM_DeleteWindow(hItem);
      71. }
      72. //
      73. // Call default handler
      74. //
      75. WM_DefaultProc(pMsg);
      76. break;
      77. default:
      78. WM_DefaultProc(pMsg);
      79. break;
      80. }
      81. }
      82. /*********************************************************************
      83. *
      84. * _cbBk
      85. */
      86. static void _cbBk(WM_MESSAGE * pMsg) {
      87. switch (pMsg->MsgId) {
      88. case WM_PAINT:
      89. GUI_SetBkColor(GUI_DARKGREEN);
      90. GUI_Clear();
      91. break;
      92. default:
      93. WM_DefaultProc(pMsg);
      94. break;
      95. }
      96. }
      97. /*********************************************************************
      98. *
      99. * Public code
      100. *
      101. **********************************************************************
      102. */
      103. /*********************************************************************
      104. *
      105. * MainTask
      106. */
      107. void MainTask(void) {
      108. GUI_Init();
      109. WM_SetCallback(WM_HBKWIN, _cbBk);
      110. GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), _cbDialog, WM_HBKWIN, 0, 0);
      111. while (1) {
      112. GUI_Delay(100);
      113. }
      114. }
      115. /*************************** End of file ****************************/
      Display All


      Regards,
      Sven
      Please read the forum rules before posting.

      Keep in mind, this is *not* a support forum.
      Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
      Should you be entitled to support you can contact us via our support system: segger.com/ticket/

      Or you can contact us via e-mail.
    • hi
      thanks

      i tried its getting deleted if i touch on the parent window but if i selecting any date in the calendar that time also its getting deleted.
      i would like to delete the calendar once the user click on parent window not when he is selecting any date in the calendar r doing right left scroll to change the month
    • Hi,

      On my end doesn't gets deleted when I select a date.
      I can't say why it behaves like this on your side.

      Regards,
      Sven
      Please read the forum rules before posting.

      Keep in mind, this is *not* a support forum.
      Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
      Should you be entitled to support you can contact us via our support system: segger.com/ticket/

      Or you can contact us via e-mail.
    • hello sven

      also i would like to know about the scroll buttons provided in calendar. as when i press the scroll buttons rarely it changes the months.
      how can i manually increment decrement months based on case WM_NOTIFICATION_SCROLL_CHANGED: where i need to identify which scroll button is pressed left or right one.

      thanks