Unit ItemProp

Standard defines for all Delphi Free Stuff components } { -----------------------------------------------------------------------------} { A unit to provide access to a file's context menu, properties dialog, and } { default action. } { Copyright 1998, Brad Stowers. All Rights Reserved. } { This unit can be freely used and distributed in commercial and private } { environments, provied this notice is not modified in any way. } { -----------------------------------------------------------------------------} { Feel free to contact me if you have any questions, comments or suggestions } { at bstowers@pobox.com . } { The latest version of this unit can always be found at: } { http://www.pobox.com/~bstowers/delphi/ } { -----------------------------------------------------------------------------} { Date last modified: May 15, 1997 } { -----------------------------------------------------------------------------} { -----------------------------------------------------------------------------} { ItemProp v2.10 } { -----------------------------------------------------------------------------} { Description: } { Given only a filename, the context menu or properties dialog can be } { displayed, or the default action taken (i.e. Open). This hides the messy } { parts of using the Shell Namespace API. } { } { Known Issues (bugs): } { * Cut and Copy context menu commands don't work on machines that don't } { Internet Explorer 4 stuff installed. I'm at complete loss to explain } { why. Others have told me they have the same problem using C++, so I } { don't think it's specific to Delphi. } { } { -----------------------------------------------------------------------------} { Revision History: } { 2.10: + Added new versions of all functions that accept PIDLs instead of } { filenames. If you don't know what a PIDL is, then you don't need } { these functions. There useful when you are fooling around with the } { Shell Namespace API functions. } { 2.00: + Send To menu now works. Thanks to Matt Ginzton } { (magi@cs.stanford.edu) for sending me C++ code snippet. } { 1.03: + Some code clean up. } { + Really works with C++Builder now. Thanks again to Michael Trier. } { 1.02: + Small change for C++Builder compatibility. Thanks to Michael Trier.} { 1.01: + Updated for Delphi 3 compatibility. } { + Now works properly with drives. Just pass something like C:\, but } { NOT C: } { 1.00: + Initial release } { -----------------------------------------------------------------------------

Classes

Functions

DisplayContextMenu - ------------------------------------------------------------------------------ You must pass fully qualified path names to all of these functions.
DisplayContextMenuPIDL - HWND(Parent
DisplayPropertiesDialog - ------------------------------------------------------------------------------ DisplayPropertiesDialog displays, oddly enough, the properties dialog for the given file or directory.
DisplayPropertiesDialogPIDL -
PerformDefaultAction - ------------------------------------------------------------------------------ PerformDefaultAction causes the item's double-click action to be taken.
PerformDefaultActionPIDL -

Types

Constants

Variables


Functions


function DisplayContextMenu(const Filename: string; Parent: pointer; {$ENDIF} Pos: TPoint): boolean;

------------------------------------------------------------------------------ You must pass fully qualified path names to all of these functions. No guarantees are made as to what will happen for relative pathnames. If you are calling for a subdirectory (i.e. no filename), it is your responsibility to insure that there is *NO* trailing backslash. ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ DisplayContextMenu displays the right click menu for the given file or directory and processes the item selected, if any. Parent is the window handle for the owning window of any error messages that may need to be displayed by the system, MyForm.Handle is generally fine. Pos is the X, Y position to display the menu at given in screen (absolute) coordinates. ------------------------------------------------------------------------------

function DisplayContextMenuPIDL(AParent: IShellFolder; APIDL: PItemIDList; Attr: ULONG; Parent: pointer; {$ENDIF} Pos: TPoint): boolean;

HWND(Parent

function DisplayPropertiesDialog(const Filename: string; Parent: pointer {$ENDIF}): boolean;

------------------------------------------------------------------------------ DisplayPropertiesDialog displays, oddly enough, the properties dialog for the given file or directory. Parent is the window handle for the owning window of any error messages that may need to be displayed by the system, MyForm.Handle is generally fine. ------------------------------------------------------------------------------

if Succeeded(CompFolder.GetUIObjectOf(Parent, 1, ItemID, IID_IContextMenu, NIL, pointer(ContextMenu))) then begin if Succeeded(ContextMenu.QueryInterface( IID_IContextMenu2, pointer(ContextMenu2))) then begin {$IFDEF DFS_COMPILER_2} ContextMenu.Release; // Delphi 3 does this for you. {$ENDIF} ContextMenu := ContextMenu2; HaveCM2 := TRUE; end; try HandleContextMenu(ContextMenu, Attr, HaveCM2); finally {$IFDEF DFS_COMPILER_2} ContextMenu.Release; // Delphi 3 does this for you. {$ENDIF} end; end;


function DisplayPropertiesDialogPIDL(AParent: IShellFolder; APIDL: PItemIDList; Attr: ULONG; Parent: pointer {$ENDIF}): boolean;


function PerformDefaultAction(const Filename: string; Parent: pointer {$ENDIF}): boolean;

------------------------------------------------------------------------------ PerformDefaultAction causes the item's double-click action to be taken. Parent is the window handle for the owning window of any error messages that may need to be displayed by the system, MyForm.Handle is generally fine. ------------------------------------------------------------------------------

HWND(Parent


function PerformDefaultActionPIDL(AParent: IShellFolder; APIDL: PItemIDList; Attr: ULONG; Parent: pointer {$ENDIF}): boolean;


Types


Constants


Variables