Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiline button in winapi

Tags:

c++

button

winapi

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 );
like image 314
Mikołaj Avatar asked Jan 29 '26 02:01

Mikołaj


1 Answers

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.

like image 134
axiac Avatar answered Jan 31 '26 18:01

axiac



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!