Widget Edit display unexpected length string

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

    • Widget Edit display unexpected length string

      I have a Edit on a Dialog which should display a default string like "123456_789abc". However, when I run this code, only "123456_7" is displayed while other chars are missing. I typed the missing chars into the Edit on touch screen manually and it is succesful. This means the Edit have enough space to display the whole string. The question is why the string is truncated in this Edit?

      Source Code

      1. void _cbDialogSave(WM_MESSAGE * pMsg) {
      2. switch (pMsg->MsgId) {
      3. case WM_INIT_DIALOG:
      4. // Edit
      5. hItem = WM_GetDialogItem(pMsg->hWin, ID_WENJIANMING_EDIT);
      6. EDIT_SetText(hItem, "123456_789abc");
      7. EDIT_SetFont(hItem, GUI_FONT_20_1);
      8. EDIT_SetTextAlign(hItem, GUI_TA_LEFT | GUI_TA_VCENTER);
      9. EDIT_SetTextColor(hItem, EDIT_CI_ENABLED, GUI_BLACK);
      10. EDIT_SetMaxLen(hItem, 1000);
      11. WM_SetFocus(hItem);
      12. // BUTTON1 & BUTTON2
      13. ...
      14. break;
      15. case WM_PAINT:
      16. GUI_SetBkColor(GUI_DARKBLUE);
      17. GUI_Clear();
      18. break;
      19. case WM_NOTIFY_PARENT:
      20. Id = WM_GetId(pMsg->hWinSrc);
      21. NCode = pMsg->Data.v;
      22. switch (Id) {
      23. case BUTTON1:
      24. ...
      25. break;
      26. case BUTTON2:
      27. ...
      28. break;
      29. }
      30. break;
      31. default:
      32. WM_DefaultProc(pMsg);
      33. break;
      34. }
      35. }
      Display All
    • Hi Ross Lee,

      can you tell me what maximum length you set to the EDIT widget when you create it? EDIT_SetMaxLen(hItem, 1000); could fail due to not enough memory being available.

      Best regards,

      Florian
      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.
    • Hi,

      What also could be happening is that the full text is indeed visibile at init but after drawing that text, another widget is drawn over the position of the chars '89abc' . When adding those chars in the PAINT or EDIT or other function after INIT, you overdraw that space again with the '89abc' text
    • Hi,
      This issue is finally solved by changing the element Para of Edit in resource table.

      As said in datasheet of emwin " The element Para is used according to the parameter MaxLen of the function EDIT_CreateEx()."




      Original code:

      Source Code

      1. { EDIT_CreateIndirect, "", ID_WENJIANMING_EDIT, 160, 300, 260, 60, 0, 0x0, 0 },


      Modified code:

      Source Code

      1. { EDIT_CreateIndirect, "", ID_WENJIANMING_EDIT, 160, 300, 260, 60, 0, 0x20, 0 },
    • Hi Ross Lee,

      if you leave out the Para element, the EDIT widget will have a default length of 8. That was indeed your mistake.
      Now if you want to increase the text length and add a longer text to your widget, you should call EDIT_SetMaxLen() before EDIT_SetText().

      Best regards,

      Florian
      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.