Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set up default background (greyed out) text for textbox in C++ Win32 GUI?

When creating a text box

hwnd = CreateWindowEx(0, "EDIT", [...])

How to set the placeholder (default, grey) text on the background of that box, which disappears when providing some input?

like image 518
keverman Avatar asked Jan 19 '26 16:01

keverman


1 Answers

After creating the edit control, send the EM_SETCUEBANNER message to it:

SendMessage(hwndEdit, EM_SETCUEBANNER, 0, (LPARAM)L"Default text");

Or use the Edit_SetCueBannerText macro:

Edit_SetCueBannerText(hwndEdit, L"Default text");

Either way, you also need to enable Visual Styles.


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!