emWin Button redraw

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

  • emWin Button redraw

    Hi,

    I have a question about how to create a button with Bitmap and transparent background.


    GUI_EnableAlpha(1);
    GUI_Clear();

    //Voreinstellungen
    BUTTON_SetDefaultSkinClassic();
    BUTTON_SetDefaultBkColor(GUI_TRANSPARENT,BUTTON_CI_DISABLED);
    BUTTON_SetDefaultBkColor(GUI_TRANSPARENT,BUTTON_CI_PRESSED);
    BUTTON_SetDefaultBkColor(GUI_TRANSPARENT,BUTTON_CI_UNPRESSED);
    WIDGET_SetDefaultEffect(&WIDGET_Effect_None);

    //Callback
    WM_HWIN mainWin = WM_GetDesktopWindow();
    WM_SetCallback(mainWin, cbMain);

    //Hintergund zeichnen
    GUI_DrawStreamedBitmapAuto(&bitmapBackground, 0, 0);
    //Buttons anlegen

    buttonMemoryOne = BUTTON_CreateEx(BUTTON_MEMORY_ONE_POSITION_X, BUTTON_MEMORY_ONE_POSITION_Y, BUTTON_MEMORY_ONE_X_SIZE, BUTTON_MEMORY_ONE_Y_SIZE, mainWin, WM_CF_SHOW | WM_CF_HASTRANS , 0, BUTTON_MEMORY_ONE_ID);
    BUTTON_SetTextColor(buttonMemoryOne,BUTTON_BI_UNPRESSED,GUI_RED);
    BUTTON_SetText(buttonMemoryOne,"40000");
    BUTTON_SetBitmap(buttonMemoryOne,BUTTON_BI_UNPRESSED,&bmButtonblankoinaktiv);

    The button is displayed correctly . However, when I click on the button he is locks like he is overlaid with a new button .
    Because of this the Button do not look like expected. How can I prevent that? And where does this effect come frome?

    Many thanks for your help
  • Hi,

    You wrote: "when I click on the button he is locks like he is overlaid with a new button"

    Could you please give us a more detailed expression of what does not look as expected? The best would be a screenshot and a small sample.

    By the way I've seen that you execute drawing operations outside of WM_PAINT handlers:

    C Source Code

    1. //Hintergund zeichnen
    2. GUI_DrawStreamedBitmapAuto(&bitmapBackground, 0, 0);
    3. //Buttons anlegen


    Please note that this is not recommended. A callback function for the desktop window should help here:

    C Source Code

    1. WM_SetCallback(WM_HBKWIN, _cbYourCallbackForTheDesktopWindow);


    We hope that helps.

    Regards, Jörg
    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.