Solved

IContextMenu with multiple items

Posted on 1998-11-09
5
265 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
TServerSocket - file via sendbuf or Text via sendtext ? 1 67
Convert a string into a TDateTime 5 65
Delphi problems to abort a printjob 9 25
DBCtrlGrid, Delphi, Scroll 8 39
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

808 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