频道分类

Delphi中SendMessage给一个Edit控件发送WM_SETTEXT消息

作者:admin 来源: 日期:2019/10/31 17:55:47 人气: 标签:

 
procedure SetWndText(hWnd:HWND; Text: string);
var
  Ret: LongInt;
  mText: PChar;
  Buf: Integer;
begin
  GetMem(mText, Length(Text));
  StrCopy(mText, PChar(Text));
  try
    Buf := LongInt(mText);
    SendMessage(hWnd,WM_SETTEXT, 0, Buf);
  finally
    FreeMem(mText, Length(Text));
  end;
end;