Message Maps: COMMAND handler for multiple COMMAND ID's 
Author Message
 Message Maps: COMMAND handler for multiple COMMAND ID's

I have a menu called "SELECT" (for example) I created, which has
selection1 selection2 and so on as entries. The ID associated with
each is SELECTION_1, SELECTION_2, and so on. When I select each one,
it checks it off on the menu (using the UPDATE_COMMAND_UI message
mapped to a handler function, one function per menu entry:
OnUpdateSelectSelection1(), OnUpdateSelectSelection2(), and so on). It
also can work fine if I have each selection call a different handler
function for the COMMAND message it generates when clicked
(OnSelectSelection1(), OnSelectSelection2(), and so on). So far so
good.

However, I'm experimenting with combining all those
OnSelectSelection..() calls into one call:

OnSelectSelection( UINT nID )

Where the nID is going to be the COMMAND ID that was selected. For
each entry in the menu, the property was already set to SELECTION_1,
SELECTION_2, and so on, for the appropriate menu entry. I then map
every COMMAND message for each of those COMMAND ID's to map to the one
function OnSelectSelection( UINT nID ).

The only problem is, for some strange reason, the number passed in nID
is *not* the number corresponding to the id assigned to SELECTION_1,
or SELECTION_2, or whatever else I pick. Hence I can't determine which
one was even picked, since the number passed is not even right. What
am I missing?

Any ideas appreciated.



Sat, 22 Mar 2003 03:00:00 GMT  
 Message Maps: COMMAND handler for multiple COMMAND ID's

Hi...
        What you need is

                    ON_UPDATE_COMMAND_UI_RANGE(idFirst, idLast,
OnSelectSelection(UINT nID )

Cheers
Check Abdoul
------------------


Quote:
> I have a menu called "SELECT" (for example) I created, which has
> selection1 selection2 and so on as entries. The ID associated with
> each is SELECTION_1, SELECTION_2, and so on. When I select each one,
> it checks it off on the menu (using the UPDATE_COMMAND_UI message
> mapped to a handler function, one function per menu entry:
> OnUpdateSelectSelection1(), OnUpdateSelectSelection2(), and so on). It
> also can work fine if I have each selection call a different handler
> function for the COMMAND message it generates when clicked
> (OnSelectSelection1(), OnSelectSelection2(), and so on). So far so
> good.

> However, I'm experimenting with combining all those
> OnSelectSelection..() calls into one call:

> OnSelectSelection( UINT nID )

> Where the nID is going to be the COMMAND ID that was selected. For
> each entry in the menu, the property was already set to SELECTION_1,
> SELECTION_2, and so on, for the appropriate menu entry. I then map
> every COMMAND message for each of those COMMAND ID's to map to the one
> function OnSelectSelection( UINT nID ).

> The only problem is, for some strange reason, the number passed in nID
> is *not* the number corresponding to the id assigned to SELECTION_1,
> or SELECTION_2, or whatever else I pick. Hence I can't determine which
> one was even picked, since the number passed is not even right. What
> am I missing?

> Any ideas appreciated.



Sat, 22 Mar 2003 03:00:00 GMT  
 Message Maps: COMMAND handler for multiple COMMAND ID's
On Tue, 3 Oct 2000 12:29:34 -0400,

Quote:

> Hi...
>         What you need is

>                     ON_UPDATE_COMMAND_UI_RANGE(idFirst, idLast,
> OnSelectSelection(UINT nID )

> Cheers
> Check Abdoul
> ------------------

Damn you!!! <grin> I saw that in the documentation, but thought that
was some optional thing for some *other* functionality -- didn't occur
to me that it was what *I* needed. Thank you very much. I guess class
wizard couldn't figure out I was mapping more than one command ID to
the same function, and enter that for me.. Oh well. :-) Thanks again.


Sat, 22 Mar 2003 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Multiple views and menu command handlers

2. mapping multiple messages to one handler

3. MDI No handler for command messages?

4. Pre-defined command ID's in afxres.h

5. Command ID's to use

6. Guidelines for choosing command ID's?

7. Commands ID's to use

8. range of user defined command id's ???

9. How to add custom window message handler to MESSAGE MAP

10. why my Composite Control can't capture the command message send by child common control

11. Difference between window message and command message

12. Getting Ctrl ID from within a message handler.

 

 
Powered by phpBB® Forum Software