www.un.org/Depts/DGACM/index_spanish.htm 简短回答
Try the ShellBrowser Parts from JAM 软件。 它们有一个组成部分,使你们能够展示探索者的背景菜单,而你们自己的指挥则好坏参半。
http://www.ohchr.org。
找到探索者菜单,盘问其所有财产,将其放在你自己的菜单上,是可能的,但你真的应该能够读写低水平的Win32法典,而C公司的工作知识将有所帮助。 你们也需要看看看看一些 go(见下文)。 我强烈建议阅读:http://blogs.msdn.com/b/oldnewthing/archive/2004/09/20/231739.aspx” rel=“noreferer” • 如何为许多技术细节主办一个IContextMenu系列。
<easier办法是询问IContextMenu界面,即HMENU,然后使用跟踪PopupMenu,让Windows显示菜单,然后打电话到InvokeCommand。
以下几部法典未经测试或已经从我们重新使用的内容中修改,因此以自己的风险进行。
http://msdn.microsoft.com/en-us/library/bb77609528VS. 8529.aspx“rel=“noreferer”>IConMenu。
function GetExplorerMenu(AHandle: HWND; const APath: string;
AFilenames: TStrings): IContextMenu;
var
Desktop, Parent: IShellFolder;
FolderPidl: PItemIDList;
FilePidls: array of PItemIDList;
PathW: WideString;
i: Integer;
begin
// Retrieve the Desktop s IShellFolder interface
OleCheck(SHGetDesktopFolder(Desktop));
// Retrieve the parent folder s PItemIDList and then it s IShellFolder interface
PathW := WideString(IncludeTrailingPathDelimiter(APath));
OleCheck(Desktop.ParseDisplayName(AHandle, nil, PWideChar(PathW),
Cardinal(nil^), FolderPidl, Cardinal(nil^)));
try
OleCheck(Desktop.BindToObject(FolderPidl, nil, IID_IShellFolder, Parent));
finally
SHFree(FolderPidl);
end;
// Retrieve PIDLs for each file, relative the the parent folder
SetLength(FilePidls, AFilenames.Count);
try
FillChar(FilePidls[0], SizeOf(PItemIDList) * AFilenames.Count, 0);
for i := 0 to AFilenames.Count-1 do begin
PathW := WideString(AFilenames[i]);
OleCheck(Parent.ParseDisplayName(AHandle, nil, PWideChar(PathW),
Cardinal(nil^), FilePidls[i], Cardinal(nil^)));
end;
// Get the context menu for the files from the parent s IShellFolder
OleCheck(Parent.GetUIObjectOf(AHandle, AFilenames.Count, FilePidls[0],
IID_IContextMenu, nil, Result));
finally
for i := 0 to Length(FilePidls) - 1 do
SHFree(FilePidls[i]);
end;
end;
为了获取实际菜单,你需要打电话。 您可使用。
function GetExplorerHMenu(const AContextMenu: IContextMenu): HMENU;
const
MENUID_FIRST = 1;
MENUID_LAST = $7FFF;
var
OldMode: UINT;
begin
OldMode := SetErrorMode(SEM_FAILCRITICALERRORS or SEM_NOOPENFILEERRORBOX);
try
Result := CreatePopupMenu;
AContextMenu.QueryContextMenu(Result, 0, MENUID_FIRST, MENUID_LAST, CMF_NORMAL);
finally
SetErrorMode(OldMode);
end;
end;
这里指的是用户从菜单中选择的指令:
procedure InvokeCommand(const AContextMenu: IContextMenu; AVerb: PChar);
const
CMIC_MASK_SHIFT_DOWN = $10000000;
CMIC_MASK_CONTROL_DOWN = $20000000;
var
CI: TCMInvokeCommandInfoEx;
begin
FillChar(CI, SizeOf(TCMInvokeCommandInfoEx), 0);
CI.cbSize := SizeOf(TCMInvokeCommandInfo);
CI.hwnd := GetOwnerHandle(Owner);
CI.lpVerb := AVerb;
CI.nShow := SW_SHOWNORMAL;
// Ignore return value for InvokeCommand. Some shell extensions return errors
// from it even if the command worked.
try
AContextMenu.InvokeCommand(PCMInvokeCommandInfo(@CI)^)
except on E: Exception do
MessageDlg(Owner, E.Message, mtError, [mbOk], 0);
end;
end;
procedure InvokeCommand(const AContextMenu: IContextMenu; ACommandID: UINT);
begin
InvokeCommand(AContextMenu, MakeIntResource(Word(ACommandID)));
end;
现在,你可以使用GetMenuItemInfo功能,以获得帽子、比图等,但更为容易的是:
procedure ShowExplorerMenu(AForm: TForm; AMousePos: TPoint;
const APath: string; AFilenames: TStrings; );
var
ShellMenu: IContextMenu;
Menu: HMENU;
MenuID: LongInt;
begin
ShellMenu := GetExplorerMenu(AForm.Handle, APath, AFilenames);
Menu := GetExplorerHMenu(ShellMenu);
try
MenuID := TrackPopupMenu(Menu, TPM_LEFTALIGN or TPM_TOPALIGN or TPM_RETURNCMD,
AMousePos.X, AMousePos.Y, 0, AForm.Handle, nil);
InvokeCommand(ShellMenu, MenuID - MENUID_FIRST);
finally
DestroyMenu(Menu);
end;
end;
如果你真的想提取菜单/资本,把菜单添加到你自己的pop菜单中(我们使用工具箱,2000年,确实如此),那么,这里是你处理的其他大问题:
- The "Send To" menu, and any others that are built on-demand won t work unless you handle messages and pass them to the IContextMenu2/IContextMenu3 interfaces.
- Menu bitmaps are in a couple of different formats. Delphi doesn t handle Vista high-color ones without coaxing, and the older ones are blended onto the background color using an XOR.
- Some menu items are owner-drawn, so you have to capture paint messages and have them paint to your own canvas.
- Hint strings won t work unless you manually query for them.
- You ll need to manage the lifetime of the IContextMenu and HMENU and only release them once the popup menu has been closed.