Friday, April 20th 2018, 2:58am UTC+2

You are not logged in.

  • Login
  • Register

Dear visitor, welcome to SEGGER Forum. If this is your first visit here, please read the Help. It explains how this page works. You must be registered before you can use all the page's features. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

jenlan

Beginner

Date of registration: Nov 11th 2015

Posts: 10

1

Wednesday, November 11th 2015, 9:38am

emWin Button redraw

Hi,

I have a question about how to create a button with Bitmap and transparent background.


GUI_EnableAlpha(1);
GUI_Clear();

//Voreinstellungen
BUTTON_SetDefaultSkinClassic();
BUTTON_SetDefaultBkColor(GUI_TRANSPARENT,BUTTON_CI_DISABLED);
BUTTON_SetDefaultBkColor(GUI_TRANSPARENT,BUTTON_CI_PRESSED);
BUTTON_SetDefaultBkColor(GUI_TRANSPARENT,BUTTON_CI_UNPRESSED);
WIDGET_SetDefaultEffect(&WIDGET_Effect_None);

//Callback
WM_HWIN mainWin = WM_GetDesktopWindow();
WM_SetCallback(mainWin, cbMain);

//Hintergund zeichnen
GUI_DrawStreamedBitmapAuto(&bitmapBackground, 0, 0);
//Buttons anlegen

buttonMemoryOne = BUTTON_CreateEx(BUTTON_MEMORY_ONE_POSITION_X, BUTTON_MEMORY_ONE_POSITION_Y, BUTTON_MEMORY_ONE_X_SIZE, BUTTON_MEMORY_ONE_Y_SIZE, mainWin, WM_CF_SHOW | WM_CF_HASTRANS , 0, BUTTON_MEMORY_ONE_ID);
BUTTON_SetTextColor(buttonMemoryOne,BUTTON_BI_UNPRESSED,GUI_RED);
BUTTON_SetText(buttonMemoryOne,"40000");
BUTTON_SetBitmap(buttonMemoryOne,BUTTON_BI_UNPRESSED,&bmButtonblankoinaktiv);

The button is displayed correctly . However, when I click on the button he is locks like he is overlaid with a new button .
Because of this the Button do not look like expected. How can I prevent that? And where does this effect come frome?

Many thanks for your help

SEGGER - Jörg

Super Moderator

Date of registration: Dec 20th 2007

Posts: 81

2

Wednesday, November 18th 2015, 9:47am

Hi,

You wrote: "when I click on the button he is locks like he is overlaid with a new button"

Could you please give us a more detailed expression of what does not look as expected? The best would be a screenshot and a small sample.

By the way I've seen that you execute drawing operations outside of WM_PAINT handlers:

C/C++ Source code

1
2
3
4
5
//Hintergund zeichnen

GUI_DrawStreamedBitmapAuto(&bitmapBackground, 0, 0);

//Buttons anlegen


Please note that this is not recommended. A callback function for the desktop window should help here:

C/C++ Source code

1
WM_SetCallback(WM_HBKWIN, _cbYourCallbackForTheDesktopWindow);


We hope that helps.

Regards, Jörg

jenlan

Beginner

Date of registration: Nov 11th 2015

Posts: 10

3

Wednesday, November 18th 2015, 10:31am

Hi,

Thanks for the answer. I have solved the problem a few days ago. A callback function(as proposed) did the Job.

Greetings :thumbsup:

Similar threads