在“编辑”控件中,如何显示输入新文本时消失的半透明文本?

时间:2018-11-10 08:50:07

标签: delphi-7 edit

我做了下面的代码,但是有些不起作用。

unit Unit9;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, DB, ADODB, Grids, DBGrids, ExtCtrls;

type
  TForm9 = class(TForm)
    edt1: TEdit; 
    procedure FormCreate(Sender: TObject);        
  end;

var
  Form9: TForm9;

const
  EM_SETCUEBANNER = $1501;

implementation

uses
  Unit2;

{$R *.dfm}

procedure TForm9.FormCreate(Sender: TObject);
var
  Banner: String;
  buf: array [0..$ff] of Char;
begin
  Banner := UTF8Encode('Введите логин');
  Utf8ToUnicode(PWideChar(@buf), PAnsiChar(Banner), Length(Banner));
  SendMessage(edt1.Handle, EM_SETCUEBANNER, 0, Integer(@buf));
end;

end.

例如,在某些网站上,编辑控件将显示“登录”,直到写入内容为止。

image

0 个答案:

没有答案