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

 
Shortcut Menu Example

    Shortcut Menu Shell Extensions are used to add custom menu items to file's pop-up menus. Use TSxContextMenu to add this feature to your application.

    The Shortcut 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 TSxContextMenu now. This component automates the menu drawing and allows you to forget about communication with Shell. This component uses TSxPopupMenu which is simply standard Delphi's TPopupMenu component ancestor. In the TsxPopupMenu you can specify the menu items by simple and know way - using standard Menu Editor. So add the TSxPopupMenu to the module and set the TSxContextMenu.ContextMenu property to it.

    Look on the properties of TSxContextMenu component:

CLSID

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

ContextMenu

TSxPopupMenu 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 TSxPopupMenu 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. This example uses the "txtfile" file type, it includes most of text files such as txt, ini, log and many other.

Name

An ordinary name of the Delphi component.

Table 1. TSxContextMenu component properties

    Set component properties as shown below:

TSxContextMenu component properties
Fig 3. TSxContextMenu properties sample

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

Context Menu Designer Example

    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. You should see several new menu items in it:

File Context 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.


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

Delphi 10.1 Berlin (x64)
ContextMenu-D24X64.zip
1.09Mb
3.15.296.396
11.09.2016
Delphi 10.1 Berlin
ContextMenu-D24.zip
878.73Kb
3.15.296.396
11.09.2016
Delphi 10 Seattle (x64)
ContextMenu-D23X64.zip
1.09Mb
3.15.296.396
11.09.2016
Delphi 10 Seattle
ContextMenu-D23.zip
871.05Kb
3.15.296.396
11.09.2016
Delphi XE8 (x64)
ContextMenu-D22X64.zip
1.08Mb
3.12.289.357
15.05.2015
Delphi XE8
ContextMenu-D22.zip
869.84Kb
3.12.289.357
15.05.2015
Delphi XE7 (x64)
ContextMenu-D21X64.zip
1.09Mb
3.11.289.357
19.09.2014
Delphi XE7
ContextMenu-D21.zip
88.83Kb
3.11.289.357
19.09.2014
Delphi XE6 (x64)
ContextMenu-D20X64.zip
1.09Mb
3.10.287.331
16.09.2014
Delphi XE6
ContextMenu-D20.zip
88.75Kb
3.10.287.331
16.09.2014
Delphi XE5 (x64)
ContextMenu-D19X64.zip
1.04Mb
3.10.287.331
16.03.2014
Delphi XE5
ContextMenu-D19.zip
88.37Kb
3.10.287.331
16.03.2014
Delphi XE4 (x64)
ContextMenu-D18X64.zip
1.04Mb
3.10.287.331
16.03.2014
Delphi XE4
ContextMenu-D18.zip
88.32Kb
3.10.287.331
16.03.2014
Delphi XE3 (x64)
ContextMenu-D17X64.zip
1.02Mb
3.10.287.331
16.03.2014
Delphi XE3
ContextMenu-D17.zip
88.28Kb
3.10.287.331
16.03.2014
Delphi XE2 (x64)
ContextMenu-D16X64.zip
778.17Kb
3.10.287.331
16.03.2014
Delphi XE2
ContextMenu-D16.zip
88.11Kb
3.10.287.331
16.03.2014
Delphi XE
ContextMenu-D15.zip
84.01Kb
3.10.287.331
16.03.2014
Delphi 2010
ContextMenu-D14.zip
83.35Kb
3.10.287.331
16.03.2014
Delphi 2009
ContextMenu-D12.zip
51.42Kb
3.10.287.331
16.03.2014
Delphi 2007
ContextMenu-D11.zip
50.63Kb
3.10.287.331
16.03.2014
Delphi 2006
ContextMenu-D10.zip
50.51Kb
3.10.287.331
16.03.2014
Delphi 2005
ContextMenu-D9.zip
51.50Kb
3.10.287.331
16.03.2014
Delphi 7
ContextMenu-D7.zip
247.05Kb
3.12.289.357
16.05.2015
Delphi 6
ContextMenu-D6.zip
50.68Kb
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.