Message maps / dynamically created controls

I have a dynamically created CObList of CEdits displayed on my view. How can I respond to messages e.g. EN_SETFOCUS?
As I undersatnd it...
I can't use ClassWizard because the controls don't exist at design time.
I can't manually modify the message map because I don't know how many edit boxes will be added.

Does anybody know if there is there a nice way of doing this?

Thanks in advance

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Are all the controls (CEdits) going to be of the same window class, i.e are they the same "type" of control?  If so they will all share the same message map.  So just create the window class and modify its message map.  Then at run-time create as many _instances_ of this type of control as you need.  However, If they are supposed different types of controls, you will need to know their types at compile time and they will each have seperate message maps (and seperate window classes etc.)  But I suspect you will want them all to be the same type.

Let me know if you have any questions.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mark_sAuthor Commented:
I don't know how to edit a message map for a "type" of control, only for an individual ID.

If I create a control (ID 9999)

CEdit *myedit = new CEdit;
myedit->Create(WS_VISIBLE | ES_MULTILINE, CRect(10,10,200,30), this, 9999);

I can edit the message map
      ON_EN_CHANGE(9999, OnChangeEdit9999)

to handle the on change message for the edit box in  CMyFormView::OnChangeEdit9999()

I don't know MFC very well.  but assuming that MFC doesn't do anything "weird" in this case, you should handle it in the OnCommand() procedure.  See an edit control sends WM_COMMAND messages to its parent window to notify it of certain events like this.  The command messages will specify the type of notification that is being made in the high word of the WPARAM.  you should test this word to see if it is EN_CHANGE.  If so, one of the window's edit controls has had its text modified.  (The other information passed identifies which edit control, but that you don't seem to care about, right?)

Does that help?
mark_sAuthor Commented:
This is just what I need. thanks.
I would like to identify which edit control, and I see that the ID of the control is returned in LOWORD(wParam).
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.