Hello Sergey,
How could you do a drag and drop word this way?
I have a listbox and I want to get a word from DBSrichviewEdit and drop only a copy of my word into my ListBox.
how could you do that?
thanks
Alex
Drag and Drop - Help
-
- Posts: 184
- Joined: Wed Jan 18, 2012 6:22 pm
Sergey, I tried this and I didn't have any success:
And I settled
DBSRichViewEdit1.RichViewEdit.DragMode := dmAutomatic
With a RichEdit worked fine, unfortunately it didn't with DBSrichViewEdit
Code: Select all
procedure TForm1.ListBox1DragDrop(Sender, Source: TObject; X, Y: Integer);
var
re: TDBSRichViewEdit;
lb: TListbox;
begin
if (Source is TDBSRichViewEdit) and (Source <> nil) then
begin
re := TDBSRichViewEdit(Source);
if (Sender is TListbox) and (Sender <> nil) then
begin
lb := TListBox(Sender);
lb.Items.Add(re.RichViewEdit.GetSelText);
end;
end;
end;
procedure TForm1.ListBox1DragOver(Sender, Source: TObject; X, Y: Integer;
State: TDragState; var Accept: Boolean);
begin
Accept := Source = DBSRichViewEdit1.RichViewEdit;
end;
And I settled
DBSRichViewEdit1.RichViewEdit.DragMode := dmAutomatic
With a RichEdit worked fine, unfortunately it didn't with DBSrichViewEdit
-
- Site Admin
- Posts: 17572
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
You cannot drag RichViewEdits inside TSRichViewEdit.
You can only drag TSRichViewEdit itself.
Unfortunately, TSRichViewEdit.DragMode is not published, it is protected. Open SclRView.pas and add property DragMode; to the published section of TSRichViewEdit.
However, after making the editor draggable, it becomes inconvenient to edit it.
Alternatively, you can use the "real" system drag&drop (instead of VCL drag&drop), it is supported natively by TSRichViewEdit.
However, when accepting this kind of drag&drop, you only have access to data (such as text) provided by the editor. You cannot distinguish if data were dragged from this TDBSRichViewEdit, or another TSRichViewEdit, or from another copy of your application, or from another application (such as a browser or MS Word). If it is ok, I can create a demo.
You can only drag TSRichViewEdit itself.
Unfortunately, TSRichViewEdit.DragMode is not published, it is protected. Open SclRView.pas and add property DragMode; to the published section of TSRichViewEdit.
However, after making the editor draggable, it becomes inconvenient to edit it.
Alternatively, you can use the "real" system drag&drop (instead of VCL drag&drop), it is supported natively by TSRichViewEdit.
However, when accepting this kind of drag&drop, you only have access to data (such as text) provided by the editor. You cannot distinguish if data were dragged from this TDBSRichViewEdit, or another TSRichViewEdit, or from another copy of your application, or from another application (such as a browser or MS Word). If it is ok, I can create a demo.
-
- Posts: 184
- Joined: Wed Jan 18, 2012 6:22 pm
-
- Site Admin
- Posts: 17572
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Using OLE drag&drop requires writing some "low level" code implementing IDropTarget interface.
But there is a ready-to-use solution: Drag and Drop Component Suite by Anders Melander: http://melander.dk
The example is here:
http://www.trichview.com/forums/viewtopic.php?t=3407
It is for TRichViewEdit, but for TSRichViewEdit it is the same. This listbox can accept text from all sources.
But there is a ready-to-use solution: Drag and Drop Component Suite by Anders Melander: http://melander.dk
The example is here:
http://www.trichview.com/forums/viewtopic.php?t=3407
It is for TRichViewEdit, but for TSRichViewEdit it is the same. This listbox can accept text from all sources.