Full-screen child window

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

    • Full-screen child window

      Some windows needs to create a full-screen child window (in my case, a keypad). However the parent window isn't full-screen, so the keypad will not be full-screen too.

      I know I can create the keypad window as a child of the background window (and put it at the top), however in this case the keypad will not be automatically deleted when the creator window is deleted.

      Is there a better approach? Is it possible to create a child window larger than the parent window?
    • Hi,

      you could create the fullscreen window as child of the WM_HBKWIN (the desktop window) and remember its handle. Once the smaller 'parent'-window gets deleted you also delete the fullscreen child.

      Like this:

      C Source Code

      1. #include "DIALOG.h"
      2. /*********************************************************************
      3. *
      4. * Externals
      5. *
      6. **********************************************************************
      7. */
      8. /*********************************************************************
      9. *
      10. * Defines
      11. *
      12. **********************************************************************
      13. */
      14. /*********************************************************************
      15. *
      16. * Static data
      17. *
      18. **********************************************************************
      19. */
      20. /*********************************************************************
      21. *
      22. * Static code
      23. *
      24. **********************************************************************
      25. */
      26. /*********************************************************************
      27. *
      28. * _cbFullScreen
      29. */
      30. static void _cbFullScreen(WM_MESSAGE * pMsg) {
      31. switch (pMsg->MsgId) {
      32. case WM_PAINT:
      33. GUI_SetBkColor(GUI_GREEN);
      34. GUI_Clear();
      35. GUI_DispString("FullScreen");
      36. break;
      37. default:
      38. WM_DefaultProc(pMsg);
      39. break;
      40. }
      41. }
      42. /*********************************************************************
      43. *
      44. * _cbParent
      45. */
      46. static void _cbParent(WM_MESSAGE * pMsg) {
      47. static WM_HWIN hFullscreen;
      48. static int Once;
      49. switch (pMsg->MsgId) {
      50. case WM_CREATE:
      51. WM_CreateTimer(pMsg->hWin, 0, 1000, 0);
      52. break;
      53. case WM_TIMER:
      54. if (hFullscreen == 0) {
      55. hFullscreen = WM_CreateWindowAsChild(0, 0, LCD_GetXSize(), LCD_GetYSize(), WM_HBKWIN, WM_CF_SHOW, _cbFullScreen, 0);
      56. }
      57. if (Once) {
      58. WM_DeleteWindow(pMsg->hWin);
      59. } else {
      60. WM_RestartTimer((WM_HTIMER)pMsg->Data.v, 0);
      61. }
      62. Once = 1;
      63. break;
      64. case WM_PAINT:
      65. GUI_SetBkColor(GUI_RED);
      66. GUI_Clear();
      67. GUI_DispString("Parent");
      68. break;
      69. case WM_DELETE:
      70. if (hFullscreen) {
      71. WM_DeleteWindow(hFullscreen);
      72. hFullscreen = 0;
      73. }
      74. break;
      75. default:
      76. WM_DefaultProc(pMsg);
      77. break;
      78. }
      79. }
      80. /*********************************************************************
      81. *
      82. * _cbBk
      83. */
      84. static void _cbBk(WM_MESSAGE * pMsg) {
      85. switch (pMsg->MsgId) {
      86. case WM_PAINT:
      87. GUI_SetBkColor(GUI_BLACK);
      88. GUI_Clear();
      89. break;
      90. default:
      91. WM_DefaultProc(pMsg);
      92. break;
      93. }
      94. }
      95. /*********************************************************************
      96. *
      97. * Public code
      98. *
      99. **********************************************************************
      100. */
      101. /*********************************************************************
      102. *
      103. * MainTask
      104. */
      105. void MainTask(void) {
      106. GUI_Init();
      107. WM_SetCallback(WM_HBKWIN, _cbBk);
      108. WM_CreateWindowAsChild(50, 50, 100, 100, WM_HBKWIN, WM_CF_SHOW, _cbParent, 0);
      109. while (1) {
      110. GUI_Delay(100);
      111. }
      112. }
      113. /*************************** End of file ****************************/
      Display All
      Regards,
      Sven