How to access AppWizard PROGBAR widget from C?

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

    • How to access AppWizard PROGBAR widget from C?

      If I create in C code progress like this:

      Source Code

      1. void cbID_SCREEN_Initial(WM_MESSAGE * pMsg) {
      2. GUI_USE_PARA(pMsg);
      3. PROGBAR_Handle ahProgBar;
      4. switch (pMsg->MsgId)
      5. {
      6. case WM_INIT_DIALOG:
      7. ahProgBar = PROGBAR_CreateEx (245, 70, 200, 30, pMsg->hWin, WM_CF_SHOW, PROGBAR_CF_HORIZONTAL, GUI_ID_PROGBAR0);
      8. break;
      9. }
      10. }
      Display All
      Then I can this code works:

      Source Code

      1. PROGBAR_Handle ahProgBar = WM_GetDialogItem (ID_SCREEN_Initial, GUI_ID_PROGBAR0);
      2. PROGBAR_SetValue (ahProgBar, 12);
      However, if I create PROGBAR in AppWizard GUI tool, following lines


      Source Code

      1. PROGBAR_Handle ahProgBar = WM_GetDialogItem (ID_SCREEN_Initial, ID_PROGBAR_Initial);
      2. PROGBAR_SetValue (ahProgBar, 12); <--- crash


      give crash in simulator (didn't tried on real hw):
      "PROGBAR.c
      Wrong handle type or Object not init'ed in PROGBAR_LockH()"

      Obviously AppWizard PROGBAR widget isn't the same as emWin widget.

      How to properly access AppWizard PROGBAR from C code?
      Images
      • AppWizardProgbar.png

        96.53 kB, 1,360×851, viewed 425 times
      • AppWizardProgbarCrash.png

        28.62 kB, 547×422, viewed 406 times
    • Hi,

      I have already replied to you by email, but I will address this on the forum as well, in case any other users come across this.

      We do not guarantee that the emWin widget API works for AppWizard objects as well. For most objects the API functions work the same, but for a few exceptions, like the PROGBAR, they do not.

      It is safer to do this with AppWizard variables:
      • Add a new variable to the project (e.g. ID_VAR_PROGBAR).
      • Then add an interaction so that when the variable changes the value will be set to the PROGBAR (see attached image).
      • Now, when you set the value of the variable in user code, the value will also be set to the PROGBAR, since we react on a VALUE_CHANGED signal:

      C Source Code

      1. APPW_SetVarData(ID_VAR_PROGBAR, 100);

      Best regards,
      Florian
      Images
      • Interaction.jpg

        6.1 kB, 600×45, viewed 323 times
      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.