Вверх ↑
Разработчик
Ответов: 26258
Рейтинг: 2140
#1: 2009-11-02 14:47:50 ЛС | профиль | цитата
andrestudio, мура у тебя на Delphi получилась, также выдает ошибку. Вот тебе подшаманеный твой IC, который не дает ошибку, но с иконками я не могу поянть (да и не нашел я), откуда брать ее Handle, хотя, маску отображения я поставил



Add(MainForm,162249,378,168)
{
 Point(Handle)
}
Add(InlineCode,2747598,378,217)
{
 WorkPoints=#12:doCreateMenu|
 DataPoints=#4:hwnd|
 Code=#15:unit HiAsmUnit;|0:|9:interface|0:|41:uses Windows, Kol, Share, Debug, ActiveX;|0:|5:const|29:  CMIC_MASK_ICON = $00000010;|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; //aa?oiyy oi?ea|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|22:  FullPath: PWideChar;|38:  Folder, DesktopFolder: IShellFolder;|29:  ContextMenu: IContextMenu2;|18:  Malloc: IMalloc;|20:  hPopupMenu: HMENU;|29:  pLastId, pidl: PItemIDList;|32:  pchEaten, dwAttributes: ULONG;|14:  temp: SHORT;|15:  offset: Word;|17:  nCmd: LongBool;|11:  p: PChar;|14:  pos: TPoint;|27:  ici: CMINVOKECOMMANDINFO;|5:begin|26:   GetMem(FullPath, 1024);|3:TRY|45:  StringToWideChar(Path, FullPath, MAX_PATH);|36:  SHGetDesktopFolder(DesktopFolder);|84:  DesktopFolder.ParseDisplayName(HWND, nil, FullPath, pchEaten, pidl, dwAttributes);|26:  if pidl = nil then exit;|0:|18:  pLastId := pidl;|0:|15:  while True do|7:  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);|6:  end;|0:|32:  hPopupMenu := CreatePopupMenu;|3:TRY|26:  temp := pLastId.mkid.cb;|23:  pLastId.mkid.cb := 0;|66:  DesktopFolder.BindToObject(pidl, nil, IID_IShellFolder, Folder);|26:  pLastId.mkid.cb := temp;|77:  Folder.GetUIObjectOf(HWND, 1, pLastId, IID_IContextMenu, nil, ContextMenu);|60:  ContextMenu.QueryContextMenu(hPopupMenu, 0, 1, $07FFF, 0);|67://  ContextMenu.QueryContextMenu(hPopupMenu, 0, 1, $07FFF, 16);    |20:  GetCursorPos(pos);|28:  SetForegroundWindow(hWnd);|0:|134:  nCmd := TrackPopupMenu(hPopupMenu, TPM_LEFTALIGN or TPM_LEFTBUTTON or TPM_RIGHTBUTTON or TPM_RETURNCMD, pos.x, pos.y, 0, hWnd, nil);|0:|14:  if nCmd then|7:  begin|51:    FillChar(ici, sizeof(CMINVOKECOMMANDINFO), #0);|46:    ici.cbSize := sizeof(CMINVOKECOMMANDINFO);|33:    ici.fMask := CMIC_MASK_ICON; |21:    ici.hwnd := hWnd;|48:    ici.lpVerb := MAKEINTRESOURCE(Word(nCmd)-1);|31:    ici.nShow := SW_SHOWNORMAL;|19:    ici.hIcon := 0;|35:    ContextMenu.InvokeCommand(ici);|6:  end;|1: |24://  SHGetMalloc(Malloc);|22://  Malloc.Free(pidl);|7:FINALLY|26:  DestroyMenu(hPopupMenu);|6:END;  |7:FINALLY|20:  FreeMem(FullPath);|8:END;    |4:end;|0:|0:|35:procedure THiAsmClass.doCreateMenu;|18: var h : integer; |5:begin|30: h := ReadInteger(_Data,hwnd);|35: ShowContextMenu (h,'C:\', 10, 10);|4:end;|0:|4:end.|2:  |
 link(hwnd,162249:Handle,[])
}
Add(Button,9041049,322,217)
{
 Left=20
 Top=20
 link(onClick,2747598:doCreateMenu,[])
}

карма: 22

2
Голосовали:andrestudio, a0005d26f