fidel83
asked on
explorer context menu
Hi,
I got a TListview that shows a list of files. I want to be able to right-click one of the files and have a context menu displayed. (like in explorer).
So if for example you right-click an mp3, then it has 'Play in winamp', 'Enqueue in winamp', Delete, Cut, Properties etc.
I got a TListview that shows a list of files. I want to be able to right-click one of the files and have a context menu displayed. (like in explorer).
So if for example you right-click an mp3, then it has 'Play in winamp', 'Enqueue in winamp', Delete, Cut, Properties etc.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
hi fidel,
you can't just use the above immediately because I cut it out from a much larger programme... but just look at how I use the IContextMenu2 interface's various procedures.
you can't just use the above immediately because I cut it out from a much larger programme... but just look at how I use the IContextMenu2 interface's various procedures.
ASKER
i could not get the code to run. Could you please give me some parameters to call it with?
procedure DisplayContextMenu(Display
var Result: HResult;
PopupMenu: HMenu;
Cmd: Cardinal;
ICM: TCMInvokeCommandInfo;
ContextMenu: IContextMenu;
Verb: string;
uFlags: UInt;
ErrorMode: Word;
Execute: Boolean;
begin
if RenameItem then uFlags := CMF_EXPLORE or CMF_CANRENAME
else uFlags := CMF_EXPLORE;
PopupMenu := CreatePopupMenu;
try
Result := ShellFolder.GetUIObjectOf(
if Result = 0 then
begin
Result := ContextMenu.QueryInterface
ErrorMode := SetErrorMode(SEM_FailCriti
try
if Result = 0 then
ContextMenu2.QueryContextM
else
ContextMenu.QueryContextMe
finally
SetErrorMode(ErrorMode);
end;
Cmd := Cardinal(TrackPopupMenuEx(
if Cmd > 0 then
begin
SetLength(Verb, 255);
if ContextMenu2 <> nil then ContextMenu2.GetCommandStr
else ContextMenu.GetCommandStri
SetLength(Verb, strlen(PChar(Verb)));
end;
end;
finally
DestroyMenu(PopupMenu);
end;
end;