Click here to Skip to main content
Click here to Skip to main content

Explorer Shell Context Menu

By , 27 May 2008
 
Screenshot -

Introduction

I am currently working on an Advanced text editor, and I was looking for a way to implement the Window's shell context menu in my code. I came across Andreas Johansson's WebLog which provided me with the answer. He took some of the code that Steven Roebert created and placed it in one file for ease of use. His code had several errors that were easily corrected, and now I am posting the finished product.

Using the Code

The code is pretty straightforward to use:

  1. Add the ShellContextMenu.cs file to your project.
  2. Create a new instance of the ShellContextMenu class.
  3. Call the ShowContextMenu method with the proper arguments.
    1. FileInfo/DirectoryInfo Array - A list of files/directories that need the Context Menu
    2. Point - Point to Display Context Menu
    // Sample code

    ShellContextMenu ctxMnu = new ShellContextMenu();
    FileInfo[] arrFI = new FileInfo[1];
    arrFI[0] = new FileInfo(this.treeMain.SelectedNode.Tag.ToString());
    ctxMnu.ShowContextMenu(arrFI, this.PointToScreen(new Point(e.X, e.Y)));

History

  • 12/10/07 - Created article
  • 27/05/08 - Cleaned code a bit

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Jpmon1
Software Developer Halliburton
United States United States

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
GeneralMy vote of 5memberMazen el Senih24-Sep-12 6:56 
General"Send to" menu visible but doesn't execute.memberMember 45122121-Dec-10 5:22 
AnswerRe: "Send to" menu visible but doesn't execute.memberiprog223-Jul-12 0:04 
GeneralAdd my menu to shell context menumemberJen8915-Nov-10 3:28 
AnswerRe: Add my menu to shell context menu [modified]memberiprog222-Jul-12 23:59 
GeneralRe: Add my menu to shell context menumemberMember 1016658923-Jul-13 22:41 
GeneralDoes not work on 64 bitmemberuhax10119-Jun-10 1:55 
GeneralRe: Does not work on 64 bitmemberMember 45122121-Dec-10 1:55 
AnswerSome tweaks (drives, files and folders, desktop items)memberMANSATAN29-Apr-10 11:28 
QuestionRe: Some tweaks (drives, files and folders, desktop items)memberMember 795200327-May-11 19:18 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

| Advertise | Privacy | Mobile
Web02 | 2.6.1309018 | Last Updated 27 May 2008
Article Copyright 2007 by Jpmon1
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid