Semitransparent listbox overwrites the selected line with the text from the previous line

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

    • Semitransparent listbox overwrites the selected line with the text from the previous line

      I'm trying to make a semitransparent listbox using this code

      static void _cbTool2(WM_MESSAGE* pMsg) {
      char acBuffer[32];
      int Sel;
      int NCode, Id;
      static LISTBOX_Handle hListbox, hText;
      static GUI_MEMDEV_Handle hMem;
      int i;
      // USER START (Optionally insert additional variables)
      // USER END
      switch (pMsg->MsgId) {
      case WM_CREATE:

      hListbox = LISTBOX_CreateEx(60, 60, 210, 137, hTool2, WM_CF_SHOW, 0, ID_LISTBOX_0, _acContent);
      WIDGET_SetFocusable(hListbox, 1);
      LISTBOX_SetFont(hListbox, &GUI_Font8x18);
      LISTBOX_SetTextColor(hListbox, LISTBOX_CI_UNSEL, GUI_BLACK);
      LISTBOX_SetItemSpacing(hListbox, 4);
      LISTBOX_SetSel(hListbox, 1);
      LISTBOX_SetAutoScrollV(hListbox, 1);
      hText = TEXT_CreateEx(120, 40, 80, 20, pMsg->hWin, WM_CF_SHOW, TEXT_CF_HCENTER, ID_TEXT_2, "Main Menu");
      TEXT_SetFont(hText, &GUI_Font8x18);
      TEXT_SetTextColor(hText, GUI_BLACK);

      case WM_PAINT:


      WM_HWIN CreateChild2(void);
      WM_HWIN CreateChild2(void) {

      hTool2 = WM_CreateWindowAsChild(43, 35, 240, 180, hParent, WM_CF_HASTRANS, _cbTool2, 0);

      return hTool2;

      Every thins seems fine until i move down then the widget overwrites the selected line with the text from the previous line and become darker
    • Hi,

      You have to call GUI_SetAlpha() during the drawing process of the LISTBOX. It is also important that you reset the alpha value to fully opaque after the semi-transparent drawings are finished, because otherwise the set alpha value will be used globally.

      Try to set the following callback to your LISTBOX widget:

      C Source Code

      1. static void _cbListbox(WM_MESSAGE * pMsg) {
      2. switch (pMsg->MsgId) {
      3. case WM_PAINT:
      4. GUI_SetAlpha(50);
      5. LISTBOX_Callback(pMsg);
      6. GUI_SetAlpha(0xFF);
      7. break;
      8. default:
      9. LISTBOX_Callback(pMsg);
      10. }
      11. }
      Display All

      It draws the widget using the standard callback but with a modified alpha value.

      Best regards,
      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:

      Or you can contact us via e-mail.