Ver Mensaje Individual
  #6  
Antiguo 26-10-2005
Avatar de dec
dec dec is offline
Moderador
 
Registrado: dic 2004
Ubicación: Alcobendas, Madrid, España
Posts: 13.110
Reputación: 34
dec Tiene un aura espectaculardec Tiene un aura espectacular
Hola,

La solución, digna de estudio (creo yo), la encontré escrita por Thomas Stutz en su ejemplo: Drag & Drop items from a TListBox to a TRichEdit?

Copio a continuación el código de Thomas Stutz por considerarlo merecido y útil:

Código Delphi [-]
 function RECharIndexByPos(RichEdit: TRichEdit; X, Y: Integer): Integer;
 var
   P: TPoint;
 begin
   P := Point(X, Y);
   Result := SendMessage(RichEdit.Handle, EM_CHARFROMPOS, 0, Longint(@P));
 end;
 
 
 procedure TForm1.RichEdit1DragOver(Sender, Source: TObject; X, Y: Integer;
   State: TDragState; var Accept: Boolean);
 var
   P: TPoint;
 begin
   // Check, if Source is ListBox1
   Accept := Source = ListBox1;
   if GetCursorPos(P) then
     with RichEdit1 do
     begin
       // Get the Index from Mouse Position
       P := ScreenToClient(P);
       SelStart := RECharIndexByPos(RichEdit1, P.X, P.Y);
       SetFocus;
     end;
 end;
 
 procedure TForm1.RichEdit1DragDrop(Sender, Source: TObject; X, Y: Integer);
 begin
   // finally insert text at mouse position
   RichEdit1.SelText := ListBox1.Items[ListBox1.ItemIndex];
 end;
__________________
David Esperalta
www.decsoftutils.com

Última edición por dec fecha: 26-10-2005 a las 10:47:31. Razón: Añadir código fuente.
Responder Con Cita