[python-win32] Context menu troubles

Chris Ness karbonforms at gmail.com
Fri Mar 2 22:14:43 CET 2012


Aaaaaaaaaaaaaah. It makes sense now. messages and such like. my lack of 
knowledge of win32 shows.

I'll let you know how I get on.

Am I right in thinking the win32 api is awfull?

Chris.

On 02/03/2012 20:16, Tim Roberts wrote:
> Chris Ness wrote:
>> I had decided not to use the command ID technique until I got things
>> working, so TPM_RETURNCMD was commented out when I defines flags. From
>> my understanding of MSDN and pywin32, this should make commands
>> immediately execute and cause TrackPopupMenu to return an HRESULT?
> Hmm, I should have read the doc more closely before I replied.  My fault.
>
> I doesn't work quite that automatically.  TrackPopupMenu is a
> general-purpose Windows API -- it doesn't have any connection to or
> knowledge of Windows Explorer, so it cannot force Explorer to take
> actions.  If you don't specify TPM_RETURNCMD, then the final result of
> selecting a menu item will be that a WM_COMMAND message sent to your
> window.  Your window doesn't know what to do with those command codes,
> so nothing useful will happen.  In this particular case, I think you
> HAVE to use TPM_RETURNCMD.
>



More information about the python-win32 mailing list