[Demo] Dragging URL from TreeView to RichViewEdit

Demos, code samples. Only questions related to the existing topics are allowed here.
Post Reply
Sergey Tkachenko
Site Admin
Posts: 17602
Joined: Sat Aug 27, 2005 10:28 am
Contact:

[Demo] Dragging URL from TreeView to RichViewEdit

Post by Sergey Tkachenko »

dragurlfromtree.zip
(3.94 KiB) Downloaded 1962 times
TRichView supports the standard Windows (COM-based) drag&drop, but does not support VCL drag&drop.
With use of Drag&Drop Component Suite by Anders Melander ( http://www.melander.dk/ ), you can easily implement drag&drop between VCL components and RichViewEdit.
New version of Drag&Drop Component Suite can be downloaded from https://github.com/DelphiPraxis/The-Dra ... nent-Suite

This demo shows how to drop:
- URLs listed in TTreeView
- bitmap contained in TImage
in TRichViewEdit.

[+] History of updates
2011-Oct-2: for compatibility with TRichView 13.4
2018-May-2: for compatibility with TRichView 17.3 and new version of Drag&Drop Component Suite
[+] Old versions
https://www.trichview.com/support/files ... omtree.zip - for TRichView from version 13.4 to 17.2
Sergey Tkachenko
Site Admin
Posts: 17602
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

One more simple example using Drag&Drop Component Suite: dragging text from TRichViewEdit to TListBox
https://www.trichview.com/support/files ... istbox.zip

[+] History of updates
2018-May-2: compatibility with old versions of Delphi
Sergey Tkachenko
Site Admin
Posts: 17602
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Update: this information is obsolete. You can download a new version of D&D Component Suite from https://github.com/DelphiPraxis/The-Dra ... for-Delphi . It is compatible with new versions of Delphi.

The current version of Drag&Drop Component Suite is 5.2.
It is not compatible with Delphi XE2.

Changes required to install it in XE2:
1) Open DragDrop.pas, change all occurrences (2 times) of 'CF_MAX-1' to CF_LOCALE
2) Open DragDropContext.pas, change the declaration of methods of TDropContextMenu to

Code: Select all

    { IContextMenu }
    function QueryContextMenu(Menu: HMENU; indexMenu, idCmdFirst, idCmdLast,
      uFlags: UINT): HResult; stdcall;
    function InvokeCommand(var lpici: TCMInvokeCommandInfo): HResult; stdcall;
    function GetCommandString(idCmd: UINT_PTR; uType: UINT; pwReserved: PUINT;
      pszName: LPSTR; cchMax: UINT): HResult; stdcall;

    { IContextMenu2 }
    function HandleMenuMsg(uMsg: UINT; WParam: WPARAM; LParam: LPARAM): HResult; stdcall;

    { IContextMenu3 }
    function HandleMenuMsg2(uMsg: UINT; WParam: WPARAM; LParam: LPARAM;
      var lpResult: LRESULT): HResult; stdcall;
The same changes must be made to implementation of these methods.
3) Open DragDropD2011 package, save it as DragDropDXE2, and install.
VBDavie
Posts: 1
Joined: Wed Feb 20, 2013 6:36 am

Post by VBDavie »

Also I noticed a couple of other changes needed to complete compile.
I have XE3 BTW.....

In the GetCommandString function there is this CASE statement:
case uFlags of //DLR was UType

Notice I changed from UTypes to UFlags ;) That is because the NAME OF THE PARAMTER into the procedure had changed from UType to UFlags.

ALSO:
function TDropContextMenu.HandleMenuMsg(uMsg: UINT; WParam: WPARAM; LParam: LPARAM): HResult;
var
lpResult: LRESULT; //DLR


Notice my REDEFINITION of the lpResult variable. It USED to be "Integer", It had to be CHANGED to LRESULT, because the variable is used in a procedure call and the procedure EXPECTS a variable of type LPRESULT and not INTEGER ;)

Anyways.... I got it to compile, so, YIPPIE!!!

Hope this helps someone out there!

Davie
Post Reply