Overlapping Windows

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

    • Overlapping Windows

      Hello,
      in my projectI have a menu bar which appears in different windows.
      The attached screenshot shows an example. The red framed section is the menu bar.
      Since I don't want to create all the menu controls in each window again I tried to put the menu bar into a separate dialog box sitting beside the main window.
      This works, but with the exception of the DROPDOWN widget. The dropdown would extend into the main window.
      So the menu window would have to overlap the main window temporarily. I don't know how to achieve this.
      I should also mention that the main window needs to accept inputs as well.

      May be two overlapping dialog boxes are not the right way to solve this problem?
      Is there an elegant way to "embed" reused dialogs into a window?
      Any ideas would be appreciated.

      Regards
      Jan


    • Hello,

      I would do something like this: reattach dropdown's child listbox to desktop window when dropdown is expanded so it will allow listbox to paint within whole desktop area not only within parent dialog.

      I created some code for simple windows. I think this will work also on dialogs.

      C Source Code

      1. #include "DIALOG.h"
      2. WM_HWIN hWin1, hWin2, hDropdown, hListbox;
      3. void _cbWin1(WM_MESSAGE * pMsg) {
      4. switch (pMsg->MsgId) {
      5. case WM_CREATE:
      6. // Create a dropdown, add some items
      7. hDropdown = DROPDOWN_CreateEx(10, 10, 100, 20, pMsg->hWin, WM_CF_SHOW, 0, GUI_ID_DROPDOWN0);
      8. DROPDOWN_SetListHeight(hDropdown, 67);
      9. DROPDOWN_AddString(hDropdown, "Item 1");
      10. DROPDOWN_AddString(hDropdown, "Item 2");
      11. DROPDOWN_AddString(hDropdown, "Item 3");
      12. DROPDOWN_AddString(hDropdown, "Item 4");
      13. DROPDOWN_AddString(hDropdown, "Item 5");
      14. break;
      15. case WM_NOTIFY_PARENT:
      16. // When dropdown is clicked check if it is expanded
      17. if ((pMsg->hWinSrc == hDropdown) && (pMsg->Data.v == WM_NOTIFICATION_CLICKED)) {
      18. hListbox = DROPDOWN_GetListbox(hDropdown);
      19. if (hListbox != 0) // if listbox is created and dropped reattach it to desktop window
      20. WM_AttachWindow(hListbox, WM_HBKWIN);
      21. }
      22. break;
      23. case WM_PAINT:
      24. // Draw some data
      25. GUI_SetBkColor(GUI_GRAY);
      26. GUI_Clear();
      27. GUI_DispStringHCenterAt("Window with dropdown", 210, 15);
      28. break;
      29. default:
      30. WM_DefaultProc(pMsg);
      31. break;
      32. }
      33. }
      34. void _cbWin2(WM_MESSAGE* pMsg) {
      35. switch (pMsg->MsgId) {
      36. case WM_PAINT:
      37. // Draw some data
      38. GUI_SetBkColor(GUI_RED);
      39. GUI_Clear();
      40. GUI_DispStringHCenterAt("Main window", 160, 100);
      41. break;
      42. default:
      43. WM_DefaultProc(pMsg);
      44. break;
      45. }
      46. }
      47. void MainTask(void) {
      48. GUI_Init();
      49. WM_MULTIBUF_Enable(1);
      50. hWin1 = WM_CreateWindow(0, 0, 320, 40, WM_CF_SHOW, _cbWin1, 0);
      51. hWin2 = WM_CreateWindow(0, 40, 320, 200, WM_CF_SHOW, _cbWin2, 0);
      52. while(1) {
      53. GUI_Delay(50);
      54. }
      55. }
      Display All
      Alex.
    • Thank you, Alex. Using WM_AttachWindow() is a smart way to solve the problem.
      In the meantime I also found a less elegant solution. I replaced the dropdown in the menu bar by a text item which at a click opens a new window with the dropdown on top of the other windows. It is closed again after clicking a dropdown entry. The visual result is also the desired one.

      Jan