Image size issue on button

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • 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. :)
    • 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
      Please read the forum rules before posting.

      Keep in mind, this is *not* a support forum.
      Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
      Should you be entitled to support you can contact us via our support system: segger.com/ticket/

      Or you can contact us via e-mail.
    • 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
      Files
      Please read the forum rules before posting.

      Keep in mind, this is *not* a support forum.
      Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
      Should you be entitled to support you can contact us via our support system: segger.com/ticket/

      Or you can contact us via e-mail.