Click here to Skip to main content
Licence CPOL
First Posted 10 Dec 2007
Views 38,768
Downloads 1,756
Bookmarked 58 times

Explorer Shell Context Menu

By | 27 May 2008 | Article
Add the Windows Explorer Shell Context Menu to your application
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

Jon Likes to Code.
learnto.seekdeepwithin.com
seekdeepwithin.com

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

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Layout  Per page   
  Refresh
General"Send to" menu visible but doesn't execute. PinmemberMember 4512215:22 21 Dec '10  
GeneralAdd my menu to shell context menu PinmemberJen893:28 15 Nov '10  
GeneralDoes not work on 64 bit Pinmemberuhax1011:55 19 Jun '10  
GeneralRe: Does not work on 64 bit PinmemberMember 4512211:55 21 Dec '10  
AnswerSome tweaks (drives, files and folders, desktop items) PinmemberMANSATAN11:28 29 Apr '10  
QuestionRe: Some tweaks (drives, files and folders, desktop items) PinmemberMember 795200319:18 27 May '11  
AnswerRe: Some tweaks (drives, files and folders, desktop items) PinmemberJpmon14:00 31 May '11  
QuestionRe: Some tweaks (drives, files and folders, desktop items) Pinmembermatthew4398:58 2 Aug '11  
Generalnot good on win 7 Pinmemberthanhl0v317:27 28 Feb '10  
GeneralGreat! PinmemberJose M. Menendez Poó10:19 27 May '08  
Good to know this trick.
Thanks!
 
Jm

GeneralGreat, but needs a bit tweaking PinmemberZeroXX12:08 24 Mar '08  
QuestionRe: Great, but needs a bit tweaking Pinmemberseguso7:48 20 Aug '09  
AnswerRe: Great, but needs a bit tweaking PinmemberMANSATAN11:35 29 Apr '10  
GeneralShort and Sweet PinmemberThe_Mega_ZZTer16:39 10 Dec '07  

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

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

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