How do I route multiple controls to a single handler?

How do I route multiple controls to a single handler?

Post by Andy Moo » Sat, 15 Mar 1997 04:00:00



I'm using Visual C++ 1.5 and MFC under Windows 3.1.  If I implement
an array of controls, such as

  CButton* MY_BUTTONS[10];

what do I do in the message map to deal with that?  What I really
want is for a click on any button in the array to go to a single
function, with a parameter giving the ID of the button pressed.

I can't find any example of this in my books or on-line docs.
If I have to actually write an ON_BN_CLICK entry for each
entry, that sort of defeats the purpose of using an array (not to
mention that I'd have to give a unique function for each entry?)

Thanks in advance for any help...

 
 
 

How do I route multiple controls to a single handler?

Post by Cecil A. Galbrait » Sat, 15 Mar 1997 04:00:00



> I'm using Visual C++ 1.5 and MFC under Windows 3.1.  If I implement
> an array of controls, such as

>   CButton* MY_BUTTONS[10];

> what do I do in the message map to deal with that?  What I really
> want is for a click on any button in the array to go to a single
> function, with a parameter giving the ID of the button pressed.

> I can't find any example of this in my books or on-line docs.
> If I have to actually write an ON_BN_CLICK entry for each
> entry, that sort of defeats the purpose of using an array (not to
> mention that I'd have to give a unique function for each entry?)

> Thanks in advance for any help...

Try SetDlgCtrlID() to associate the same ID with each button. If
desired, you can check which button rang in by seeing which control has
the focus...

Cecil
--
Cecil Galbraith

Free programmer's utilities and MFC tips at
http://www.concentric.net/~cgalbrai

 
 
 

1. single account; single user: multiple mailboxes

Hello,

I am running win2k with outlook express.

I have been running Outlook Express for a long time. Through
many fixes etc.

So what has happened is that I have created mailboxes (ie: inbox.dbx)
in many locations.

I would like to merge them into one and remove the rest.

I have no idea how to do that.

any ideas?

Thank you very much.

Respectfully,

Bil

2. Display problem

3. Creating Menus on the fly, with single handler

4. how to find out who send you a message through WIN NT prompt.

5. Windows XP, Multiple User Accounts, Multiple NIC, managing routes on startup

6. jones_jupiter@hotnomail.com

7. Outlook Express 6 and NTFS

8. Doesn't multiple inheritance work with message handlers?

9. Multiple handlers

10. Mapping multiple BN_CLICKEDs to same handler?

11. Single DHCP Server in Routed Environment?

12. Win95 TCP/IP and DOS legacy apps, INT 14 Handler