Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   Varios (https://www.clubdelphi.com/foros/forumdisplay.php?f=11)
-   -   Recibir texto de un control externo? (https://www.clubdelphi.com/foros/showthread.php?t=89690)

Reasen 18-01-2016 15:25:35

Recibir texto de un control externo?
 
Por ejemplo si tengo 2 aplicaciones diferentes de delphi iniciadas como consigo el texto de un TEdit del otro proceso? Intente algo como esto pero sin suerte:

Código Delphi [-]
var
  winn:HWND;
  winn2:HWND;
    HoldString: PChar;
  HoldString__: String;
begin
winn:= FindWindow('','Aplicacion');
 winn2:=FindWindowEx(winn,0,'Edit',''); // recibimos el handle del control
 SendMessage(winn2,WM_GETTEXT,200,lparam(HoldString));
 HoldString__ := HoldString__ + ' ' + String(HoldString);
ShowMessage( HoldString__);
end;

Cualquier ayuda o consejo me sirven, saludos!

Reasen 18-01-2016 16:28:25

Me auto-respondo, Lo solucioné de esta manera:
Código Delphi [-]
  function GetText(XHand : THandle):string;
var textlength:integer;
  text:PChar;
begin
  textlength:=SendMessage(XHand,WM_GETTEXTLENGTH,0,0);
  if textlength=0 then Result:='Empty' else
  begin
    getmem(text,textlength+1);
    SendMessage(XHand,WM_GETTEXT,textlength+1,Integer(text));
    Result:=text;
    freemem(text);
  end;
end;

Osorio 18-01-2016 16:43:35

Tambien puedes ver algo de callback. Tal vez te puede ser util en mayor o menor medida para tu necesidad puntual.

Saludos.


La franja horaria es GMT +2. Ahora son las 05:35:47.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi