创建文本框时
hwnd = CreateWindowEx(0, "EDIT", [...])
如何在该框的背景上设置默认的灰色文本,该文本在提供某些输入时会消失? An example.我正在使用代码块.
编辑:
#include <commctrl.h>
[...]
HWND hwndEdit = CreateWindowEx(0, "EDIT", NULL, WS_CHILD | WS_VISIBLE | WS_BORDER, 10, 110, 300, 20, hwnd, NULL, hThisInstance, NULL);
SendMessage(hwndEdit, EM_SETCUEBANNER, FALSE, (LPARAM) L"Default text");
解决方法:
创建编辑控件后,向其发送EM_SETCUEBANNER消息:
SendMessage(hwndEdit, EM_SETCUEBANNER, 0, (LPARAM)L"Default text");
Edit_SetCueBannerText(hwndEdit, L"Default text");
无论哪种方式,您都还需要enable Visual Styles.