简体   繁体   中英

WIN32: Is there a way to have the button icon (BM_SETIMAGE) on the right side of the text

Is there a way to have a button with text and graphic, with the graphic on the right side of the text, without having to owner-draw the button?

I want to just sent BM_SETIMAGE and whatever else would be needed so the graphic is to the right of the text.

Also, I noticed the image is so tight against the text that it doesn't look good. Is there a way to adjust the margin without having to use a blank space in the text?

Is there a way to have a button with text and graphic, with the graphic on the right side of the text, without having to owner-draw the button?

There are BS_LEFTTEXT and BS_RIGHTBUTTON styles available, but the documentation says they only apply to CheckBoxes and RadioButtons:

Constant Description
BS_LEFTTEXT Places text on the left side of the radio button or check box when combined with a radio button or check box style. Same as the BS_RIGHTBUTTON style.
BS_RIGHTBUTTON Positions a radio button's circle or a check box's square on the right side of the button rectangle. Same as the BS_LEFTTEXT style.

For a standard push button, there does not appear to be a way to control the position of the image other than through owner-drawing.

Is there a way to adjust the margin without having to use a blank space in the text?

Use BCM_SETTEXTMARGIN / Button_SetTextMargin() :

Sets the margins for drawing text in a button control.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM