Re: 840807 - DLGITEMTEMPLATE
- From: Joseph M. Newcomer <newcomer@xxxxxxxxxxxx>
- Date: Sun, 20 Nov 2005 21:27:14 -0500
Why does the data have to be part of the dialog template? For example, why can't it be
independent data?
It would never have occurred to me to use the DLGTEMPLATE data for this purpose, when
there are numerous other means of making the data available, none of which suffer from the
problems you describe.
You could consider a window-creation hook, and set the GWL_USERDATA field to a pointer at
that point, but I'm not sure the window-creation hook gives you what you need. But at
least at this point you've given a problem specification, rather than asking about the
details of a solution. The question should be rephrased as "How can I make additional
information available to my OnPaint handler?" and the answers are numerous. You are
creating a DLGTEMPLATE object, which means you have a pointer to the data to be displayed.
At that point, you also have some specification of a dialog class. You could consider
creating something like a CMap indexed by control ID and whose values are LPBYTE objects,
and initializing that. Making it part of the template just sounds like taking a simple
problem and making it difficult. You are using a feature that is essentially unsupported
by the dialog editor, and you are attempting to fit it into an environment (creating a
dialog template on the fly) in which the whole concept (intercepting WM_CREATE messages
with OnCreate handlers) is inoperative. Search for a more appropriate solution, and
forget putting the data in the dialog template. Note that you can build rich structures
which include the template and the CMap trivially in C++, and they will fit nicely into
the supported paradigms. Instead of fighting MFC, work *with* it.
So, given a problem statement, how to associate data with a control, there is at least one
easy answer. There are problably several more which are isomorphic, but all of them
simply boil down to: keep the data separate from the template! By choosing an
implementation strategy that tries to force the two together, you have chosen an
implementation strategy that is inconsistent with what MFC supports. So why bother?
joe
On 2 Nov 2005 01:50:21 -0800, "hamidi" <hamidi@xxxxxxxxx> wrote:
>let's use "be informed of" instead of "intercept".
>u call being informed of creation of a control (the static control) is
>a wrong solution.
>let me state my problem "again". i need to access the information i
>delivered in DLGITEMTEMPLATE as creation data,
>
>later in the program, eg. when i have to paint the control. this is my
>problem. without giving any solution i ask u
>
>to say how can i access this data. so my question becomes:
>"how can i access the creation data i delivered for a control along
>with DLGITEMTEMPLATE in the control's OnPaint?"
>
>give me a code not just words! because what is in ur mind may not be
>implemented.
>i didn't expect u not to realize my problem after such an iterative
>detailed posts.
>u ask "Why do you want to intercept the OnCreate handler?"! the
>creation data is passed to the control along with
>
>WM_CREATE message. how can i access it if i don't intercept the
>control's OnCreate?!!!
>we, iranians, have a proverb. we say understanding the problem is half
>of solution. maybe i couldn't describe it at
>
>first so good, because of my not so good English. but after these long
>posts i thought u must have understood the
>
>problem. sorry.
>my complain which u refered to is based on prooves i made after
>completely understanding ur suggestions. i stated in
>
>details why they're not applicable!
>i described also how PreSubclassWindow is not a practical way. the
>creation is done before the control is bound to
>
>any object. so no PreSubclassWindow (of no object) may be called.
>u ask "Why do you need a global function to be called?" this is not me
>to need calling a global function! the
>
>function is called by CreateIndirect which i used to make my dialog
>from the DLGTEMPLATE i made. u say i don't use
>
>CreateIndirect to create my dialog from the DLGTEMPLATE i made? this
>inevitably calls the ::CreateDialogIndirect
>
>global function!
>and about construction. surely when the variable may not be useful for
>me because it's bound after creation of the
>
>control i won't put it in the class of my dialog.
>ok, u say "You seem to have implemented a complicated solution for a
>simple problem. Why?" i'm going not to give
>
>any solution. forget it! now u know my problem? u give a solution.
>thanx and best regards. i hope u remember that it's just a discussion
>which follows its rules and it's not surely a
>
>quarrel... sorry!
Joseph M. Newcomer [MVP]
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
.
- References:
- Re: 840807 - DLGITEMTEMPLATE
- From: Joseph M . Newcomer
- Re: 840807 - DLGITEMTEMPLATE
- From: hamidi
- Re: 840807 - DLGITEMTEMPLATE
- Prev by Date: Re: Visual C++ 2005 express edition and MFC ?
- Next by Date: Re: Why there is an blue rectagle in MFC Dialog?
- Previous by thread: Re: 840807 - DLGITEMTEMPLATE
- Next by thread: Store object in combo?
- Index(es):
Relevant Pages
|