Adding a context menu item to windows explorer - c#

I've been searching for days about this, but haven't found anything.
I am trying to find out how I can add a context menu item to the windows explorer. I do not want it for specific filetypes, BUT I want it to appear on everything inside a specific path.
For example, I want right-click menus of anything inside "C:\folder" to contain this item, but it shouldn't appear outside this folder...
Is that possible?
Any help will be really appreciated!
Thanks in advance,
John.

The normal way this is achieved is to add it to the Registry under:
HKEY_LOCAL_MACHINE/Software/Classes/Folder/Shell
However in your specific case you want to do some preprocessing before it is displayed (eg is it in the specified directory) which wouldn't work with a simple registry alteration.
I think there is a way to force you way into any operation and add a hook to it. I'm talking about old school knowledge now though and I cannot think what the technology would be called. I think its how you would have, for example, forced your way into the rendering engine to put custom skins on normal explorer windows or inject an extra button into the title bar of apps like you used to see back in the day.
It just occurred to me that adding a button to the windows title bar might have given a search starting point, I found this article which refers to subclassing windows components and injecting your own behaviour. I think that is what I'm talking about above:
http://www.codeproject.com/KB/wtl/titlebar.aspx
Hope this gives you a new direction to search in.

Related

Windows 10 File Browser popup menu showing New items

Using:
Visual Studio 2017
Windows Form
C#
I know how to create a Popup menu displaying items that I have added with code to a native WinForm ContextMenuStrip control.
For example:
My coded Popup menu
What I am looking for and trying to achieve and I have not found so far is how to populate a ContextMenuStrip or any alternative control with the Items that show up when you right click on a blank space on File Explorer and select New and displays a list of the Items you can create base on what you have installed on your computer.
For example:
File Explorer Popup Menu > New
I have looked at many suggestion on different sites but they all show what I already know in how to add items manually and none explain how to add the Items that show up in the File Explorer New sub menu.
Could anyone tell me if this is even possible and/or point me to the right place.
Regards,
You're describing the problem as if it were some programming task, so most probably, it's not the thing you expect to see. Adding items to that menu is more of a problem of configuration of the almighty 'explorer.exe'..
Please see here and read where to place item templates and how to register "file classes" for them in the registry.
I don't like answers like this that just drop a link to other resource, but it's not reasonable to copy&paste&redact it all not knowing if it's what you really want..
Also, note that if you see your desktop, then 'explorer.exe' is already running, and editing its configuration in the registry probably won't take any effect until this process is restarted. Typically you get advices like in that article above:
To have this change take effect, you need to restart your PC, not just sign out and back in.
But that's not true. Just kill explorer.exe via task manager, and then start it back again. No need to reboot.

Trying to make a Visual Studio 2015 Add-In: SDK, API.... (Reagrding ribbon or whatever its called)

I have been trying to get my head around the SDK API for visual studio for a while now. The problem is I know what I want/need to do. However I can not find a code example or API documentation anywhere that allows me to do what I want :(
I know its possible just I cant find documentation to show how.
I want to add another sidebar ribbon for all open files similar to how the breakpoint works (And many test add-ins for VS, NCrunch comes to mind...) that is blank as standard but when clicked allows some logic to be run to add a comment on that line.
Once added a Icon will be then displayed on that line allowing you to click the icon to view/edit the left comment. (The storage of this etc. is not a problem with the implementation I am doing) I just really need to know how to tell the API to add a new ribbon/side thing and plumb in the required logic :/
If this isn't possible I also had the idea of highlighting the word and again a icon popping up but that seems even more annoying to implement hence why I chose the side option if it is at all possible :/
Thanks in Advance to anyone who helps :D
The "sidebar ribbon" is called an editor margin. See Editor Extension Points.
Implement an IWpfTextViewMargin interface to define a margin. You must
also implement the IWpfTextViewMarginProvider interface to create the
margin.

Use 3rd party context menu (for Windows Explorer) within a C# application?

Unlike others who wish to add items to the Windows Explorer, I want to display a context menu within my application. Now you may be thinking, the class you are looking for is ContextMenu. Let me show you what I am interested in doing. Please excuse the small images...
Here is what I currently have:
This is what I would like it to be:
Let's get the assumptions out of the way. I've already detected that the user has TortoiseSVN installed and the item they are selecting is under source control.
My research thus far:
Retrieving context menus - This is very useful. This is a c# library for the Windows Explorer (which can retrieve the context menu for a particular folder/file). However, even when testing out the example, it does not retrieve the TortoiseSVN options.
Another context menu retrieval - Almost identical to the previous link (C# code again). Gets the Windows Explorer context menu minus the TortoiseSVN options.
Process to add context menu - I have just started reading these in-depth posts. The answer may be within this text but it is going to take me some time to get through it. If I have any luck with these, I will post back an answer.
User appears to be able to accomplish this - This appears to be a email group that deals with SVN development. Why post it here? Perhaps to prove that this can be done. To quote: "I'm playing with the TSVN shell context menu. I'm using the IContextMenu.QueryContextMenu (C++ code) method to access TSVN shell context menu and then I'm browsing trough the returned menu."
All in all, this seems like it should be a fairly straight forward thing to do and I am just missing one step. Any and all suggestions are welcome. Thanks!
Edits: Trying to make better use of tags and a more focused title
Hopefully the following will get you started
Showing windows (file/directory) context menu in c# winforms
application
The above link contains the following answer that shows something similar to what you want
How do you show the Windows Explorer context menu from a C#
application?
Rather than trying to pull from the Windows Explorer, ultimately I re-implemented the ContextMenu myself. Adding in the direct calls to TortoiseSVN (as previously mentioned). Not the super elegant solution I wanted but it worked of course!
I will note that user oefe pointed out that the main issue could have been due to x86 vs x64 (TortoiseSVN was installed as x64 on my development machine). Other users may want to look into that if they try to accomplish a similar task.

Building a Windows Explorer Extension

I'm looking to build an application that will rely on adding menu extensions to the menu that appears when one right clicks a file or folder. I've heard that you can build it in Python, here are the resources that I am currently looking at:
http://docs.python.org/extending/extending.html
http://docs.python.org/extending/windows.html#building-on-windows
However I'm not quite sure if I'm even looking in the right direction for this kind of stuff. What should I be searching for, and is it possible to build this kind of thing in Python or will I have to learn C#/.NET?
Thanks!
Edit: Looks like these things are called context menus and involves adding entries to the registry in order to associate applications with certain file types. In that case, should I have my application listening in the background for actions from the entry? Also if you know how to do the same thing in OS X or have some nifty cross-platform thing for this, that would be really nifty!
Here is a sample code at Sample code .
Another way is to manipulate the Registry by using the Windows Explorer tool, like the Open with option. Use it to associate a file extension with opening an executable, basically. However, this technique does not add a menu item into Windows Explorer. But it's easier.

Windows Forms Browser Skeleton (C#/.NET)

I was wondering if anyone knows of an existing sample or an approach to achieve the desired functionality.
Basically, what I'm looking for is a web browser like skeleton. The idea is that the main screen of my application is shown in the left tab. This tab can never be closed. On this screen is an overview of various application components such as activities, events, contacts, etc.
When the user clicks on a specific contact/event/activity a new tab is created and auto-focused. The user can view and edit the information. When they are done they can close the tab.
The ability to have multiple tabs open is important.
Also, keyboard shortcuts to easily navigate between tabs would be great, but not absolutely essential at this point.
Note: I don't need to access any web content.
Really what I'm looking for, at least what I think I'm looking for, is a shell of a modern web browser. Does something like this exist? Is there a good approach to building such an application?
Note: I'm new to Windows GUI development, so I apologize if this is a rudimentary question. I was unable to find anything meaningful while searching MSDN and other resources.
Thanks!
What it sounds like is not really a Web Browser shell at all, simply the relative appearance of one functionality-wise.
What you can do is use a TabControl control. This can be altered to suit your needs quite perfectly in my view.
An example of a modified TabControl is as follows: [ From here ]
There are a number of things that can be done with a TabControl (as with any other component) to make it suit what you need.
Here are some links that you may find helpful:
Flat Tab Control - As per the picture
MSDN
Video on using a Tab Control
C# Corner

Categories

Resources