Friday, April 20th 2018, 12:29pm 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.

Date of registration: Nov 30th 2017

Posts: 12

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: 561

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: 12

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: 561

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 - 23 times downloaded - Last download: Yesterday, 8:50pm)