Centering an icon in a BITMAPBUTTON

  • Hello,
    I'm creating bitmap buttons with the following code. To control the size of the icon, I'm using BITMAPBUTTON_FORCE_SIZE. If the Bitmap Button and the icon are different sizes, this puts the icon at the top left of the button. Is it possible to center the icon in the button? I didn't see any properties in the BITMAPBUTTON documentation that indicates that this is possible. If it is not, how could I go about getting the desired result (screenshot below) with a resized icon in GeDialog?

    bc = c4d.BaseContainer()
    bc.SetBool(c4d.BITMAPBUTTON_BUTTON, True)
    bc.SetInt32(c4d.BITMAPBUTTON_FORCE_SIZE, 12)
    bc.SetInt32(c4d.BITMAPBUTTON_ICONID1, 1026694)
    bc.SetString(c4d.BITMAPBUTTON_TOOLTIP, "<b>Title</b><br>Tooltip")
    bmpBtn = self.AddCustomGui(BUTTON_ID, c4d.CUSTOMGUI_BITMAPBUTTON, "Bitmap Button", c4d.BFH_LEFT | c4d.BFV_CENTER | c4d.BFV_SCALE, c4d.gui.SizePix(30), c4d.gui.SizePix(30), bc)




  • hi,
    Here's the code for the bitmap button. As you can see, either -1 or >0 will make the bitmap to be drawn from 0,0. (top corner of the UserArea)

    		if (special_size == -1)
    			DrawBitmap(img, 0, 0, GetWidth(), GetHeight(), 0, 0, w, h, drawflags);
    		else if (special_size)
    			DrawBitmap(img, 0, 0, special_size, special_size_y, 0, 0, w, h, drawflags);

    The final else is for when you don't specify any size.

    So it's not possible in a BITMAPBUTTON.

    But maybe you can retrieve the icon you want, resize it, and register it as a new icon.


  • @m_magalhaes Thank you for clarifying the Bitmap Button, Manuel.

Log in to reply