PROGBAR doesn't change colors

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

    • PROGBAR doesn't change colors

      I use emWin provided by ST (STemWin based on emWin 5.40)

      I tried to change PROGBAR colors but nothing happens.

      I downloaded emWin tutorial (both executables and source code). Also the WIDGET_Progbar sample doesn't change the colors:

      [img]https://s18.postimg.org/y20p2twa1/WIDGET_Progbar-_Sample.png[/img]

      In the source code there is:

      C Source Code

      1. while(1) {
      2. PROGBAR_SetFont(ahProgBar[0], &GUI_Font8x16);
      3. if (LCD_GetDevCap(LCD_DEVCAP_BITSPERPIXEL) <= 4) {
      4. PROGBAR_SetBarColor(ahProgBar[0], 0, GUI_DARKGRAY);
      5. PROGBAR_SetBarColor(ahProgBar[0], 1, GUI_LIGHTGRAY);
      6. } else {
      7. PROGBAR_SetBarColor(ahProgBar[0], 0, GUI_GREEN);
      8. PROGBAR_SetBarColor(ahProgBar[0], 1, GUI_RED);
      9. }
      10. PROGBAR_SetTextAlign(ahProgBar[0], GUI_TA_HCENTER);
      11. PROGBAR_SetText(ahProgBar[0], NULL);
      Display All


      So is it possible to change the colors of the PROGBAR? how?

      best regards
      Max
    • Hi,

      For some widgets it is not possible to change the color with functions like <WIDGET>_SetColor() because they use a skinning routine to draw themself (e.g. the PROGBAR widget).

      To change the colors to be used you can set the properties (like the colors) for the widget with the function <WIDGET>_SetSkinFlexProps() (or in this case PROGBAR_SetSkinFlexProps()).

      Best way is to read the properties and write them back. This allows you to change only one property and leave the other unchanged.

      Another way to change the look of the widgets is to overwrite their callback function or set a skinning/owner-draw function (if available).
      This will give you more control over the look of the widgets.

      Regards
      Sven