Changing dialog focus causes "white flashing"

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

  • Changing dialog focus causes "white flashing"

    Hi,

    I have a strange effect:
    I have a dialog box with a blue background and few checkboxes and similar.
    When the focus changes from one widget (checkbox e.g.) to another widget, then the area around the widgets is incomprehensively first cleared/filled with white color before(!) receiving the WM_PAINT message in which I clear to my dedicated color (blue). This effect is recognized as a kind of short "flashing".
    I reproduced it with emWinView in the Simulator to evaluate this. And I tried many but could not find a solution to prevent this disturbing effect.

    Further details:

    Clearing to white happens AFTER the dialog callback has processed the WM_PRE_PAINT message but immediately BEFORE it recieves the WM_PAINT message.
    Then the WM_PAINT message is processed by me e.g. to draw the background in the dedicated color (different from white).

    This effect is not seen when using memory devices (which I cannot use because of low availibe RAM).
    Disadvantage:
    a. On slow systems a very poor 'flashing' (white) is seen.
    b. It costs performance because the area is drawn twice (once unnecessarily in white, and then within WM_PAINT in the dedicated color).
    I assume, that when using memory devices it cost performance (time) too whitout seen the "flashing".

    I use a fast LCD interface with parallel 16 bit, so output performance is not a critical issue. But because I dont use a white background the "flashing-white" is inconvinient.

    Who is drawing the white area??? What have I to do, to eliminate this "clearing to white"?

    Here is a short sample source for reproducing it (should run in the simulator):

    C Source Code

    1. /*********************************************************************
    2. HOW TO REPRODUCE:
    3. 1. Start Simulation and emWinView
    4. 2. Start this sample
    5. 3. Then set breakpoints after executing WM_PRE_PAINT and before
    6. executing WM_PAINT (see marking ####).
    7. 4. Change the focus to any other unfocussed widget.
    8. => breakpoint after WM_PRE_PAINT is reached.
    9. 5. In the Simulator Press Run [F5]
    10. => breakpoint when receiving WM_PAINT is reached.
    11. => In the emView you can see the white-cleared areas! <=== !!!!!
    12. 6. Press [F10] twice to see this area been filled by the own
    13. WM_PAINT statements with the dedicated color.
    14. 7. Press [F5] to contiue
    15. Step 4. to 7. could be repeated.
    16. *********************************************************************/
    17. /*********************************************************************
    18. * SEGGER ...
    19. */
    20. #include <stddef.h>
    21. #include "GUI.h"
    22. #include "DIALOG.h"
    23. /*********************************************************************
    24. * Dialog resource
    25. */
    26. static const GUI_WIDGET_CREATE_INFO _aDialogCreate[] = {
    27. { FRAMEWIN_CreateIndirect, "Framewin", 0, 30, 5, 260, 230, 0, 0 },
    28. { BUTTON_CreateIndirect, "OK", GUI_ID_OK, 10, 30, 100, 20 },
    29. { BUTTON_CreateIndirect, "Cancel", GUI_ID_CANCEL, 10, 60, 100, 20 },
    30. { CHECKBOX_CreateIndirect, "Check1", GUI_ID_CHECK0, 10, 90, 100, 20 },
    31. { CHECKBOX_CreateIndirect, "Check2", GUI_ID_CHECK1, 10, 120, 100, 20 },
    32. };
    33. /*********************************************************************
    34. * Background Callback only to have a different background color
    35. */
    36. static void _cbBkWindow(WM_MESSAGE* pMsg) {
    37. switch (pMsg->MsgId) {
    38. case WM_PAINT:
    39. GUI_SetBkColor(GUI_RED);
    40. GUI_Clear();
    41. break;
    42. default:
    43. WM_DefaultProc(pMsg);
    44. }
    45. }
    46. /*********************************************************************
    47. * Dialog Callback
    48. */
    49. static void _cbCallback(WM_MESSAGE * pMsg) {
    50. WM_HWIN hWin, hClient;
    51. hWin = pMsg->hWin;
    52. switch (pMsg->MsgId) {
    53. case WM_PRE_PAINT:
    54. WM_DefaultProc(pMsg);
    55. // #### Put a breakpoint at the next line:
    56. __nop();
    57. break;
    58. case WM_PAINT:
    59. // #### Put a breakpoint at the next line:
    60. // Area has unnecessarily been cleared to white before receiving this WM_PAINT message!
    61. // And now the area is again cleared to the dedicated color.
    62. GUI_SetBkColor(GUI_LIGHTBLUE); // dedicated dialog background color.
    63. GUI_Clear();
    64. break;
    65. case WM_INIT_DIALOG:
    66. CHECKBOX_SetText(WM_GetDialogItem(hWin, GUI_ID_CHECK0), "Checkbox 1");
    67. CHECKBOX_SetText(WM_GetDialogItem(hWin, GUI_ID_CHECK1), "Checkbox 2");
    68. break;
    69. default:
    70. WM_DefaultProc(pMsg);
    71. }
    72. }
    73. /*********************************************************************
    74. *
    75. * MainTask
    76. */
    77. void MainTask(void) {
    78. // WM_SetCreateFlags(WM_CF_MEMDEV); // DONT use memory devices to demonstrate the effect
    79. GUI_Init();
    80. WM_SetCallback(WM_HBKWIN, &_cbBkWindow);
    81. GUI_ExecDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), &_cbCallback, WM_HBKWIN, 0, 0);
    82. }
    83. /*************************** End of file ****************************/
    Display All

    Can anyone help me?
    Matz