Thursday, April 26th 2018, 10:51pm UTC+2

You are not logged in.

  • Login
  • Register

Date of registration: Nov 30th 2017

Posts: 13

1

Friday, March 16th 2018, 5:35am

Image size issue on button

Hi,
I have a button of size 100*39. on that button i want to set image for pressed and unpressed which is also of 100*39. I am setting it in init dialog as


BUTTON_SetBkColor(hEnter,BUTTON_CI_UNPRESSED,GUI_BLACK);
BUTTON_SetBkColor(hEnter,BUTTON_CI_PRESSED,GUI_BLACK);
BUTTON_SetBitmap(hEnter,BUTTON_CI_UNPRESSED,&bm_entericon_3Blue);
BUTTON_SetBitmap(hEnter,BUTTON_CI_PRESSED,&bm_entericon_3Pressedimageblue);

by this image is fitting into the button size .But the same thing when i am trying with call back the image is enlarged, I am not able to understand why it is like that.
callback is implemented as:


switch (pMsg->MsgId) {
case WM_INIT_DIALOG:
hEnter = WM_GetDialogItem(pMsg->hWin, ID_PW_BUTTON_12);

WM_SetCallback(hEnter, ChangeEnterButton);

break:
}

this is my callback function


void ChangeEnterButton(WM_MESSAGE * pMsg)
{

switch (pMsg->MsgId) {
case WM_PAINT:

if(BUTTON_IsPressed(pMsg->hWin))
{
GUI_SetBkColor(GUI_BLACK);
GUI_Clear();
GUI_DrawBitmap(&bm_entericon_3Pressedimageblue,0,0);
}

else
{
GUI_SetBkColor(GUI_BLACK);
GUI_Clear();
GUI_DrawBitmap(&bm_entericon_3Blue,0,0);
}

break;
default:
BUTTON_Callback(pMsg);
break;
}
}

Please do needful help. :)

SEGGER - Schoenen

Super Moderator

Date of registration: Aug 13th 2015

Posts: 562

2

Tuesday, March 20th 2018, 2:58pm

Hi,

I have no idea why the images are enlarged.

Can you attached the images?

From my point of view the callback function looks good. Although, the function calls of BUTTON_SetBkColor() and BUTTON_SetBitmap() are not required, since you draw the button on your own in the callback function.

Regards,
Sven

Date of registration: Nov 30th 2017

Posts: 13

3

Thursday, March 29th 2018, 6:23am

Here i am attaching the image. Please have a look.
Kusum Swarankar has attached the following image:
  • Arrow.PNG

SEGGER - Schoenen

Super Moderator

Date of registration: Aug 13th 2015

Posts: 562

4

Thursday, March 29th 2018, 3:22pm

Hi,

I can't find anything wrong with the image.

I have made a small example where I create a button and draw the image in the callback function. Please give it a try and let it run on your side.

Regards
Sven
SEGGER - Schoenen has attached the following file:
  • ImageOnButton.zip (1.91 kB - 25 times downloaded - Last download: Apr 24th 2018, 1:48pm)