• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 362
  • Last Modified:

Context Menu Item

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?
0
adm_adamlee
Asked:
adm_adamlee
  • 2
1 Solution
 
ThievingSixCommented:
Try ShowModal instead of just show. Then in on a button change the ModalResult as mrOK.
0
 
adm_adamleeAuthor 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
0
 
ThievingSixCommented:
Kind of interesting that its the same answer I provided.
0
 
MerijnBSr. Software EngineerCommented:
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 :)
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

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

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now