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.
Related
Is it possible to add new items to the Start 'flyout' menu? By flyout menu, I mean the one shown in the image below. I've written a system tray Winforms application which allows me to swap between and set boot partitions without using BCDEdit and thought it may be nice to add this feature into the actual start menu.
Despite a lot of Googling, I didn't find a solution but I did see ways to switch existing options on and off through the registry.
When browsing a folder in Windows Explorer, I can use the user interface to add additional columns to my view that are typically not there when browsing the folder, such as "File extension" or "Language." In Windows 10, you perform this action by clicking the "View" tab, clicking "Add Columns," clicking "Choose columns...," then selecting the desired columns and clicking "OK."
What I would like to do is perform this action programmatically, ideally adding any column from that list to a chosen directory with hopes of populating that column with metadata. I was looking extensively into methods that could accomplish this, such as the Column Handler shell extension, but support for IColumnHandler was dropped after XP and simply won't work.
From there, the only possible option is to use the Property Handler in the Windows API and read the values directly from the registry. However, I am not sure how to go about doing that. I have tried finding some samples online of how to perform this, and it's led me to a bunch of dead ends all around. I understand it must be difficult, but I am sure someone has managed to make it work.
Does anyone has any examples or guidance on how to use the Property Handler in the Windows API to add columns to a View in a Windows Explorer folder? Do I have any other options? Any feedback is appreciated.
in a shell view, you choose columns by calling IColumnManager::SetColumns with an array of PROPERTYKEY structures.
Assuming you have a Windows Explorer window's IShellBrowser interface, call GetActiveShellView to get the shell view, then query the view object for IColumnManager (a cast in C#).
Sometimes I see the shortcut sometimes I don't. I'm not sure why.
How can I make the shortcut permanent?
I believe I have an answer. It worked for me flawlessly. After being frustrated, I wrote to MS through the Feedback option in VS2013 (at the top). A week later, one of their employees responded with this:
Hi,
Thanks for raising this issue to us through the Visual Studio
Feedback program. I am interested in helping investigate the issue
you’ve described. After creating a new WPF app in Visual Studio 2013
RTM, I was able to reproduce the issue you’ve described. By default,
.xaml files do not have the “Open in Blend…” command enabled in the
context menu in the Solution Explorer. However, I was able to
successfully add this command in both VB and C# WPF projects in VS
2013. It sounds like you might have also tried this method, but please try the steps below and see if you are able to successfully add the
command. I hope that step #6 might be the trick in successfully
enabling the command for you. In order to add this command, I
followed these steps:
Tools > Customize
Select Context Menu radio button
From the Dropdown, choose “Project and Solution Context Menus | Item”
Click the “Add Command…” button
Select View category
Select the third (bottom-most) “Open in Blend…” command (there should be three available)
Close dialogs
Right click MainWindow.xaml
Select “Open in Blend…” (it should not be grayed out)
Of the three “Open in Blend…” commands available, the third one is the
only one which successfully worked on .xaml files in WPF projects. The
other two would be grayed out when I tried to use them. Please
contact me to let me know if you are able to successfully add the
command or if you still see the issue. I look forward to your
response, and I hope that this will successfully resolve your issue!
Thank you,
Scott Rick
I am impressed by the fact that he gave much consideration to this issue and actually tested several methods. In my case, there were two "Open in Blend..." items, so I chose the second one and it worked flawlessly.
Hope it works for you as well.
You can customize it:
Keyboard Shortcut: how to
Integration in context menu:
Tools->Customize
Click on Commands tab
Click on Context menu and choose "Project and Solution Context Menus | Item
Click on Add Command
Select View as Category
Select 'Open in Blend' command
You get this context menu option now for every item but that should not hurt...
When working on a Silverlight, Windows Phone or Windows Store app project, you can use the View -> Open in Blend command to open your current active tab/code XAML window in Blend.
The above menu choice is not available for WPF apps only. No idea why.
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.
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.