Re: Command IDs in message map handlers.
- From: "David Webber" <dave@xxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 14 May 2007 19:09:16 +0100
"Joseph M. Newcomer" <newcomer@xxxxxxxxxxxx> wrote in message news:m8og43t4577g8380pimg3jpi32iugspo46@xxxxxxxxxx
No. Because you are in that handler, you KNOW what ID got it there.
If you want to have several ON_COMMAND dispatches go to the SAME handler, use
ON_COMMAND_RANGE(low, high, OnHandler)
As Seetharam pointed out, ON_COMMAND_EX also passed the ID. But I have a million and one ON_COMMAND handlers and I wanted to avoid having to change them all (and the form of the functions they call) if possible.
But I have been playing with GetCurrentMessage() and this seems to be doing the trick.
A bit of background:
Just about all my OnCommand handlers are essentially three line functions with a call to
- a preparation function
- an execute function
- a tidy-up function
I introduced this structure to allow multiple levels of undo: the preparation function makes some definitions, and the tidy-up function adds to the undo stack if the command was successful.
So it was the work of a moment to add GetCurrentMessage as the first task of the preparation function, and extract the command ID and store it temporarily. The tidy-up function stores it for the longer term if the commend succeeded.
And the point: after a couple of user-requests I have added a "repeat previous command" command, (on F4 by default, as in Microsoft Office) which just looks up this ID and, yes, *posts* a WM_COMMAND message. It is still somewhat embryonic but it appears to be working quite well so far.
Dave
--
David Webber
Author of 'Mozart the Music Processor'
http://www.mozart.co.uk
For discussion/support see
http://www.mozart.co.uk/mzusers/mailinglist.htm
.
- Follow-Ups:
- Re: Command IDs in message map handlers.
- From: Joseph M . Newcomer
- Re: Command IDs in message map handlers.
- References:
- Command IDs in message map handlers.
- From: David Webber
- Re: Command IDs in message map handlers.
- From: Joseph M . Newcomer
- Command IDs in message map handlers.
- Prev by Date: Re: path...
- Next by Date: Re: Preventing task manager from closing my application.
- Previous by thread: Re: Command IDs in message map handlers.
- Next by thread: Re: Command IDs in message map handlers.
- Index(es):
Relevant Pages
|