 |
|
 |
Method ShellContextMenu.ShowContextMenu first calls User32.dll DestroyMenu then calls IContextMenu.InvokeCommand, using the menu id of the previous destroyed menu.
Changed the order of calls, then it worked.
private void ShowContextMenu(Point pointScreen)
{
...
uint nSelected = TrackPopupMenuEx(
pMenu,
TPM.RETURNCMD,
pointScreen.X,
pointScreen.Y,
this.Handle,
IntPtr.Zero);
if (nSelected != 0)
{
InvokeCommand(_oContextMenu, nSelected, _strParentFolder, pointScreen);
}
DestroyMenu(pMenu);
pMenu = IntPtr.Zero;
...
}
ShellContextMenu.InvokeContextMenuDefault does it in the right order.
|
|
|
|
 |
|
 |
Could you please tell me how can I add one more personal option to the context menu?
I want to have smthng like "Add to..." and when the users click on it, i want to show a form created from me in the same solution... But I want to keep the rest of the shell menu..
Thank you in advance...
|
|
|
|
 |
|
 |
Does not work correctly on Windows Server 2008 64 bit or Win7 64 bit (I suspect the same with Vista 64 bit)
Try bringing up the context menu a few times (right clicking a file) it works the first few times then falls over.
I can't get any useful debug information from it, all I know is its memory access violation.
Can anyone else test and try confirm, I am unable to find a working .Net Explorer Context menu that works under 64 bit.
modified on Saturday, June 19, 2010 9:07 AM
|
|
|
|
 |
|
 |
For 64bit there is an unhandled overflow exception in WndProc which crashes the app.
Solution see http://www.codeproject.com/Messages/3541887/Re-Does-not-work-on-64-bit.aspx[^]
public static uint HiWord(IntPtr ptr)
{
uint param32 = (uint)(ptr.ToInt64() & 0xffffffffL);
if ((param32 & 0x80000000) == 0x80000000)
return (param32 >> 16);
else
return (param32 >> 16) & 0xffff;
}
and
public static uint LoWord(IntPtr ptr)
{
uint param32 = (uint)(ptr.ToInt64() & 0xffffffffL);
return (param32 & 0xffff);
}
|
|
|
|
 |
|
 |
Excellent work, however i had to modify it for my evil purposes, the GetPIDLs overloads for DirectoryInfo and FileInfo were unnecessary and it made it not possible to get the menu of files and folders at the same time, i modified it to take string[] yet the drives menus where non functional so i added a check to GetParentFolder for drive paths to have parent folder "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}" which is "My Computer"'s guid, and for desktop items like "My computer, My Documents, Desktop" i added an overload to ShowContextMenu and GetPIDLs that takes CSIDL that gets the PIDLs using SHGetSpecialFolderLocation, the rest of the CSIDL are quite useless so i just ignored them.
|
|
|
|
 |
|
 |
@mansatan
sorry, I speak English so badly that C#
would be nice if you give us the changes to uses directories and files
thank you in advance
(and thank you google for the translation,
which should not be great but better than this I could do)
@+
|
|
|
|
 |
|
 |
That does not seem to be too hard to do, I would just override:
public void ShowContextMenu
with parameters that accept a FileInfo array and a DirectoryInfo array.
If you look in the current ShowContextMenu methods, the method GetPIDLs is called for the DirectoryInfo and FileInfo arrays passed as parameters. Just call both for the directorys and files passed to your new method, and combine them in the _arrPIDLs array.
P.S. I did not test this, but it seems as though it should work.
|
|
|
|
 |
|
 |
@mansatan or anyone
Your reply Here is over a year old,but I am hoping you or someone can show a little example of how to get this to work with drives.
|
|
|
|
 |
|
 |
i use this Shell ContextMenu but i can't use Send to of it,Please Help me
sorry if my english is not good
|
|
|
|
 |
|
 |
Good to know this trick.
Thanks!
Jm
|
|
|
|
 |
|
 |
This is really great, looking forward to use it, only problem is that it can't handle every situation, like it states, files / folders need to be in the same location, and only one type of object can be passed onto it at a time.
Keep up the good work.
|
|
|
|
 |
|
 |
Does someone know how to handle the first limitation (that the files need to be in the same folder) ? Thanks
|
|
|
|
 |
|
|
 |
|
 |
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.
|
|
|
|
 |