Click here to Skip to main content
Licence CPOL
First Posted 10 Dec 2007
Views 36,265
Downloads 1,400
Bookmarked 57 times

Explorer Shell Context Menu

By Jpmon1 | 27 May 2008
Add the Windows Explorer Shell Context Menu to your application
1 vote, 6.7%
1
1 vote, 6.7%
2
2 votes, 13.3%
3
1 vote, 6.7%
4
10 votes, 66.7%
5
4.35/5 - 15 votes
1 removed
μ 3.85, σa 2.31 [?]
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 4512216:22 21 Dec '10  
GeneralAdd my menu to shell context menu PinmemberJen894:28 15 Nov '10  
GeneralDoes not work on 64 bit Pinmemberuhax1012:55 19 Jun '10  
GeneralRe: Does not work on 64 bit PinmemberMember 4512212:55 21 Dec '10  
AnswerSome tweaks (drives, files and folders, desktop items) PinmemberMANSATAN12:28 29 Apr '10  
QuestionRe: Some tweaks (drives, files and folders, desktop items) PinmemberMember 795200320:18 27 May '11  
AnswerRe: Some tweaks (drives, files and folders, desktop items) PinmemberJpmon15:00 31 May '11  
QuestionRe: Some tweaks (drives, files and folders, desktop items) Pinmembermatthew4399:58 2 Aug '11  
Generalnot good on win 7 Pinmemberthanhl0v318:27 28 Feb '10  
GeneralGreat! PinmemberJose M. Menendez Poó11:19 27 May '08  
GeneralGreat, but needs a bit tweaking PinmemberZeroXX13:08 24 Mar '08  
QuestionRe: Great, but needs a bit tweaking Pinmemberseguso8:48 20 Aug '09  
AnswerRe: Great, but needs a bit tweaking PinmemberMANSATAN12:35 29 Apr '10  
GeneralShort and Sweet PinmemberThe_Mega_ZZTer17:39 10 Dec '07  
I've been looking for articles relating to shell folder things like this, and this is part of what I'm looking for. Very simple implementation and execution that covers what I would need it to do nicely.
 
I was going to use a more thorough source code sample for my research into mimicking a Vista Explorer-esque interface in .NET, but your code should be a nice and simple alternative for me to look at as well! Thanks!
 
I was disappointed when I saw you haven't written any other articles. I'll be sure to check them out when you do. Smile | :)

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
Web02 | 2.5.120210.1 | Last Updated 27 May 2008
Article Copyright 2007 by Jpmon1
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid