when does WM_NOTIFICATION_RELEASED occur?

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

    • I have a screen which has multiple buttons. Once any button is pressed , all other buttons must not take any input from user. Can I disable the background window using WM_DisableWindow()? Will it disable the buttons at once instead of disabling each and every button?



      Is there any other approach other than above mentioned one?
      1. What is the risk involved in using WM_SetCapture and WM_ReleaseCapture?
      2. Will modal window approach work?

      The post was edited 1 time, last by Manasa ().

    • Hi,

      WM_DisableWindow() will only disable the window/widget with the given handle.

      So, you have to disable all buttons manually. If you assign the IDs for these buttons successively you can iterate over the button IDs to disable them.

      1.
      Set capture might work. But this depends on your application.

      2.
      This will work. But also any other widget/window won't get input.

      I would use WM_DisableWindow().

      Here is a short example:


      C Source Code

      1. #include "DIALOG.h"
      2. /*********************************************************************
      3. *
      4. * Defines
      5. *
      6. **********************************************************************
      7. */
      8. #define ID_WINDOW_0 (GUI_ID_USER + 0x00)
      9. #define ID_BUTTON_0 (GUI_ID_USER + 0x01)
      10. #define ID_BUTTON_1 (GUI_ID_USER + 0x02)
      11. #define ID_BUTTON_2 (GUI_ID_USER + 0x03)
      12. /*********************************************************************
      13. *
      14. * Static data
      15. *
      16. **********************************************************************
      17. */
      18. /*********************************************************************
      19. *
      20. * _aDialogCreate
      21. */
      22. static const GUI_WIDGET_CREATE_INFO _aDialogCreate[] = {
      23. { WINDOW_CreateIndirect, "Window", ID_WINDOW_0, 0, 0, 320, 240, 0, 0x0, 0 },
      24. { BUTTON_CreateIndirect, "Button", ID_BUTTON_0, 10, 10, 80, 20, 0, 0x0, 0 },
      25. { BUTTON_CreateIndirect, "Button", ID_BUTTON_1, 10, 40, 80, 20, 0, 0x0, 0 },
      26. { BUTTON_CreateIndirect, "Button", ID_BUTTON_2, 10, 70, 80, 20, 0, 0x0, 0 },
      27. };
      28. /*********************************************************************
      29. *
      30. * Static code
      31. *
      32. **********************************************************************
      33. */
      34. /*********************************************************************
      35. *
      36. * _ButtonsOnOff
      37. */
      38. static void _ButtonsOnOff(WM_HWIN hButtonPressed, WM_HWIN hDialog, int * pDisabled) {
      39. WM_HWIN hItem;
      40. int i;
      41. for (i = 0; i < 3; i++) {
      42. hItem = WM_GetDialogItem(hDialog, ID_BUTTON_0 + i);
      43. if (hItem != hButtonPressed) {
      44. if (*pDisabled) {
      45. WM_EnableWindow(hItem);
      46. } else {
      47. WM_DisableWindow(hItem);
      48. }
      49. }
      50. }
      51. *pDisabled ^= 1;
      52. }
      53. /*********************************************************************
      54. *
      55. * _cbDialog
      56. */
      57. static void _cbDialog(WM_MESSAGE * pMsg) {
      58. int NCode;
      59. int Id;
      60. static int Disabled;
      61. switch (pMsg->MsgId) {
      62. case WM_NOTIFY_PARENT:
      63. Id = WM_GetId(pMsg->hWinSrc);
      64. NCode = pMsg->Data.v;
      65. switch(Id) {
      66. case ID_BUTTON_0: // Notifications sent by 'Button'
      67. switch(NCode) {
      68. case WM_NOTIFICATION_CLICKED:
      69. break;
      70. case WM_NOTIFICATION_RELEASED:
      71. _ButtonsOnOff(pMsg->hWinSrc, pMsg->hWin, &Disabled);
      72. break;
      73. }
      74. break;
      75. case ID_BUTTON_1: // Notifications sent by 'Button'
      76. switch(NCode) {
      77. case WM_NOTIFICATION_CLICKED:
      78. break;
      79. case WM_NOTIFICATION_RELEASED:
      80. _ButtonsOnOff(pMsg->hWinSrc, pMsg->hWin, &Disabled);
      81. break;
      82. }
      83. break;
      84. case ID_BUTTON_2: // Notifications sent by 'Button'
      85. switch(NCode) {
      86. case WM_NOTIFICATION_CLICKED:
      87. break;
      88. case WM_NOTIFICATION_RELEASED:
      89. _ButtonsOnOff(pMsg->hWinSrc, pMsg->hWin, &Disabled);
      90. break;
      91. }
      92. break;
      93. }
      94. break;
      95. default:
      96. WM_DefaultProc(pMsg);
      97. break;
      98. }
      99. }
      100. /*********************************************************************
      101. *
      102. * _cbBk
      103. */
      104. static void _cbBk(WM_MESSAGE * pMsg) {
      105. switch (pMsg->MsgId) {
      106. case WM_PAINT:
      107. GUI_SetBkColor(GUI_BLACK);
      108. GUI_Clear();
      109. break;
      110. default:
      111. WM_DefaultProc(pMsg);
      112. break;
      113. }
      114. }
      115. /*********************************************************************
      116. *
      117. * Public code
      118. *
      119. **********************************************************************
      120. */
      121. /*********************************************************************
      122. *
      123. * MainTask
      124. */
      125. void MainTask(void) {
      126. GUI_Init();
      127. WM_SetCallback(WM_HBKWIN, _cbBk);
      128. GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), _cbDialog, WM_HBKWIN, 0, 0);
      129. while (1) {
      130. GUI_Delay(100);
      131. }
      132. }
      133. /*************************** End of file ****************************/
      Display All
      EDIT:
      Did a mistake in the example. Fixed.

      Regards,

      Sven