Getting notification for dynamically added controls





On a similar note to my last question ...

I have a situation where I will present multiple data fields to the
user which they can edit.

The number of fields can vary. I have a class which wraps there names
and values nicely.

I can build a dialog in the editor and add the fields, but that's not
really desireable. It would make more sense to just pass in the class
which wraps these fields and construct the whole thing dynamically.

My first question, really, is whether I can just create a CDialog
dynamically. I will need to create a subclass of course so I can do
things like populate the data fields and read back the user entries.

But I am really not sure how much point there is to creating it in the
editor. I mean theoretically I can just instantiate it, add the text
labels/fields (CStatic and CEdit instances) then resize the dialog to
fit them.

I dug around a little and found these articles

http://msdn.microsoft.com/msdnmag/issues/06/09/CAtWork/

http://msdn.microsoft.com/msdnmag/code/?url=http://msdn.microsoft.com/msdnmag/issues/05/08/CAtWork/Default.aspx

But although the author describes it as simple, it looks like a real
mess. I downloaded his example code

http://download.microsoft.com/download/2/e/9/2e9bde04-3af1-4814-9f1e-733f732369a3/CAtWork0508.exe

and the majority of work seems to be in creating a template.

Is it possible to just use a default template? The original
questioner mentioned DLGTEMPLATE, is that a default template I could
use? I will end up dynamically sizing the dialog anyway, so any old
template should work, at least from my point of view.

***

Second question. I know I should really do more research and
trial-and-error on this before I ask the question, but I am worried I
am going to get deep into it and have spent a lot of time on it and
have painted myself into a corner.

If I am creating, for example, CEdits dynamically, instead of in the
editor, they aren't going to have IDs. I guess for what I'm doing, I
am just going to need to write default values to them, then read them
when the user is done, so I don't know if I even need notifications.

But on the other hand, I often find I need to know when some things
happen, like when the user clicks in an edit field.

Without actually trying it, I don't know if this will be a problem or
not. I posted another question earlier today where I am running into
difficulty trying to get notification when a user clicks in a
dynamically-created CListCtrl subclass which doesn't have an
editor-created ID.

(Somewhat ironically, the article I cite above that was the person's
original question, but it doesn't appear that it ever gets answered.)

Is there a general way to handle this? Is there a way to create
message map entries that don't require IDs? Or if not, is there a
workable general way of generating IDs? And in the latter case, how
do I put them in the message map?

anyway sorry if this is a frustrating question. I know there is a lot
more work I could do before I ask it, it's still fairly vague. I
suppose I am just trying to figure out if I am going to paint myself
into a corner.


--
Joe Cosby
http://joecosby.com/
When you give food to the poor, they call you a saint.
When you ask why the poor have no food, they call you a communist.

- Archbishop Helder Camara, Brazilian liberation theologist

:: Currently listening to Rattled, 1988, by The Traveling Wilburys, from "The Traveling Wilburys"
.



Relevant Pages

  • Re: Word 2007 Equation Editor
    ... or by right-clicking one and choosing Equation Object> Edit. ... editor, ... "What will happen to the equations if these docx files are ... Pack and opens these docx files and saves them as docx files?" ...
    (microsoft.public.word.docmanagement)
  • Re: How to edit the template of custom form library
    ... Once again this newsgroup is not for Windows SharePoint Services. ... "how to edit form temple in form library." ... > I need to create custom list template. ... > I am able to create form library using this custom form library template. ...
    (microsoft.public.sharepoint.teamservices.caml)
  • Re: choosing an editor
    ... template to modify with that editor. ... As far as downloading a "good" template. ... You've got to become good with HTML and CSS before that. ...
    (alt.html)
  • Re: latex and word,
    ... I have noticed that MSWord's equation editor adds formatting to a ... document that is difficult for any other software to edit. ... preferred WYSIWYG editor. ... The interface (even the better ...
    (sci.math)
  • Re: Questions For Dan Murphy
    ... >> Are you use template files for inserting things like Program Start, ... >> Tool Change, Drilling Cycles, etc? ... > you are in .doc or .rtf format, then you are not using it as a text editor. ...
    (alt.machines.cnc)