We help IT Professionals succeed at work.

Context Menu Item

adm_adamlee
adm_adamlee asked
on
Medium Priority
373 Views
Last Modified: 2012-05-06
I downloaded CustomContextMenu.zip from net and succuessfully created my own context menu items, I want to make an application that will do as WinRAR, in windows explorer, right click zip or RAR file, there will be menu items (extract here, extract to xxx etc...), right click all other files, there will be menu items (adding files, adding to xxx etc...).

from this abstract class, we can create our own context menu items, however, I have a problem, that is I don't know how to show a form when clicking one of the context menu items.

from the zip, DLL is the context menu item handler, in CopyPathMain.pas, we can define menu item text, and command, I add a new form, add below codes:

use unit2;
....

with tform2.create(nil) do begin
  try
  show;
  finally;
    free;
   end;
end;

but it does not work, the form2 just appears once and then disappears.

for WinRAR, when clicking 'Adding files', there will be form for the users to look and check, then press OK to process, that's what I want.

http://subsimple.com/download/CustomContextMenu.zip

andybody help?
Comment
Watch Question

Developer
CERTIFIED EXPERT
Commented:
Try ShowModal instead of just show. Then in on a button change the ModalResult as mrOK.

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

Commented:
I got the point, below codes works:

with tform2.create(nil) do begin
  try
  showModal;
  finally;
    free;
   end;
end;

but we can not use application.terminate
ThievingSixDeveloper
CERTIFIED EXPERT

Commented:
Kind of interesting that its the same answer I provided.
MerijnBSr. Software Engineer
CERTIFIED EXPERT

Commented:
It's always a good idea to don't these kind of things directly from your context menu handler DLL. In stead, launch an external program which does the actual work (like showing a form or time consuming things).

Two reasons:
- if you take long time you'll hog up the calling process (probably explorer.exe).
- if you crash you probably take the calling process with you.

KISS is what you want to do here: http://en.wikipedia.org/wiki/KISS_principle :)
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.