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,
      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 },