Open a file's context dialog, default action and etc
Asked Answered
G

2

5

In Windows when one is in Windows Explorer and right clicks a file or directory, a Windows context menu appears with all of the actions that one can do regarding this file or directory.

Way back in the day, Brad Stowers wrote a unit ItemProp.pas that did the exact same thing within one's own Delphi application. This unit works great through Delphi 5, but for D7 and above, a lot of errors are thrown.

http://www.koders.com/delphi/fid7ABE724EBD5F2123FF824AFD45151D2A087C5E6C.aspx?s=network

Okay! I admit it! I AM lazy and have Googled for an updated unit and even one like this, have worked for a couple hours trying to make this unit at least D7 compatible but I guess I am missing something somewhere as I have not been successful in any endeavor regarding this.

So... my question is, has anyone updated this unit for D7 and above OR does a unit or component exist that does what this code does?

Thanks in advance!

John

Gunsmith answered 3/11, 2011 at 3:52 Comment(0)
J
5

I suspect all that is needed is to update the compiler version directives in DFS.inc

I added

{$DEFINE DFS_DELPHI}
{$DEFINE DFS_COMPILER_4_UP}
{$DEFINE DFS_NO_COM_CLEANUP}
{$DEFINE DFS_COMPILER_3_UP}

to the main file (ItemProp.pas), and it compiled OK on Delphi 2007, but I haven't tried running the code yet.

Jacinthe answered 3/11, 2011 at 4:7 Comment(3)
JEESH! I saw something similar to this in one of the googled files that I did find and was "added for D5" but the code presented had the included dfs.inc removed, {$I DFS.INC} was removed and of course it failed to compile. I should have thought ahead but I am losing my Delphi programming skills. THANK-YOU!Gunsmith
@John: Good to see that you found the check mark and accepted Gerry's answer. It is part of what makes SO work. Did you realize that apart from accepting the answer you can also upvote it?Catlaina
Thanks Marjan. I tried last night but it said I needed more 'points' or something. This AM it allowed me to upvote it.Gunsmith
T
5

Instead of translate this unit you can use the updated JEDI JCL library, check the JclShell unit, inside of this unit exist a function called DisplayContextMenu whcih shows the shell context menu for a File.

function DisplayContextMenu(const Handle: HWND; const FileName: string;
  Pos: TPoint): Boolean;
Tactile answered 3/11, 2011 at 4:19 Comment(1)
I searched JEDI too figuring they had to have something like this. With a gazillion components, I missed it as usual. Thanks everyone!Gunsmith

© 2022 - 2024 — McMap. All rights reserved.