Platform SDK Shell >> CDefFolderMeu_Create2 woes

by Henk Devos » Sun, 11 Jan 2004 04:11:44 GMT

Hi all,

This group seems to be very active right (everyone back from holidays?) so
this might be a good time to ask my question.

Nowadays there is a documented function CDefFolderMenu_Create2 that creates
a default context menu.
Great function.
However the documentation doesn't seem to be intended to help developers to
use this function, but rather to be able to say that this function is
documented.

I want to create a context menu for a file that's somewhere in the file
system, and i want to get the exact same menu as in Explorer.
Does anyone know which registry keys i should pass to the function?
I am currently passing HKCR\*, HKCR\file, HKCR\.ext and HKCR\fileclass.
The last ones would be HKCR\.txt and HKCR\txtfile in case of a text file.
There is a context menu displayed with a number of default verbs like "copy"
and "delete", but the most basic ones are not there: "Open" etc. These are
the ones that are associated with this specific file type.

Does anyone know what i have to do to get all verbs show up?

Thanks for any help you can give me with this!




Platform SDK Shell >> CDefFolderMeu_Create2 woes

by Jim Barry » Sun, 11 Jan 2004 04:40:34 GMT





That's about the size of it.


Any reason not to use the filesystem folder's GetUIObjectOf?

- Jim



Platform SDK Shell >> CDefFolderMeu_Create2 woes

by Henk Devos » Sun, 11 Jan 2004 07:30:16 GMT

Yes.
This is for a namespace extension sample.
The sample i'm doing now does have a real fioe system counterpart.
Other similar applications won't have that.
The sample is an exact copy of the C: drive with everything being displayed
as much as the real C: drive as possible, but doint everything myself in a
namespace extension.






That's about the size of it.


Any reason not to use the filesystem folder's GetUIObjectOf?

- Jim




CDefFolderMeu_Create2 woes

by Henk Devos » Mon, 12 Jan 2004 00:32:07 GMT

I already got one step further.
I added the CF_HDROP data format to the IDataObject passed to
CDefFolderMenu_Create2.
Now i have "Open with..." with the list of programs that has been used
before, and some other context menu extensions.
But the "Open" and other verbs in the registry still doesn't show up.

I also noticed that the order of the keys seems to be important. When i put
HKCR\* first in the list, it works like described. When i put this one last,
i get only the default cut/copy/etc, but none of the extensions i expect.

Any further ideas on getting the menu complete?




creates
to
"copy"




CDefFolderMeu_Create2 woes

by Henk Devos » Mon, 12 Jan 2004 01:16:39 GMT

Sorry for all the fuss, i was doing something wrong.
It's not true that the order of the keys makes a difference.
The problem was that i only succeeded in opening one of the keys (operator
precedence, forgot brackets, typical beginner's misstake: "&(*parKeys[j]))"
instead of "&((*parKeys)[j]))", where parKeys is HKEY** list to fill up).

One more remark:
I thought it would make sense to include the "file" key.
However when i do this, a second open command shows up.
So it now seems like the correct keys to pass are (for example for a text
file):
HKCR\*
HKCR\.txt
HKCR\txtfile




put
last,


so
file.
are




CDefFolderMeu_Create2 woes

by Kenneth Myhra » Wed, 14 Jan 2004 01:45:19 GMT

Henk, ref. the post 'Namespace Extension: IContextMenu related questions',
where we were talking earlier.

This function may be what I need! Do you have any examples on how to use
this function to for example merge the cut/copy/paste menu items from
explorer? I have a bit trouble understanding what values to put in the
ahkeyClsKeys parameter I thought this should be HKEY flags, but the only
ones I can see in the header files are these:

#define HKEY_CLASSES_ROOT (( HKEY )
(ULONG_PTR)((LONG)0x80000000) )
#define HKEY_CURRENT_USER (( HKEY )
(ULONG_PTR)((LONG)0x80000001) )
#define HKEY_LOCAL_MACHINE (( HKEY )
(ULONG_PTR)((LONG)0x80000002) )
#define HKEY_USERS (( HKEY )
(ULONG_PTR)((LONG)0x80000003) )
#define HKEY_PERFORMANCE_DATA (( HKEY )
(ULONG_PTR)((LONG)0x80000004) )
#define HKEY_PERFORMANCE_TEXT (( HKEY )
(ULONG_PTR)((LONG)0x80000050) )
#define HKEY_PERFORMANCE_NLSTEXT (( HKEY )
(ULONG_PTR)((LONG)0x80000060) )

#define HKEY_CURRENT_CONFIG (( HKEY )
(ULONG_PTR)((LONG)0x80000005) )
#define HKEY_DYN_DATA (( HKEY )
(ULONG_PTR)((LONG)0x80000006) )

so, I am wondering, which one of these corresponds to 'HKCR\*' for example,
my first guess would be HKEY_CLASSES_ROOT, is that right? But then you also
lists 'HKCR\file, HKCR\.ext, HKCR\.txt, HKCR\txtfile and HKCR\fileclass'
which predefined HKEY does these correspond to?

-Kenneth



creates
to
"copy"




CDefFolderMeu_Create2 woes

by Henk Devos » Wed, 14 Jan 2004 04:34:49 GMT

ou don't have to use predefined keys.
Open the key yourself, and remember to close it again when your IContextMenu
object gets deleted.
In other words call RegOpenKeyEx(HKEY_CLASSES_ROOT, "*", ...).

This function should have all the needed standard verbs. You will not have
to add Delete etc.
The menu will also for some reason be correctly merged.
Might be interesting to step through the code and see exactly what is being
done to get everything right.
If you want to add extra commands, you can do this by calling
Shell_MergeMenus, which is as far as i know also what is being done to do
the final merge of the def menu with the passed-in hmenu.
I don't have any samples that i can post here.

"Kenneth Myhra" < XXXX@XXXXX.COM > wrote in message
news:# XXXX@XXXXX.COM ...
example,
also
so
file.
are