Reputation: 93
How can I create a multiline button in winAPI (\n or even \r\n doesn't work). Here is the code:
HWND hPrzyciskoff = CreateWindowEx( 0, "BUTTON", "Play offline", WS_CHILD | WS_VISIBLE | WS_TABSTOP, 410, 550, 380, 25, hwnd, NULL, hInstance, NULL );
Upvotes: 2
Views: 1610
Reputation: 139
Alternative to a big multiline push button could be a command link button BS_COMMANDLINK. It has a main text and extra notes (setup via BCM_SETNOTE message or Button_SetNote macro), shown in different size fonts. The fonts are predefined and cannot be changed as far as I know. There is also a default green arrow, which can be replaced with another image (via BM_SETIMAGE), but cannot be removed entirely. However, the button background can be changed via WM_CTLCOLORBTN message (this does not work for any other pushbutton), which can be quite handy sometimes, e.g. to blend with the window background like in toolbar.
Upvotes: 0
Reputation: 72226
Add BS_MULTILINE
to the styles you specify in the 4th argument of CreateWindowEx()
.
As the documentation of Button Styles explains:
BS_MULTILINE
Wraps the button text to multiple lines if the text string is too long to fit on a single line in the button rectangle.
The \n
characters inside the button text will then have the desired effect.
Check the screenshot on the Button Types page to see how it looks like.
Upvotes: 13