[python-win32] Context menu troubles

Tim Roberts timr at probo.com
Fri Mar 2 19:42:32 CET 2012


Chris Ness wrote:
> disclaimer: I have only the faintest idea what I'm doing!
>
> I'm trying to get a windows explorer context menu in my app. I can get 
> the menu to show, but it does not execute any commands (e.g. 'copy')

Right, because you haven't told it to.  You implemented the stuff form
the articles pretty closely until the call to TrackPopupMenu, then you
went awry.  TrackPopupMenu does not actually return a boolean.  It
returns 0 if the call fails, but if the call succeeds, it returns the
command ID of the menu item that was selected, and you have to tell the
shell to go invoke that command.

So, if it returns a value other than 0, you need to create a
CMINVOKECOMMANDINFO structure, fill it in, and pass it to
CM.InvokeCommand.  That will trigger the real action.

-- 
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.



More information about the python-win32 mailing list