Getting notification for dynamically added controls
- From: Zapanaz <http://joecosby.com/code/mail.pl>
- Date: Mon, 11 Feb 2008 18:12:58 -0800
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"
.
- Follow-Ups:
- Re: Getting notification for dynamically added controls
- From: Uwe Kotyczka
- Re: Getting notification for dynamically added controls
- From: Joseph M . Newcomer
- Re: Getting notification for dynamically added controls
- From: Scott McPhillips [MVP]
- Re: Getting notification for dynamically added controls
- Prev by Date: Re: Changed behavior of overriden OnCmdMsg(...) after migration to Visual Studio 2005
- Next by Date: Re: Getting notification for dynamically added controls
- Previous by thread: CListCtrl gets NM_CLICK, but not NM_DBLCLK
- Next by thread: Re: Getting notification for dynamically added controls
- Index(es):
Relevant Pages
|