Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

IContextMenu with multiple items

Posted on 1998-11-09
5
Medium Priority
?
280 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 800 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

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 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…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…

972 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