Wednesday, April 25th 2018, 12:33am UTC+2

You are not logged in.

  • Login
  • Register

aaa1

Beginner

Date of registration: Mar 8th 2018

Posts: 13

1

Friday, March 9th 2018, 5:24pm

SkinFlex Buttons

I have 4 buttons in a window. I used the following code to set a new color to one button.

C/C++ Source code

1
BUTTON_SetSkinFlexProps(&Props, BUTTON_SKINFLEX_PI_ENABLED);

C/C++ Source code

1
hB0 = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_0);

C/C++ Source code

1
WM_Invalidate(hB0);


My problem is that if I touch another button, also the other button is colored with the new colors.
Why is that? Is there a way to keep the other buttons the same even if they are pressed?
Thanks

Lullaby

Beginner

Date of registration: Aug 3rd 2016

Posts: 23

2

Monday, March 12th 2018, 5:11am

SkinFlex Buttons

Hi,
As far as I understood, setting skinflex properties for a button is a global property. Even though, we pass the specific button handle to WM_Invalidate(hB0);,
it will change the global skinning properties of the buttons.

If you are in same window having different buttons, you can use the BUTTON_SetSkin() function passing the handle of the item and pointer to custom draw function.


BUTTON_SetSkin(hB0, _ButtonCustomSkin);



int _ButtonCustomSkin(const WIDGET_ITEM_DRAW_INFO * pDrawItemInfo)

{

switch (pDrawItemInfo->Cmd)
{
case WIDGET_ITEM_DRAW_BACKGROUND:
switch (WM_GetId(pDrawItemInfo->hWin))
{
case ID_BUTTON_B0:
/* Set button color here using GUI_SetColor() */
break;
default:
BUTTON_DrawSkinFlex(pDrawItemInfo);
break;
}
}

}


Hope this helps.


Thank you,
Lullaby.

aaa1

Beginner

Date of registration: Mar 8th 2018

Posts: 13

3

Monday, March 12th 2018, 11:55am

Thank you for your reply. I tried to implement the code but what happens is that the button disappears..
I can't understand the reason why.
Does it happen to you too?
Thanks

Lullaby

Beginner

Date of registration: Aug 3rd 2016

Posts: 23

4

Tuesday, March 13th 2018, 7:51am

Button skin flex issue

In the code snippet, the default: case should be for the outer switch. That was a mistake. Please check now.

aaa1

Beginner

Date of registration: Mar 8th 2018

Posts: 13

5

Tuesday, March 13th 2018, 9:35am

What do you mean with "outer switch"? I tried to leave the disable case empty but I still see the button disappear.
Is it right to leave the default empty?

Lullaby

Beginner

Date of registration: Aug 3rd 2016

Posts: 23

6

Thursday, March 15th 2018, 6:23am

Button skinflex

int _ButtonCustomSkin(const WIDGET_ITEM_DRAW_INFO * pDrawItemInfo)

{
int Id;

switch (pDrawItemInfo->Cmd)
{
case WIDGET_ITEM_DRAW_BACKGROUND:
Id = WM_GetId(pDrawItemInfo->hWin);
switch (Id)
{
case ID_BUTTON_B0:
/* Set button color here using GUI_SetColor() */ break;
}
default:
BUTTON_DrawSkinFlex(pDrawItemInfo);
break;
}
return 0;
}

Try this code snippet..