Re: Command IDs in message map handlers.
"Joseph M. Newcomer" <newcomer@flounder.com> wrote in message
news:5pci43pvpmlh9u9pfpvmalpfi37ufo7bu6@4ax.com...
Every once in a while we earn our pay. Sometimes all we can do is buckle
down and edit.
Sounds like a good aphorism :-)
I
doubt you have a million-and-one handlers,
Ok - that's UK English for probably well over a hundred or two. I could
have said "squillions" but that would have been hyperbole.
but I've done this sort of thing with three
hundred functions, and a simple keyboard macro is usually good enough,
providing you have
a humane editor. For example, I will grep for ::On[A-Za-z0-9_]+()
You forgot to allow for spaces between the ( ) - I leave them all over the
place.
and then ask my editor
to remember my keystrokes as I type move-to-start-of-line, delete-word,
BOOL, move to left
paren, insert UINT nID, move to start of line, move down one line. Then I
will do
C-X-C-N, look at the handler, if it is a command handler, type C-X-E, and
proceed thusly.
so I end up typing 4 keystrokes per conversion, 2 keystrokes per
non-conversion.
Any respectable editor has such a macro capability.
This is frighteningly advanced editing! I used to try it sometimes but
gave up as I tend to screw it up to often. I'd also of course need to
insert "return TRUE;" at the end of each function.
But the relatively simple solution:
int CMusView::mvCommandCurrent()
{
int nId = 0;
const MSG *pMsg = GetCurrentMessage();
if( pMsg && (pMsg->message==WM_COMMAND) )
nId = (int)LOWORD(pMsg->wParam);
return nId;
}
seems to be working well enough at the moment. [Lord knows why
"CWnd::GetCurrentMessage()" isn't declared const.]
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