Based on Uwe Raabe's answer, here is the procedure (for Delphi 2007, should also work for newer versions of Delphi):
type
TCueBannerHideEnum = (cbhHideOnFocus, cbhHideOnText);
procedure TEdit_SetCueBanner(_ed: TEdit; const _s: WideString; _WhenToHide: TCueBannerHideEnum = cbhHideOnFocus);
const
EM_SETCUEBANNER = $1501;
var
wParam: Integer;
begin
case _WhenToHide of
cbhHideOnText: wParam := 1;
else // cbhHideOnFocus: ;
wParam := 0;
end;
SendMessage(_ed.Handle, EM_SETCUEBANNER, wParam, Integer(PWideChar(_s)));
end;
You call it this way:
constructor TForm1.Create(_Owner: TComponent);
begin
inherited;
TEdit_SetCueBanner(ed_HideOnFocus, 'hide on focus', cbhHideOnFocus);
TEdit_SetCueBanner(ed_HideOnText, 'hide on text', cbhHideOnText);
end;
It does not check the version of Windows, but you may need to add an ifwe statement:
if CheckWin32Version(5, 1) and StyleServices.Enabled and _ed.HandleAllocated then
I just tested it with a project where I turned off the runtime: it didn't work.