WM_SetCallback problem?

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

  • WM_SetCallback problem?

    Hello there

    I am creating an event with the WM_Set_Callback function to write something to the screen.

    The function is running but there is a problem. I called this function, the event occurs 3 times in the target function.

    I use it as follows.

    Source Code

    1. WM_SetCallback(WM_HBKWIN, DrawFingerVals);

    this is target function

    Source Code

    1. /*********************************************************************
    2. *
    3. * DrawFingerVals
    4. */
    5. static void DrawFingerVals(WM_MESSAGE * pMsg);
    6. static void DrawFingerVals(WM_MESSAGE * pMsg) {
    7. WM_HWIN hItem;
    8. switch (pMsg->MsgId) {
    9. case WM_PAINT:
    10. hItem = WM_GetDialogItem(pMsg->hWin, ID_MULTIEDIT_0);
    11. MULTIEDIT_AddText(hItem,write_buffer);
    12. break;
    13. default:
    14. WM_DefaultProc(pMsg);
    15. break;
    16. }
    17. }
    Display All

    Every time I call the function, the same verb is written to the screen 3 times.

    How can I solve this?

    Thank You
  • Hi,

    AS the name of WM_PAINT suggests, this message is send if a window/widget/dialog should be drawn. Please do not call any other functions than those related to drawing. Setting properties (like MULTIEDIT_AddText()) or (in the worst case) creating windows or widgets within WM_PAINT can lead to unexpected behavior.

    For example, if you are within WM_PAINT and set a text for a transparent widget, it gets invalidated. A transparent widget causes the background to be redrawn. If the text was set within WM_PAINT of the background window you will create an endless loop.

    The reason why it gets called three times is the tiling algorithm of emWin. If a background of an opaque window gets drawn the area of the foreground window gets omitted. WM_PAINT of the background window gets called several times to draw the rectangles around the foreground window on by one.

    Please refer to chapter 18.2.5 'Tiling mechanism' of the emWin user manual (UM03001_emWin5.pdf) for more information about the tiling mechanism.