Forum > LCL

[SOLVED]Cannot center image in tSpeedButton

(1/3) > >>

CM630:

I have a speed button (W=24; H=24 px), placed in a toolbar.

My code is

  if stQuickTransOn
    then imagelist1.GetBitmap(0,SpeedButton1.Glyph)
    else imagelist1.GetBitmap(1,SpeedButton1.Glyph);

Images are stored in imglImagesOnOff, all images in it are 24x24 pixels. imglImagesOnOff is itself 24 pixels wide.

When I have not touched default values of the speed button image is drawn OUTSIDE(above) the button.
I tried various settings, but could not center the image on both axises.
I have also tried Center of the images in imagelist1, but they got garbled, scrambled... etc.

Should I use some other control instead of TSpeedButton?

(a sample is attached)

ASerge:
The image is centered, but the arrow in the image is not centered. Correct the image.

RayoGlauco:
I usually use  tBitBtn and I like it. I have no problem, and the images are placed in the center.
Anyway, I think your button must be greater than 24x24 if you want it to contain 24x24 images, because there has to be some margin.

CM630:

--- Quote from: ASerge on April 25, 2018, 01:56:49 pm ---The image is centered, but the arrow in the image is not centered. Correct the image.

--- End quote ---
It is offset one pixel to the left and is vertically centered. And even if it was not so, I except it should not be drawn oustside (above) the button, as it happens.



--- Quote from: RayoGlauco on April 25, 2018, 02:00:37 pm ---Anyway, I think your button must be greater than 24x24 if you want it to contain 24x24 images, because there has to be some margin.
--- End quote ---

I increased it to 28x28, and still image is alligned top-left.

RayoGlauco:
Maybe this is a kind of bug?  Using your code, image is placed top-left. If I manually put an image on the button, the result is different, as the attached image shows.

If you place on your button some image (same size: 24x24) in design time, I think then the images placed by code may be ok.

Navigation

[0] Message Index

[#] Next page

Go to full version