Window validation

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

    • Window validation

      Hi all,
      I have a doubt regarding validity of a window. I created one window by using GUI_CreateDialogBox() and deleted using GUI_EndDialog(). according to my understanding once a dialog box is deleted the handle of that dialog box becomes invalid. after that is there any chance that it can become valid without creating it.
      I am facing some strange behavior that when i call GUI_EndDialog() and after that GUI_Exec() then if i check validity it is telling invalid but after some operation it is coming as a valid window. when it can happen? for valid check i am calling WM_IsWindow().
      Another doubt is that when we call GUI_EndDialog(). it will only free the memory and visually it will not go?am i correct?.
      Please clarify my doubts.
      Thank you :) .
    • Hi,

      Lets say after creating the dialog you receive the handle with a value of e.g. 1. Now you delete the dialog, but the handle will still have a value of 1. Later on, another window/dialog gets created and the new handle has also a value of 1, because the memory (which was used for the first/deleted dialog) was getting reused.

      It would be better if you set the value of the handle to 0 after deleting, like:

      GUI_EndDialog(hDialog);
      hDialog = 0;

      This way you can make sure that if the handle is 0, no dialog is created.

      Kusum Swarankar wrote:

      it will only free the memory and visually it will not go?
      It will also disappear visually. But if there is no callback or color set for the background it will remain visible, because there is no routine to clear the background. Try either to set a callback for the background or set a color for the background.

      Either set a callback:

      Source Code

      1. static void _cbBk(WM_MESSAGE * pMsg) {
      2. switch (pMsg->MsgId) {
      3. case WM_PAINT:
      4. GUI_SetBkColor(GUI_BLACK);
      5. GUI_Clear();
      6. break;
      7. default:
      8. WM_DefaultProc(pMsg);
      9. break;
      10. }
      11. }
      12. void MainTask(void) {
      13. GUI_Init();
      14. WM_SetCallback(WM_HBKWIN, _cbBk);
      15. while (1) {
      16. GUI_Delay(100);
      17. }
      18. }
      Display All

      Or set a background color:

      Source Code

      1. void MainTask(void) {
      2. GUI_Init();
      3. WM_SetDesktopColor(GUI_BLACK);
      4. while (1) {
      5. GUI_Delay(100);
      6. }
      7. }
      Regards,
      Sven