ShellPlus Customer login
ShellPlus
Shell+ components
    Home
    News
    Overview
    Download
    Examples
    Customer's area
    Flash Demo
 
Developer Tools
    Shell Reset Tool
 
Shell+ Tutorial
    Namespace Extensions
    ShortCut menu
    Property Sheet
    Icon Handler
    Thumbnails
    InfoTip Handler
    Copy Hook
    Balloon TrayIcon
    Control Panel
    Shortcut Files
    Drag&Drop Menu
    Shell Change Notify
 
 
Documents
    Articles Index
    Press Releases
 
Purchase
    Buy now
    Resellers network
    Resellers wanted
 
Support
    Contact directly
    Customer's area
 
About/Contacts
    Shell+ Developers

Embarcader Technology Partner

 
Drag&Drop Menu Handler Example

    When user drags a file using a right mouse button then the context menu is shown when the object is about to be dropped. Usually this menu contains suggestion to copy or move the file but it can be enhance if necessary. Use the TSxDragDropMenu to enhance this menu with your own items. The example below shows how to create "Hard Link" for the file being dragged.

    The TSxDragDropMenu is very similar to the TSxContextMenu component because it is inherited from TSxContextMenu. We recommend to study TSxContextMenu usage example too.

    Important note: The Hard Link is a feature of the NTFS file system so this example will work for Windows NT/2000/XP on NTFS volumes only.

    The DragDrop Menu handler is an ActiveX library like all other Shell Extensions. The first step to do is to create a new ActiveX Library. Create it with the following sequence of operations: open the Repository dialog using File | New | Other... menu, then select the ActiveX tab and click the ActiveX Library icon.

Create new ActiveX library
Fig. 1. New ActiveX Library creation.

    Save the created project.

    The next step is to add the instance of TSxDataModule to the project. Every Shell+ component should be placed on SxDataModule 1. This special descendant of TDataModule supplies several internal methods that allow Shell+ components to safely operates in multiple Shell threads and automates their registration and initialization. Note that you can place several Shell+ components onto the same SxDataModule as well as you can add multiple TSxDataModule instances to your project. It is easy to add new SxDataModule to the project - just click corresponding icon in the Repository:

Create new Shell extension module
Fig. 2. How to create new SxDataModule instance.

    You can save the project now.

    Add the TSxDragDropMenu now. This component automates the menu drawing and allows you to forget about communication with Shell. This component simply uses standard Delphi's TPopupMenu component as a source of menu items. So add the TPopupMenu to the module and set the TSxDragDropMenu.ContextMenu property to it.

    Look on the properties of TSxDragDropMenu component:

CLSID

Automatically generated GUID. All shell extensions use it to be identified by system.

ContextMenu

TPopupMenu reference. This component will be used in its usual manner - it holds menu items to be displayed. Unlike the ordinary application these menu items will be displayed in the shell's shortcut menu, not application menu. Use TPopupMenu designer to edit menu items as you do it usually.

Description

Extension description, enter desired text here.

ExtensionName

Short name of the extension, MyContextMenu for example.

FileType

File type to be handled by the extension. The extended menu items will be shown for this file type only. Drag&Drop menu extension can be installed for folders and printers only Set this parameter to "Directory".

Name

An ordinary name of the Delphi component.

Table 1. TSxDragDropMenu component properties

    Set component properties as shown below:

Drag&Drop menu component properties
Fig 3. TSxDragDropMenu properties sample

    The next step is to design the menu. Do it as usual with native TPopupMenu designer.

Drag&Drop menu component properties

    Save the project and compile it - it is ready now! As well as any other ActiveX library the Shell+ project requires registration. You can register it in several ways:

  • from command prompt using MS regsvr32 utility: regsvr32.exe Project1.dll
  • from command prompt using Borland's tregsvr utility: tregsvr Project1.dll

To know more about shell extension installation please follow the link.

The final step is to test the extension library. Create the new text document on the desktop or in any folder. You can use the New | Text Document context menu for this purpose. Right click the newly created file and drag it to any other folder:

Drag&Drop menu example

    Don't forget to uninstall the example when all tests are finished. Note that it is an example only and it will show its confirmation window until you will not unregister it. As well as installation the uninstallation can be done in many ways:

  • from command prompt using MS regsvr32 utility: regsvr32.exe /u Project1.dll
  • from command prompt using Borland's tregsvr utility: tregsvr -u Project1.dll

The detailed information about extension uninstallation is available here.


1. The only exception is the TSxTrayIcon component that does not need to be placed on SxDataModule instance.


Download example

Use links below to download source codes of this example as well as binary files:

Delphi 10.1 Berlin (x64)
DragDropMenu-D24X64.zip
1.10Mb
3.15.296.396
11.09.2016
Delphi 10.1 Berlin
DragDropMenu-D24.zip
891.24Kb
3.15.296.396
11.09.2016
Delphi 10 Seattle (x64)
DragDropMenu-D23X64.zip
1.10Mb
3.15.296.396
11.09.2016
Delphi 10 Seattle
DragDropMenu-D23.zip
883.11Kb
3.15.296.396
11.09.2016
Delphi XE8 (x64)
DragDropMenu-D22X64.zip
1.10Mb
3.12.289.357
15.05.2015
Delphi XE8
DragDropMenu-D22.zip
881.85Kb
3.12.289.357
15.05.2015
Delphi XE7 (x64)
DragDropMenu-D21X64.zip
1.10Mb
3.11.289.357
19.09.2014
Delphi XE7
DragDropMenu-D21.zip
88.63Kb
3.11.289.357
19.09.2014
Delphi XE6 (x64)
DragDropMenu-D20X64.zip
1.10Mb
3.10.287.331
16.09.2014
Delphi XE6
DragDropMenu-D20.zip
88.51Kb
3.10.287.331
16.09.2014
Delphi XE5 (x64)
DragDropMenu-D19X64.zip
1.06Mb
3.10.287.331
16.03.2014
Delphi XE5
DragDropMenu-D19.zip
87.65Kb
3.10.287.331
16.03.2014
Delphi XE4 (x64)
DragDropMenu-D18X64.zip
1.05Mb
3.10.287.331
16.03.2014
Delphi XE4
DragDropMenu-D18.zip
87.61Kb
3.10.287.331
16.03.2014
Delphi XE3 (x64)
DragDropMenu-D17X64.zip
1.03Mb
3.10.287.331
16.03.2014
Delphi XE3
DragDropMenu-D17.zip
87.58Kb
3.10.287.331
16.03.2014
Delphi XE2 (x64)
DragDropMenu-D16X64.zip
788.81Kb
3.10.287.331
16.03.2014
Delphi XE2
DragDropMenu-D16.zip
87.62Kb
3.10.287.331
16.03.2014
Delphi XE
DragDropMenu-D15.zip
83.53Kb
3.10.287.331
16.03.2014
Delphi 2010
DragDropMenu-D14.zip
82.97Kb
3.10.287.331
16.03.2014
Delphi 2009
DragDropMenu-D12.zip
52.01Kb
3.10.287.331
16.03.2014
Delphi 2007
DragDropMenu-D11.zip
51.10Kb
3.10.287.331
16.03.2014
Delphi 2006
DragDropMenu-D10.zip
50.94Kb
3.10.287.331
16.03.2014
Delphi 2005
DragDropMenu-D9.zip
52.03Kb
3.10.287.331
16.03.2014
Delphi 7
DragDropMenu-D7.zip
260.37Kb
3.12.289.357
16.05.2015
Delphi 6
DragDropMenu-D6.zip
51.23Kb
3.8.287.331
09.05.2012

  Top


Components | Download | Purchase | Support | About Us
Copyright © 2016 ALDYN Software. All rights reserved.
Copyright © 2001 - 2011 Shell+ Development Group. All rights reserved.