2005. március 18., péntek

How to retrieve the text of a single-line edit control


Problem/Question/Abstract:

How to retrieve the text of a single-line edit control

Answer:

Solve 1:

{ ... }
var
  FNEText: array[0..127] of Char;
begin
  SendMessage(Edit1.Handle, WM_GETTEXT, Sizeof(FNEText), Integer(@FNEText));
  { ... }

Solve 2:

{ ... }
var
  buffer: array[0..$10000] of Char;
  len: Integer;
begin
  buffer[0] := #0;
  len := SendMessage(hFocusWin, WM_GETTEXTLENGTH, 0, 0);
  if len > 0 then
    SendMessage(hFocusWin, WM_GETTEXT, len + 1, LPARAM(@buffer));
  memo1.SetTextBuf(buffer);
  { ... }

Nincsenek megjegyzések:

Megjegyzés küldése