Starting with Appwizard

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

    • Starting with Appwizard

      Hi! i am new in general with all of this, but currently i'm working on a project and using Appwizard, the design and interaction parts were relatively easy, but i need to add some dropdown widgets, been looking for some help and found a documentation from renesas explaining how to add emWin widgets to Appwizzard application, but i have problems understanding what pMsg->hWin, in the image is what i get, but my parent window is under and not set to appear yet. Anyone who can explain it to me in simple terms would we great :D
      Images
      • Screenshot 2021-11-15 090428.jpg

        32.74 kB, 548×409, viewed 433 times
    • Hi,

      The handle "pMsg->hWin" refers to is always the handle of the window where the callback function belongs to.

      In the AppWizard output files (e.g. ID_SCREEN_00_Slots.c) you will find the callback function as shown below. Here the handle "pMsg->hWin" refers to the screen with the Id ID_SCREEN_00 (most likely the main screen).

      C Source Code

      1. void cbID_SCREEN_00(WM_MESSAGE * pMsg) {
      2. GUI_USE_PARA(pMsg);
      3. }


      So, if you like add a normal emWin widget to this screen you could something like:

      C Source Code

      1. void cbID_SCREEN_00(WM_MESSAGE * pMsg) {
      2. WM_HWIN hWin;
      3. switch (pMsg->MsgId) {
      4. case WM_INIT_DIALOG:
      5. hWin = DROPDOWN_CreateEx(10, 10, 80, 20, pMsg->hWin, WM_CF_SHOW, 0, GUI_ID_DROPDOWN0);
      6. break;
      7. }
      8. }

      Now, the dropdown widget is a child window of the screen. If you intend to react on the dropdown you could extend the screen callback function:

      C Source Code

      1. void cbID_SCREEN_00(WM_MESSAGE * pMsg) {
      2. WM_HWIN hWin;
      3. int Id, NCode;
      4. switch (pMsg->MsgId) {
      5. case WM_INIT_DIALOG:
      6. hWin = DROPDOWN_CreateEx(10, 10, 80, 20, pMsg->hWin, WM_CF_SHOW, 0, GUI_ID_DROPDOWN0);
      7. break;
      8. case WM_NOTIFY_PARENT:
      9. Id = WM_GetId(pMsg->hWinSrc);
      10. NCode = pMsg->Data.v;
      11. switch(Id) {
      12. case GUI_ID_DROPDOWN0:
      13. switch(NCode) {
      14. case WM_NOTIFICATION_CLICKED:
      15. break;
      16. case WM_NOTIFICATION_RELEASED:
      17. break;
      18. case WM_NOTIFICATION_SEL_CHANGED:
      19. break;
      20. }
      21. break;
      22. }
      23. }
      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.
    • Thank you so much, it is very useful!. One more question, what should i do if that dropdown belongs to a window in a screen, with your example i finally managed to show and interact with the widget, but other interaction overlap other windows and should hide the dropdown, don't know if i made myself clear but if someone get it and could explain it will be appreciated.
    • Hi,

      If you are referring to a WINDOW (ID_WINDOW_00) added with the AppWizard you could do the following:

      C Source Code

      1. static void _cbWin(WM_MESSAGE * pMsg) {
      2. int Id, NCode;
      3. switch (pMsg->MsgId) {
      4. case WM_NOTIFY_PARENT:
      5. Id = WM_GetId(pMsg->hWinSrc);
      6. NCode = pMsg->Data.v;
      7. switch(Id) {
      8. case GUI_ID_DROPDOWN0:
      9. switch(NCode) {
      10. case WM_NOTIFICATION_CLICKED:
      11. break;
      12. case WM_NOTIFICATION_RELEASED:
      13. break;
      14. case WM_NOTIFICATION_SEL_CHANGED:
      15. break;
      16. }
      17. break;
      18. }
      19. break;
      20. default:
      21. WM_OBJECT_WINDOW_cb(pMsg);
      22. break;
      23. }
      24. }
      25. void cbID_SCREEN_00(WM_MESSAGE * pMsg) {
      26. WM_HWIN hWin;
      27. switch (pMsg->MsgId) {
      28. case WM_INIT_DIALOG:
      29. hWin = WM_GetDialogItem(pMsg->hWin, ID_WINDOW_00);
      30. WM_SetCallback(hWin, _cbWin);
      31. hWin = DROPDOWN_CreateEx(10, 10, 80, 20, hWin, WM_CF_SHOW, 0, GUI_ID_DROPDOWN0);
      32. break;
      33. }
      34. }
      Display All
      Now the DROPDOWN is a child widget of the window (ID_WINDOW_00) and the DROPDOWN notifications are getting send to _cbWin.

      If you mean a "normal" WM-window you might want to refer to this example.

      alpe wrote:

      but other interaction overlap other windows and should hide the dropdown

      Not sure what you mean with that.

      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.
    • Thanks a lot! that solved my problem :D. One last question, when i designed the application in Appwizard, i made the mistake of not following any rule to name everything in order and not repeating any name, later i changed every name accordingly to the recommendation of the user manual, e.g before it was "window1" and after renaming "ID_WINDOW_MENU", but every time i open visual to edit some code, still get the same error caused by the old name even tough new changes appear normally. The error is simple to fix, but that's not a good way to begin with coding so i want to fix it permanently, is there a way to fix that? it's okay if my code is erased, it's that long and could do it again. For all your help you already gave, thank you and hope you could help me with this too.