c++winapiwatermarkeditcontrol

Edit Control Watermark


I would like to implement a grey text watermark in an edit control in C++ with Win32 API, but I'm not sure of any ways to do it besides handling WM_KEYDOWN messages.

I would like something like this:

image

Any ideas?


Solution

  • Send the EM_SETCUEBANNER message to your edit control.

    Pass a unicode string to display in lparam.

    e.g.:

    SendMessage(hwnd, EM_SETCUEBANNER, (WPARAM) FALSE, (LPARAM) strW);