Draw custom button borders during WM_PAINT

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

  • Draw custom button borders during WM_PAINT

    Hello,

    we're using emWiin 3.96.

    We want to draw buttons with custom rounded borders. I'm using the following code en the button's callback:

    static void btnTestCallback(WM_MESSAGE * pMsg)
    {
    // I must call the previous callback, otherwise the button doesn't render ok
    if (previousButtonCallback != 0)
    previousButtonCallback(pMsg);

    if (pMsg->MsgId == WM_PAINT )
    {
    // Paint custom borders: BUG: Borders paint randomly, sometimes ok, sometimes wrong...
    paintButtonBorder(pMsg->hWinSrc);
    }
    // else
    // WM_DefaultProc(pMsg);
    }

    but the borders appear randomly, sometimes ok and sometimes wrong. I attach a test file code to try it.

    I saw in another thread a new Message ID WM_POST_PAINT but it's not available in our emWin version 3.96.

    any idea?

    Thanks in advance,

    Raúl Truco,
    Files
  • Dear Raúl,

    I have tested your code and I have to tell you that this behavior is not a bug in emWin. Unfortunately there is no advice I could give you at this point. Maybe it would be a good idea to update emWin to the new version, so you would be able to use the WM_PRE_PAINT and the WM_POST_PAINT message.

    Best regards,
    Adrian