A
avbb4cat
Unregistered / Unconfirmed
GUEST, unregistred user!
D5下可以实现,但是D7下就看不到那个Bean!
望各位大侠解惑!
procedure TForm1.ListBox1MouseDown(Sender: TObject
Button: TMouseButton;
Shift: TShiftState
X, Y: Integer);
begin
inherited;
if(Button=mbLeft)and(not (ssDouble in Shift))then
with Sender as TCustomListBox do
begin
if(ItemAtPos(Point(X, Y), True)=ItemIndex)and(ItemIndex>=0)then begin
BeginDrag(False);
end;
end;
end;
procedure TForm1.RichEdit1DragOver(Sender, Source: TObject
X, Y: Integer;
State: TDragState
var Accept: Boolean);
var
P: TPoint;
Idx: Integer;
RichEdit:TRichEdit;
begin
RichEdit := TRichEdit(Sender);
if (TWinControl(Source).ClassName='TListBox') then
Accept := True;
if Accept then
begin
if not RichEdit.Focused then RichEdit.SetFocus;
P := Point(X,Y);
Idx := SendMEssage(RichEdit.Handle,EM_CHARFROMPOS,0,Integer(@P));
if Idx>=0 then
RichEdit.SelStart := Idx;
end;
end;
procedure TForm1.RichEdit1DragDrop(Sender, Source: TObject
X, Y: Integer);
var
ListBox: TListBox;
RichEdit: TRichEdit;
begin
RichEdit := TRichEdit(Sender);
if Source.ClassName='TListBox' then
begin
ListBox := TListBox(Source);
RichEdit.SetSelTextBuf(PChar(' ' + ListBox.Items[ListBox.ItemIndex] + ' '));
end;
end;
望各位大侠解惑!
procedure TForm1.ListBox1MouseDown(Sender: TObject
Button: TMouseButton;
Shift: TShiftState
X, Y: Integer);
begin
inherited;
if(Button=mbLeft)and(not (ssDouble in Shift))then
with Sender as TCustomListBox do
begin
if(ItemAtPos(Point(X, Y), True)=ItemIndex)and(ItemIndex>=0)then begin
BeginDrag(False);
end;
end;
end;
procedure TForm1.RichEdit1DragOver(Sender, Source: TObject
X, Y: Integer;
State: TDragState
var Accept: Boolean);
var
P: TPoint;
Idx: Integer;
RichEdit:TRichEdit;
begin
RichEdit := TRichEdit(Sender);
if (TWinControl(Source).ClassName='TListBox') then
Accept := True;
if Accept then
begin
if not RichEdit.Focused then RichEdit.SetFocus;
P := Point(X,Y);
Idx := SendMEssage(RichEdit.Handle,EM_CHARFROMPOS,0,Integer(@P));
if Idx>=0 then
RichEdit.SelStart := Idx;
end;
end;
procedure TForm1.RichEdit1DragDrop(Sender, Source: TObject
X, Y: Integer);
var
ListBox: TListBox;
RichEdit: TRichEdit;
begin
RichEdit := TRichEdit(Sender);
if Source.ClassName='TListBox' then
begin
ListBox := TListBox(Source);
RichEdit.SetSelTextBuf(PChar(' ' + ListBox.Items[ListBox.ItemIndex] + ' '));
end;
end;