procedure TForm1.DBGrid1MouseMove(Sender: TObject; Shift: TShiftState;
X, Y: Integer);
var gc:TGridcoord;
begin
gc := dbgData.MouseCoord(X, Y);
if (Shift=[ssLeft]) and (gc.Y>0) then
begin
dbgData.BeginDrag(True);
end;
end;
procedure TForm1.RichEdit1DragOver(Sender, Source: TObject; X,
Y: Integer; State: TDragState; var Accept: Boolean);
var p:TPoint;
begin
Accept := (Source is TDBGrid);
//
if GetCursorPos(p) then
begin
p := RichEdit1.ScreenToClient(p);
RichEdit1.SelStart := fn_Get_CharIndexByPos(RichEdit1, p.X, p.Y);
RichEdit1.SetFocus;
end;
end;
function TForm1.fn_Get_CharIndexByPos(RichEdit: TRichEdit; X, Y: Integer): Integer;
var
P: TPoint;
begin
P := Point(X, Y);
Result := SendMessage(RichEdit.Handle, EM_CHARFROMPOS, 0, Longint(@P));
end;
沒有留言:
張貼留言