nesco, попробовал тут контекстное меню проводника сделать, но иконок нет почемуто? Да и рунтайм при выборе, хотя собирается без ошибок (скормил всё необходимое).
Add(MainForm,2953706,266,154) { Point(Handle) } Add(InlineCode,2747598,266,203) { WorkPoints=#12:doCreateMenu| DataPoints=#4:hwnd| Code=#15:unit HiAsmUnit;|0:|9:interface|0:|41:uses Windows, Kol, Share, Debug, ActiveX;|0:|5: type|0:|21: PSTRRet = ^TStrRet;|24: {$EXTERNALSYM _STRRET}|18: _STRRET = record|78: uType: UINT; { One of the STRRET_* values }|20: case Integer of|95: 0: (pOleStr: LPWSTR); { must be freed by caller of GetDisplayNameOf }|60: 1: (pStr: LPSTR); { NOT USED }|79: 2: (uOffset: UINT); { Offset into SHITEMID (ANSI) }|69: 3: (cStr: array[0..MAX_PATH-1] of Char); { Buffer to fill in }|8: end;|20: TStrRet = _STRRET;|23: {$EXTERNALSYM STRRET}|20: STRRET = _STRRET; |2: |25: PSHItemID = ^TSHItemID;|27: TSHItemID = packed record|78: cb: Word; { Size of the ID (including cb itself) }|71: abID: array[0..0] of Byte; { The item ID (variable length) }|6: end;|0:|29: PItemIDList = ^TItemIDList;|22: TItemIDList = record|21: mkid: TSHItemID;|6: end;|0:|47: PCMInvokeCommandInfo = ^TCMInvokeCommandInfo;|37: {$EXTERNALSYM _CMINVOKECOMMANDINFO}|31: _CMINVOKECOMMANDINFO = record|65: cbSize: DWORD; { must be sizeof(CMINVOKECOMMANDINFO) }|60: fMask: DWORD; { any combination of CMIC_MASK_* }|72: hwnd: HWND; { might be NULL (indicating no owner window) }|74: lpVerb: LPCSTR; { either a string of MAKEINTRESOURCE(idOffset) }|69: lpParameters: LPCSTR; { might be NULL (indicating no parameter) }|78: lpDirectory: LPCSTR; { might be NULL (indicating no specific directory) }|68: nShow: Integer; { one of SW_ values for ShowWindow() API }|20: dwHotKey: DWORD;|19: hIcon: THandle;|6: end;|0:|46: TCMInvokeCommandInfo = _CMINVOKECOMMANDINFO;|36: {$EXTERNALSYM CMINVOKECOMMANDINFO}|45: CMINVOKECOMMANDINFO = _CMINVOKECOMMANDINFO;|0:|51: PCMInvokeCommandInfoEx = ^TCMInvokeCommandInfoEx;|39: {$EXTERNALSYM _CMInvokeCommandInfoEx}|33: _CMInvokeCommandInfoEx = record|66: cbSize: DWORD; { must be sizeof(CMINVOKECOMMANDINFOEX) }|59: fMask: DWORD; { any combination of CMIC_MASK_* }|71: hwnd: HWND; { might be NULL (indicating no owner window) }|73: lpVerb: LPCSTR; { either a string or MAKEINTRESOURCE(idOffset) }|68: lpParameters: LPCSTR;{ might be NULL (indicating no parameter) }|77: lpDirectory: LPCSTR; { might be NULL (indicating no specific directory) }|67: nShow: Integer; { one of SW_ values for ShowWindow() API }|20: dwHotKey: DWORD;|19: hIcon: THandle;|69: lpTitle: LPCSTR; { For CreateProcess-StartupInfo.lpTitle }|71: lpVerbW: LPCWSTR; { Unicode verb (for those who can use it) }|77: lpParametersW: LPCWSTR; { Unicode parameters (for those who can use it) }|76: lpDirectoryW: LPCWSTR; { Unicode directory (for those who can use it) }|72: lpTitleW: LPCWSTR; { Unicode title (for those who can use it) }|56: ptInvoke: TPoint; { Point where it's invoked }|6: end;|52: TCMInvokeCommandInfoEx = _CMINVOKECOMMANDINFOEX;|40: {$EXTERNALSYM CMINVOKECOMMANDINFOEX}|51: CMINVOKECOMMANDINFOEX = _CMINVOKECOMMANDINFOEX;|0:|31: IMalloc = interface(IUnknown)|46: ['{00000002-0000-0000-C000-000000000046}']|50: function Alloc(cb: Longint): Pointer; stdcall;|65: function Realloc(pv: Pointer; cb: Longint): Pointer; stdcall;|41: procedure Free(pv: Pointer); stdcall;|52: function GetSize(pv: Pointer): Longint; stdcall;|53: function DidAlloc(pv: Pointer): Integer; stdcall;|36: procedure HeapMinimize; stdcall;|6: end;|0:|35: IEnumIDList = interface(IUnknown)|46: ['{000214F2-0000-0000-C000-000000000046}']|54: function Next(celt: ULONG; out rgelt: PItemIDList;|49: var pceltFetched: ULONG): HResult; stdcall;|49: function Skip(celt: ULONG): HResult; stdcall;|37: function Reset: HResult; stdcall;|62: function Clone(out ppenum: IEnumIDList): HResult; stdcall;|6: end;|2: |36: IShellFolder = interface(IUnknown)|46: ['{000214E6-0000-0000-C000-000000000046}']|46: function ParseDisplayName(hwndOwner: HWND;|74: pbcReserved: Pointer; lpszDisplayName: POLESTR; out pchEaten: ULONG;|73: out ppidl: PItemIDList; var dwAttributes: ULONG): HResult; stdcall;|58: function EnumObjects(hwndOwner: HWND; grfFlags: DWORD;|53: out EnumIDList: IEnumIDList): HResult; stdcall;|66: function BindToObject(pidl: PItemIDList; pbcReserved: Pointer;|54: const riid: TIID; out ppvOut): HResult; stdcall;|67: function BindToStorage(pidl: PItemIDList; pbcReserved: Pointer;|54: const riid: TIID; out ppvObj): HResult; stdcall;|39: function CompareIDs(lParam: LPARAM;|51: pidl1, pidl2: PItemIDList): HResult; stdcall;|64: function CreateViewObject(hwndOwner: HWND; const riid: TIID;|36: out ppvOut): HResult; stdcall;|64: function GetAttributesOf(cidl: UINT; var apidl: PItemIDList;|44: var rgfInOut: UINT): HResult; stdcall;|79: function GetUIObjectOf(hwndOwner: HWND; cidl: UINT; var apidl: PItemIDList;|74: const riid: TIID; prgfInOut: Pointer; out ppvOut): HResult; stdcall;|63: function GetDisplayNameOf(pidl: PItemIDList; uFlags: DWORD;|45: var lpName: TStrRet): HResult; stdcall;|77: function SetNameOf(hwndOwner: HWND; pidl: PItemIDList; lpszName: POLEStr;|66: uFlags: DWORD; var ppidlOut: PItemIDList): HResult; stdcall;|9: end; |0:|36: IContextMenu = interface(IUnknown)|46: ['{000214E4-0000-0000-C000-000000000046}']|42: function QueryContextMenu(Menu: HMENU;|72: indexMenu, idCmdFirst, idCmdLast, uFlags: UINT): HResult; stdcall;|78: function InvokeCommand(var lpici: TCMInvokeCommandInfo): HResult; stdcall;|68: function GetCommandString(idCmd, uType: UINT; pwReserved: PUINT;|54: pszName: LPSTR; cchMax: UINT): HResult; stdcall;|6: end;|0:|41: IContextMenu2 = interface(IContextMenu)|46: ['{000214F4-0000-0000-C000-000000000046}']|82: function HandleMenuMsg(uMsg: UINT; WParam, LParam: Integer): HResult; stdcall;|7: end; |4: |81://------------------------------------------------------------------------------ |29: THiAsmClass = class(TDebug)|9: private|0:|8: public|36: hwnd:THI_Event; //âåðõíÿÿ òî÷êà|57: procedure doCreateMenu(var _Data:TData; Index:word);|5: |6: end;|82://------------------------------------------------------------------------------ |14:implementation|0:|6:const |0:|103: IID_IShellFolder: TGUID = (D1:$000214E6; D2:$0000; D3:$0000; D4:($C0,$00,$00,$00,$00,$00,$00,$46)); |101: IID_IContextMenu: TGUID = (D1:$000214E4; D2:$0000; D3:$0000; D4:($C0,$00,$00,$00,$00,$00,$00,$46));|101: IID_IContextMenu2: TGUID = (D1:$000214F4; D2:$0000; D3:$0000; D4:($C0,$00,$00,$00,$00,$00,$00,$46));|101: IID_IEnumIDList: TGUID = (D1:$000214F2; D2:$0000; D3:$0000; D4:($C0,$00,$00,$00,$00,$00,$00,$46));|0:|67:// SID_IShellFolder = '{000214E6-0000-0000-C000-000000000046}';|68:// SID_IContextMenu = '{000214E4-0000-0000-C000-000000000046}'; |68:// SID_IContextMenu2 = '{000214F4-0000-0000-C000-000000000046}'; |68:// SID_IEnumIDList = '{000214F2-0000-0000-C000-000000000046}'; |0:|62:function SHGetDesktopFolder(var ppshf: IShellFolder): HResult;|59: stdcall; external 'shell32' name 'SHGetDesktopFolder';|5: |50:function SHGetMalloc(ppMalloc: IMalloc): HResult; |57: stdcall; external 'shell32' name 'SHGetMalloc'; |0:|67:procedure ShowContextMenu(HWND: hWnd; Path: String; x, y: Integer);|3:var|24: FullPath: PWideChar;|40: Folder, DesktopFolder: IShellFolder;|31: ContextMenu: IContextMenu2;|20: Malloc: IMalloc;|22: hPopupMenu: HMENU;|31: pLastId, pidl: PItemIDList;|34: pchEaten, dwAttributes: ULONG;|16: temp: SHORT;|17: offset: Word;|19: nCmd: LongBool;|13: p: PChar;|29: ici: CMINVOKECOMMANDINFO;|5:begin|27: GetMem(FullPath, 1024);|47: StringToWideChar(Path, FullPath, MAX_PATH);|38: SHGetDesktopFolder(DesktopFolder);|86: DesktopFolder.ParseDisplayName(HWND, nil, FullPath, pchEaten, pidl, dwAttributes);|23: if pidl <> nil then|9: begin|20: pLastId := pidl;|17: while True do|9: begin|30: offset := pLastId.mkid.cb;|26: p := Pointer(pLastId);|20: p := @p[offset];|21: temp := word(p^);|27: if temp = 0 then Break;|30: pLastId := PItemIDList(p);|8: end;|28: temp := pLastId.mkid.cb;|25: pLastId.mkid.cb := 0;|68: DesktopFolder.BindToObject(pidl, nil, IID_IShellFolder, Folder);|28: pLastId.mkid.cb := temp;|79: Folder.GetUIObjectOf(HWND, 1, pLastId, IID_IContextMenu, nil, ContextMenu);|34: hPopupMenu := CreatePopupMenu;|64:// ContextMenu.QueryContextMenu(hPopupMenu, 0, 1, $07FFF, 0);|67: ContextMenu.QueryContextMenu(hPopupMenu, 0, 1, $07FFF, 16); |38: nCmd := TrackPopupMenu(hPopupMenu,|72: TPM_LEFTALIGN or TPM_LEFTBUTTON or TPM_RIGHTBUTTON or TPM_RETURNCMD,|24: x, y, 0, hWnd, nil);|16: if nCmd then|9: begin|50: ZeroMemory(@ici, sizeof(CMINVOKECOMMANDINFO));|46: ici.cbSize := sizeof(CMINVOKECOMMANDINFO);|21: ici.hwnd := hWnd;|48: ici.lpVerb := MAKEINTRESOURCE(Word(nCmd)-1);|31: ici.nShow := SW_SHOWNORMAL;|35: ContextMenu.InvokeCommand(ici);|8: end;|24: SHGetMalloc(Malloc);|22: Malloc.Free(pidl);|8: end;|22: FreeMem(FullPath);|4:end;|0:|0:|35:procedure THiAsmClass.doCreateMenu;|18: var h : integer; |5:begin|30: h := ReadInteger(_Data,hwnd);|40: ShowContextMenu (h,'C:\Demo\', 10, 10);|4:end;|0:|4:end.|2: | link(hwnd,2953706:Handle,[]) } Add(Button,9041049,210,203) { Left=20 Top=20 link(onClick,2747598:doCreateMenu,[]) }
------------ Дoбавленo в 09.38:
Вот флаги на всякий случай
|