Jump to content


Photo

Capturar el texto seleccionado en una ventana


  • Please log in to reply
1 reply to this topic

#1 escafandra

escafandra

    Advanced Member

  • Administrador
  • 4107 posts
  • LocationMadrid - España

Posted 18 February 2015 - 11:14 AM

Me pareció interesante capturar como truco el código con el que respondí esta cuestión, aqui lo dejo:
 


delphi
  1. function GetSelText(hWnd: THANDLE): String;
  2. var
  3.   Buffer: PCHAR;
  4.   Size, Ini, Fin: DWORD;
  5. begin
  6.   Size:= SendMessage(hWnd,  WM_GETTEXTLENGTH, 0, 0)+1;
  7.   GetMem(Buffer, Size);
  8.   SendMessage(hWnd, WM_GETTEXT, WPARAM(Size), LPARAM(Buffer));
  9.   SendMessage(hWnd, EM_GETSEL, WPARAM(@Ini), LPARAM(@Fin));
  10.   Buffer[Fin]:= #0;
  11.   Result:= (Buffer + Ini);
  12.   FreeMem(Buffer);
  13. end;


Saludos.


  • 0

#2 poliburro

poliburro

    Advanced Member

  • Administrador
  • 4945 posts
  • LocationMéxico

Posted 18 February 2015 - 12:29 PM

Gracias por el aporte amigo...  (y)
  • 0




IP.Board spam blocked by CleanTalk.