Short answer: generally, no—not with the standard Windows toolbar control (TOOLBARCLASSNAME / common controls).
The standard toolbar button text is rendered by the common controls library and does not interpret \n or CR/LF as a line break. If you pass:
"Open" + CRLF + "File"or
TEXT("Open\r\nFile")the control will either:
display only one line,
replace the line break with a space,
or ignore it completely (depending on the comctl32 version).
The toolbar control supports:
TBSTYLE_LIST (image beside text)
BTNS_SHOWTEXT
multiline tooltips (TTM controls)
wrapping of toolbar rows (TBSTYLE_WRAPABLE)
However, it does not support multiline button captions.
Possible workarounds1. Owner-drawn / Custom Draw (recommended if you really need it)You can make the toolbar owner-drawn:
TBSTYLE_CUSTOMERASE NM_CUSTOMDRAWor create owner-drawn buttons and paint the caption yourself using
DrawText( hdc, TEXT("Open\nFile"), -1, &rc, DT_CENTER | DT_WORDBREAK | DT_VCENTER );This gives complete control but essentially means replacing the toolbar's text rendering.
Some developers use characters such as
Open Fileor
Open/Fileor
Open↵FileThese are visual tricks only—not actual multiline captions.
Windows Explorer, Office, and Visual Studio avoid multiline toolbar text by using:
larger buttons
icons
short captions
This is the most compatible approach.
If true multiline captions are required, a toolbar is probably not the ideal control.
A custom panel containing:
image
static text
click handling
can mimic a toolbar while allowing arbitrary text layout.
Can it be hacked via WinAPI messages?Unfortunately, no.
Messages like
TB_SETBUTTONINFO TB_ADDBUTTONS TB_SETBUTTONSIZE TB_AUTOSIZEonly affect:
text
image
size
state
There is no style or message equivalent to:
BS_MULTILINEthat exists for push buttons.
For HMG ExtendedSince HMG's TOOLBAR is a wrapper around the standard Windows toolbar control, there is currently no WinAPI flag that can enable multiline captions.
If you wanted to add this capability to HMG itself, the practical options would be:
Implement NM_CUSTOMDRAW support and draw button captions with DrawText(..., DT_WORDBREAK).
Create a new custom toolbar control (similar to the existing ButtonEx implementation) that behaves like a toolbar but supports multiline text.
Use regular BUTTONEX controls arranged to resemble a toolbar. BUTTONEX already offers much greater flexibility than the standard toolbar and is likely the easiest route if multiline captions are important.
So, from a WinAPI perspective, the answer is no: the standard toolbar control does not support line breaks in button captions, and there is no documented message or style to enable that behavior. Any solution requires custom drawing or replacing the control.
--
Visit our website on https://www.hmgextended.com/ or https://www.hmgextended.org/
---
You received this message because you are subscribed to the Google Groups "Harbour Minigui" group.
To unsubscribe from this group and stop receiving emails from it, send an email to minigui-foru...@googlegroups.com.
To view this discussion, visit https://groups.google.com/d/msgid/minigui-forum/a5016411-0cc7-418e-908b-d66b6874e6ccn%40googlegroups.com.