0

So I was trying to make an image button using the WIN32 API. The problem is, that the image gets cropped, because the button is smaller than the image. In a statics control, I would user the SS_REALSIZECONTROL tag, but in a button that doesn't seem to work.

Here is how I created the button:

hButton = CreateWindowA("Button", NULL, WS_VISIBLE | WS_CHILD | BS_BITMAP, 10, 10, 70, 70, hWindow, BUTTON_ID, NULL, NULL);

And here is how I set its image:

SendMessageA(hButton, BM_SETIMAGE, IMAGE_BITMAP, hBitmap);
Daniel A. White
  • 187,200
  • 47
  • 362
  • 445
aviad1
  • 354
  • 1
  • 10
  • 1
    You can either make your button bigger or make the image smaller. Neither will happen automatically. – Jonathan Potter Jul 16 '20 at 02:57
  • 1
    Or use a custom draw button. Draw the image scaled to fit the destination rectangle. Refer to "[About cropping and scaling GDI+ images](https://learn.microsoft.com/en-us/windows/win32/gdiplus/-gdiplus-cropping-and-scaling-images-about)" and "[Scaling an Image](https://learn.microsoft.com/en-us/windows/win32/gdi/scaling-an-image)". – Rita Han Jul 16 '20 at 03:28
  • That's too bad, but I thought that this will be the answer. Thanks! – aviad1 Jul 16 '20 at 17:23

0 Answers0