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

前端 未结 1 780
小蘑菇
小蘑菇 2021-01-22 21:28

When creating a text box

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

How to set default, grey text on the background of that box, which disappear

相关标签:
1条回答
  • 2021-01-22 21:39

    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.

    0 讨论(0)
提交回复
热议问题