dynamic create of controls, how to receive events?

From: Martin Ortiz (martin_at_enigmasoftwaregroup.com)
Date: 05/13/04


Date: Thu, 13 May 2004 10:55:51 -0400

I need to dynamically create buttons. Dynamically creating buttons is easy
in atl, I just need to use whatever variant of "create" to do it.

I need advice deciding on which would be best method to deal with "button
clicks"....(that is, informing container of button click event occurred.

I have basically 4 options I've come up with

1) I can use IDispEventImpl, I know how to use it during pre compile phase,
not sure about doing it at runtime

2) Since I won't have, say more than 10 buttons, I can just create them in
resource editor, and just make them visible at runtime when appropriate (no
hassles with keeping track of new and deletes, message mapping done in
source code...etc...)

3) I can use CHAIN_MSG_MAP_DYNAMIC, to chain messages of buttons to host
container.....

4) Create buttons dynamically, and when button is clicked, to called either
a global function (that is aware of host), or to pass pointer to subclassed
button, with function so host can do what ever is appropriate when button is
clicked.

thoughts? practical advice from experience on best method to pick?