Flicker problem with "ownerdrawn" buttons

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

  • Flicker problem with "ownerdrawn" buttons

    Hi everyone,

    I need very urgent a solution for this problem:
    I use many dialogs in my application. To realize ownerdrawn buttons I set their transparency flag with WM_SetHasTrans(hBtn).
    Then I copy a memory device with a drawn JPEG image into the buttons area. This happens in the WM_PAINT of the dialog callback function.
    The WM_PAINT in the buttons callback function is empty.

    C Source Code

    1. void CPage::CallbackButton(WM_MESSAGE * pMsg)
    2. {
    3. switch (pMsg->MsgId)
    4. {
    5. case WM_PAINT:
    6. break;
    7. default:
    8. BUTTON_Callback(pMsg);
    9. break;
    10. }
    11. }
    12. void CPage::CallbackDialog(WM_MESSAGE * pMsg)
    13. {
    14. switch (pMsg->MsgId)
    15. {
    16. case WM_PAINT:
    17. m_CurrentPage->WM_Paint();
    18. break;
    Display All


    And this is the annoying problem: With every click/release the button area flickers with the transparent color, before the image is seen.
    To use bitmap buttons instead is no option because there is not enough space for many button bitmaps in the flash memory.

    Is there any other way to show "image" buttons without flickering?
    Or is it possible to avoid the seen click/release state of buttons ?

    Thanks in advance

    JuergenL
  • Hello JuergenL,

    Using WM_SetHasTrans() causes the window manager to redraw the background of the button in order to have the transparent parts updated before the actual button is drawn. So the behavior you experience is correct in the first step. The disadvantage is of course that the drawing (flickering) might be visible depending on the used hardware. To avoid this using Memory Devices is a good option. In fact the following function call makes the Window Manager use Memory Devices automatically:

    WM_SetCreateFlags(WM_CF_MEMDEV);

    Once the creation flag WM_CF_MEMDEV is set, windows are drawn in a Memory Device first. As soon as all windows are drawn, the content of the Memory Device is displayed.

    Please note that the background window is created from within the function GUI_Init(). It might be necessary therefore to call WM_SetCreateFlags() even before GUI_Init().

    I hope this is a help for you.

    Best regards,
    Adrian