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
Member

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

 
Hint: For improved responsiveness ensure Javascript is enabled and choose 'Normal' from the Layout dropdown and hit 'Update'.
You must Sign In to use this message board.
Search this forum  
    Spacing  Layout  Per page   
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 
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 
AnswerRe: Some tweaks (drives, files and folders, desktop items)memberJpmon131 May '11 - 4:00 
QuestionRe: Some tweaks (drives, files and folders, desktop items)membermatthew4392 Aug '11 - 8:58 
Generalnot good on win 7memberthanhl0v328 Feb '10 - 17:27 
GeneralGreat!memberJose M. Menendez Poó27 May '08 - 10:19 
GeneralGreat, but needs a bit tweakingmemberZeroXX24 Mar '08 - 12:08 
QuestionRe: Great, but needs a bit tweakingmemberseguso20 Aug '09 - 7:48 
AnswerRe: Great, but needs a bit tweakingmemberMANSATAN29 Apr '10 - 11:35 
GeneralShort and SweetmemberThe_Mega_ZZTer10 Dec '07 - 16:39 

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

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