try searching your registry for the words in the context menu (the words used for Nvidia)
then, if you find them try adding one manually (you may need to restart your system before the changes take effect), if that works then you can programatically add the keys.
Not sure what exact changes would be needed but should just be something similar to winzips (or othe apps that add a CM menu) registry entries but modify to execute your app.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
I'm not very sure when I modify windows register. I didn't really find where nvidia hides its stuffs to insert its own menu in desktop menu. Anyone could know which key it is?
It's surprising that's is not as easy as you click on desktop for this menu ! It seems all desktop stuffs is difficult to manipulate. Nothing has been really done to personnalize desk with VB...
I read up on how to do this many years ago but never created an app to make use of it. And now I no longer have the information at hand. The menu item you see is contained in a dll. Not sure if it can be done in vb.
Look under: "HKEY_CLASSES_ROOT\Directory\Background\shellex\ContextMenuHandlers" and you'll see GUIDs and subkeys containing GUIDs. These GUIDs reference the HKCR\CLSID section, which contain the reference to the dll. Sorry to give a bit of a negative answer, but it's all I have.
EDIT: Also - HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Shell Extensions\Approved
I've noticed that in registry adress HKEY_CLASSES_ROOT\Directory\Background\shellex\ContextMenuHandlers, indeed there is a folder whose the name is "NvCplDesktopContext", Nv for nvidia... It was surprising to see that : why is it in "Directory"?
I've tried to play with dll exemple and I put it here (and I desactivated the file selection in dll as I could). But nothing, no changes! We're near the problem.
You can hook into the desktop and on INITMENUPOPUP you can add your own menu item. I've done it for TaskBar context menu and RTB context menu. Here is a similar code: http://www.vbforums.com/showthread.php?t=376337
I didn't find the registry keys that time, so I don't know how it can be done by editing registry.
I've tried your application which changes Richtextbox popup menu (it seems there is a cursor problem : it doesn't change as default when popup is shown).
I've change hwnd, and I've tried with notepad popup menu. Nothing happens ; WM_INITPOPUPMENU isn't detected by hook ocx. This is the same with superior layer of the desktop!
You need to hook into SHELLDLL_DefView, which is the parent of the desktop listview.
Just replace cmdHook_Click with the following code and it will work.
Following your program, I tried myself to color my submenu add-in in desktop menu. It didn't run. Using your menu sub ("format menu") of this program, I coloured with setmenuinfo. I used getsubmenu to get sub menu handle (I had a null sub handle although submenus were counted), and nothing happened. Have you finally achieved your color menu program?
Re: color menu:-
Nope. The problem is still unresolved. At last I gaveup hope.
Re: differences between the two messages:-
I don't know why some app uses WM_CONTEXTMENU and why some app uses WM_INITMENUPOPUP.
Originally Posted by sephiroth2m of CodeGuru
I think system classes do not fire WM_INITMENUPOPUP, which allows user to change the menu before dysplay it, like user-defined classes do. WM_CONTEXTMENU, in my opnion, is useless because it just works like WM_RBUTTONUP/DOWN works.
Idea for trapping popup menus created after processing WM_CONTEXTMENU: (NOT TESTED)
1. Subclass the control where user right clicks. 2. When you receive WM_CONTEXTMENU, enable a timer (with very little interval - 10ms) 3. From inside the timer look for the menu (class name "#32768") using FindWindow (or may be FindWindowEx) API. 4. Once you get hWnd of the menu, you can add new manuitems.
Thanks, I have managed to add a menu to desktop menu as I've wanted. I would like to get also the way to color menu of my own, and I hope someone will achieve later.
Re: [RESOLVED] Adding menu in desktop context menu
It is old for me! I haven't read these lines until now. I use them in my program but I think it would be easier to extract files that are dealing with the topic of this thread. I hope I have all of them.
I was satisfied with a hook procedure of the desktop, and finally i abandon colored menu possibilities. I only use iprank's solution suggested in this thread, not more, only small adaptations.
This files would probably not run because they call functions and other stuffs of my program. This is only for reading. I'm sorry but you're going to sort what is useful for this thread because I never well formated this insert menu solution.
We need a hook control Hookcontrol.ocx.We use a ghost window, F0, that has all operations of my program (that uses as systray program...). The F0 form is not visible. We also need a classic module HK for declarations relative to the menu hook procedure. The F0 form has the lines to build the menu. You have to use a main sub to launch hkcinit to start the hook. Finally when you click with your right mouse button on the desktop, you must have your own menu inserted in your common desktop menu!
Hookcontrol.txt has to be changed in hookcontrol.ocx and it is must be in the same folder as F0.frm.