Created by: gwideman, Jan 19, 2012 5:18 pm
Revised by: gwideman, Apr 3, 2012 10:13 am (8 revisions)


I needed to use Anders Melander's Drag and Drop component suite in Delphi XE2, but the most recent version, 5.2, has compiled versions only up to Delphi 2010. So, what will be entailed in compiling for XE2? This article captures notes on the process.
Anyone following this procedure might also like to review how Delphi paths work with respect to packages:Delphi -- notes on packages


Version downloaded:


Directory layout:
  • ..\3rdPartyLibs\Melander\
    • DragDrop\
      • Demos\
      • Library\
      • Packages\
      • Source\
Anders' readme.txt: "Find the design time package that matches your version of Delphi. Open it in Delphi, Compile and Install.". However, the most recent package is "DragDropD2011.dpk", and corresponding dof file.
So I started by copying and renaming those to files to: DragDropDXE2.dpk and .dof. Then I edited and debugger them in the steps below.
I noted this component set has only one package version, and it's for design time only. For runtime, the assumption is that the needed units from this library will link statically. This is fine, especially as we're likely to need only a fraction of the code (just one or two drag formats) anyway, so separate dcus allows the linker to include only what it needs.

Edits to DragDropDXE2.dpk

  • I changed the package statement to match the new file name.

Edits to DragDropDXE2.dof

  • [Directories] section
    • Search and replace all "Delphi 2011" to "DelphiXE2
    • Correspondingly, I added an actual directory at: ..\DragDrop\Library\DelphiXE2
    • I'm pretty sure I may want to change the DLL (bpl) and DCP output directories, but that can wait until next step.

Config Changes

  • In DXE2, Open DragDropDXE2.dpk
    • DragDropDXE2.bpl > Project Options
        • Delphi compiler
          • The following changes are to remove the project-specific package (bpl) output dir and DCP output dirs, allowing my preferred default dirs to take effect.
          • Package output dir: For All configs, deleted setting
          • DCP output dir: For All configs, deleted setting


  • In DXE2, Open DragDropDXE2.dpk
    • Message: Upgrading project ...\DragDropDXE2.dpk to ...\DragDropDXE2.dproj
    • In Project Manager, I saved the project group as ...\DragDrop\Packages\DragDropDXE2Grp.groupproj
  • In Project Manager
    • Build configs --> Debug
    • Target Platforms --> 32-bit Windows
  • Compile 1: 3 errors
    • DragDrop.pas:2487 "Number of elements differs from declaration"
      • Apparently the status of the end of the list involving CF_MAX has changed, so that now CF_MAX encompasses CF_DIBV5, where previously it did not. (Windows.pas: 23340)
      • sClipNames: add a string: 'CF_DIBV5'
    • DragDrop.pas:2491 duplicate case label
      • case Value of CF_TEXT....CFMAX-1: ... delete case 17
  • Compile 2:
    • [DCC Error] DragDropContext.pas(66): E2291 Missing implementation of interface method IContextMenu3.HandleMenuMsg2
    • [DCC Error] DragDropContext.pas(66): E2291 Missing implementation of interface method IContextMenu2.HandleMenuMsg
    • [DCC Error] DragDropContext.pas(66): E2291 Missing implementation of interface method IContextMenu.GetCommandString
      • But class TDropContextMenu in fact has these methods, so what's going on? Mismatch parameters perhaps?
        • TDropContextMenu.HandleMenuMsg: has Integer params, whereas IContextMenu2.HandleMenuMsg has WPARAM and LPARAM. So change TDropContextMenu.HandleMenuMsg to match the interface definitions.
        • The other two are similar: Inspect the interface definitions in Winapi.ShlObj, and change the corresponding method params in TDropContextMenu to match.
  • Compile 3
    • Error: TDropContextMenu.HandleMenuMsg ... var lpResult: Integer --> LRESULT
  • Compile 4: Zero errors!
    • Verified that DragDropDXE2.bpl and DragDropDXE2.dcp show up in my IDE-set bpl and dcp directories


  • In Project Manager
    • DragDropDXE2.bpl > Install
      • succeeded
  • Tools > Options
    • Environment > Delphi > Library
      • Library path: Add path to dcus: ...\3rdPartyLibs\Melander\DragDrop\Library\DelphiXE2
      • Browsing path: Add path to source: ...\3rdPartyLibs\Melander\DragDrop\Source
        • This is optional, but I figure it might be useful in case problems need debugging.


As a quick test, I tried the ComboTargetDemo
  • Compiled, no errors
  • Ran, and accepted various kinds of drops.
Obviously more testing could be done, but I tested the kinds of drops I need, so good enough for now!