lpcware

emWin lib - Flicker problem with "ownerdrawn" buttons

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by Grisu on Thu Feb 16 09:38:52 MST 2012
[FONT=&quot]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.[/FONT]
          [FONT=&quot][IMG]file:///C:/Users/staudenr/AppData/Local/Temp/msohtmlclip1/01/clip_image002.gif[/IMG][/FONT]
         [B][FONT=&quot]C/C++ Source code[/FONT][/B]
             [FONT=&quot]1[/FONT]
   [FONT=&quot]2[/FONT]
   [FONT=&quot]3[/FONT]
   [FONT=&quot]4[/FONT]
   [FONT=&quot]5[/FONT]
   [FONT=&quot]6[/FONT]
   [FONT=&quot]7[/FONT]
   [FONT=&quot]8[/FONT]
   [FONT=&quot]9[/FONT]
   [FONT=&quot]10[/FONT]
   [FONT=&quot]11[/FONT]
   [FONT=&quot]12[/FONT]
   [FONT=&quot]13[/FONT]
   [FONT=&quot]14[/FONT]
   [FONT=&quot]15[/FONT]
   [FONT=&quot]16[/FONT]
   [FONT=&quot]17[/FONT]
   [FONT=&quot]18[/FONT]
   [FONT=&quot]19[/FONT]
         [COLOR=darkred][FONT=&quot]void[/FONT][/COLOR][FONT=&quot]  CPage[COLOR=green]::[/COLOR]CallbackButton(WM_MESSAGE   [COLOR=green]*[/COLOR] pMsg)[/FONT]
   [FONT=&quot]{[/FONT]
   [FONT=&quot]  [COLOR=blue]switch[/COLOR] (pMsg[COLOR=green]->[/COLOR]MsgId)[/FONT]
   [FONT=&quot]  {[/FONT]
   [FONT=&quot]  [COLOR=blue]case[/COLOR] WM_PAINT[COLOR=green]:[/COLOR][/FONT]
   [FONT=&quot]    [COLOR=blue]break[/COLOR];[/FONT]
   [FONT=&quot]  [COLOR=blue]default[/COLOR][COLOR=green]:[/COLOR][/FONT]
   [FONT=&quot]      BUTTON_Callback(pMsg);[/FONT]
   [FONT=&quot]    [COLOR=blue]break[/COLOR];[/FONT]
   [FONT=&quot]  }[/FONT]
   [FONT=&quot]}[/FONT]
   [FONT=&quot] [/FONT]
   [COLOR=darkred][FONT=&quot]void[/FONT][/COLOR][FONT=&quot] CPage[COLOR=green]::[/COLOR]CallbackDialog(WM_MESSAGE   [COLOR=green]*[/COLOR] pMsg)[/FONT]
   [FONT=&quot]{[/FONT]
   [FONT=&quot]  [COLOR=blue]switch[/COLOR] (pMsg[COLOR=green]->[/COLOR]MsgId)[/FONT]
   [FONT=&quot]  {[/FONT]
   [FONT=&quot]  [COLOR=blue]case[/COLOR] WM_PAINT[COLOR=green]:[/COLOR][/FONT]
   [FONT=&quot]      m_CurrentPage[COLOR=green]->[/COLOR]WM_Paint();[/FONT]
   [FONT=&quot]    [COLOR=blue]break[/COLOR];[/FONT]
        [FONT=&quot]

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 ?

[/FONT][FONT=&quot]Thanks in advance

Grisu [/FONT]

Outcomes