Solved

IContextMenu with multiple items

Posted on 1998-11-09
5
263 Views
Last Modified: 2010-04-03
Can anybody give me a Delphi 3 or Delphi 4 sample which uses IShellFolder.GetUIObjectOf to get the context menu for MULTIPLE OBJECTS.  I can get it working fine for ONE object, but when I try to get multiple objects I get a GPF.

The online help says that the 3rd parameter for GetUIObjectOf (apidl) is a "pointer to an array of pointers to ITEMIDLIST structures, each of which uniquely identifies a file object or subfolder relative to the parent folder. Each item identifier list must contain exactly one SHITEMID structure followed by a terminating zero."

I've tried several things, but using a "pointer to an array of pointers" seems to cause the most problems!  As I said, I can get it to work fine for a single object relative to the IShellFolder, but if I try to get the combined context menu for 2/more items, I get Access Violations, etc.

Any help much appreciated!
JB

P.S.  My functions for manipulating PIDLs could be half the problem, although I do other things with PIDLs & IShellFolders which *seem* to work fine.
0
Comment
Question by:JimBob091197
  • 2
  • 2
5 Comments
 
LVL 20

Expert Comment

by:Madshi
ID: 1346312
JimBob,

sorry, have no GetUIObjectOf sample. But here comes my "ConcatPidl" function. Perhaps it help you to check whether your "pidl" functions are correct. Note, that you have to use IMalloc.Alloc/Free instead of using Delphi functions...

function ConcatPidl(pidl1,pidl2: PItemIDList) : PItemIDList;
var ma    : IMalloc;
    c1,c2 : cardinal;
    pidl3 : PItemIDList;
begin
  result:=nil;
  if ((pidl1=nil) and (pidl2=nil)) or (SHGetMalloc(ma)<>NOERROR) then exit;
  if pidl1=nil then begin result:=CopyPidl(pidl2); exit end;
  if pidl2=nil then begin result:=CopyPidl(pidl1); exit end;
  pidl3:=pidl1; c1:=0;
  while pidl3^.mkid.cb<>0 do begin
    inc(c1,pidl3^.mkid.cb);
    pidl3:=pointer(cardinal(pidl3)+pidl3^.mkid.cb);
  end;
  pidl3:=pidl2; c2:=2;
  while pidl3^.mkid.cb<>0 do begin
    inc(c2,pidl3^.mkid.cb);
    pidl3:=pointer(cardinal(pidl3)+pidl3^.mkid.cb);
  end;
  result:=ma.Alloc(c1+c2);
  if result<>nil then begin
    Move(pidl1^,                 result     ^,c1);
    Move(pidl2^,pointer(cardinal(result)+c1)^,c2);
  end;
end;

Regards, Madshi.
0
 
LVL 5

Author Comment

by:JimBob091197
ID: 1346313
Hi Madshi

Ronit pointed me to a sample program in my question "File Object's Properties Dialog".

This sample program helped me solve 3 of the 5 questions I asked yesterday: "File Object's Properties Dialog", "IContextMenu's Send To menu" and "IContextMenu with multiple items".

Ronit has answered my first question ("File Object's...") and when she (I think, else he) reads my comment there, she will answer my other 2 questions too.

Thanks,
Dave

P.S. My PIDL functions were OK.

0
 
LVL 5

Accepted Solution

by:
ronit051397 earned 200 total points
ID: 1346314
JB, I am glad it helped you.
For the others, a full example can be downloaded from
http://www.aye.net/~bstowers/delphi/examples/itemprop.html 
I have checked it briefly on NT4 and it's working. JB checked it on Win98.

Bye
Ronit,
0
 
LVL 5

Author Comment

by:JimBob091197
ID: 1346315
Thanks, Ronit.  You can answer the question "http://www.experts-exchange.com/topics/comp/lang/delphi/Q.10096628" too, as this question is related.

-Dave

0
 
LVL 5

Expert Comment

by:ronit051397
ID: 1346316
Hi, I think I have got enough points from you - 2 questions, so the third will be too much.

Anyway, Thanks for the offer and good luck
Ronit,
0

Featured Post

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question