Button with transparency

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

  • Button with transparency

    Hi,

    Is it possible to create the button wich use a bitmap with transparency ? Something looking like a ICONVIEW, but as a BUTTON ?
    I'm trying to set background color of the button to GUI_TRANSPARENT, but it doesn't work, the background is black, not transparent.

    Best regards
    Skrzydlaty
  • Hi,

    I've used BmpCvt.exe to convert PNG file to C file, and added it to project, but I've also tried to use pictures from the ICONVIEW demo to be sure that the bitmap is correct (has the right transparency). The button is a part of the DialogBox. I've used GUI_CreateDialogBox to create the dialog from the table :


    static const GUI_WIDGET_CREATE_INFO _aDialogCreate_stan_wejsc[] = {
    { WINDOW_CreateIndirect, "Window", ID_WINDOW_0, 0, 0, 480, 272, 0, 0, 0 },
    { BUTTON_CreateIndirect, "", ID_BUTTON_0_ZONES, 10 ,61 ,50, 50, 0, 0, 0 },
    };


    _hWindow_modal = WM_CreateWindow( 0, 0, 480, 272, WM_CF_SHOW | WM_CF_MEMDEV, NULL, 0);
    GUI_CreateDialogBox(_aDialogCreate_stan_wejsc, GUI_COUNTOF(_aDialogCreate_stan_wejsc), &_cbDialog_stan_wejsc, _hWindow_modal, 0, 0);

    In the _cbDialog function I've set the bitmap and the transparent color :


    BUTTON_SetBitmap(hItem, BUTTON_BI_UNPRESSED, &bmst_wej9);
    BUTTON_SetBkColor(hItem,BUTTON_CI_UNPRESSED,GUI_TRANSPARENT);

    But there is no transparency in the button.
    When I use the same bitmap as a picture I see the transparency :

    GUI_DrawBitmap(
    &bmst_wej9 , 100, 100);

    PS I've also traied to use WM_CF_HASTRANS flag to the window, dialogbox, and the button, but it wasn't working.

    I use emWin 5.12

    Best regards
    Skrzydlaty
    Images
    • st_wej9.png

      4.08 kB, 50×50, viewed 3,518 times
    Files
    • st_wej9.txt

      (54.28 kB, downloaded 1,466 times, last: )