Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

IContextMenu with multiple items

Posted on 1998-11-09
5
Medium Priority
?
277 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

704 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