试试这个,基本上能够满足你的要求。
procedure TForm1.Edit1DragOver(Sender, Source: TObject; X, Y: Integer;
State: TDragState; var Accept: Boolean);
begin
if source is tlabel then accept:=true;
end;
procedure TForm1.Edit1DragDrop(Sender, Source: TObject; X, Y: Integer);
procedure addtxt(A_edit:tedit;A_label:tlabel;startpos:integer);
begin
A_edit.SelStart:=startpos;
A_edit.SelLength:=0;
A_edit.SelText:=A_label.Caption;
end;
var spos:integer;
begin
if (source is tlabel) and (sender is tedit) then begin
spos:=round((x/form1.Canvas.TextWidth(edit1.Text))*length(edit1.Text));
//spos:=(x div (-edit1.Font.Height))+1;
showmessage(inttostr(spos));
addtxt((sender as tedit),(source as tlabel),spos);
end;
end;