Solved

IContextMenu with multiple items

Posted on 1998-11-09
5
251 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

762 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now