Re: 840807 - DLGITEMTEMPLATE

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



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
.



Relevant Pages

  • Re: 840807 - DLGITEMTEMPLATE
    ... eg. when i have to paint the control. ... "how can i access the creation data i delivered for a control along ... with DLGITEMTEMPLATE in the control's OnPaint?" ... u ask "Why do you need a global function to be called?" ...
    (microsoft.public.vc.mfc)
  • RE: Id guess I cant do this
    ... Templated User Control. ... Creating the Template Class ... When you have a dynamic template available, you can instantiate it in code. ... Add a data-binding event handler to the controls you create in the template. ...
    (microsoft.public.dotnet.languages.vb)
  • RE: Resolving datasource expression
    ... | a custom ASP.NET template databound control and the control will display ... | DataItem is just a propety of the "Container", ...
    (microsoft.public.dotnet.framework.aspnet.webcontrols)
  • Re: Listing objects
    ... App will be the root, ... asks a Control to do that. ... a page has a template ... So, after Controller instantiates Data, it should check that the loaded ID wasn't already assigned in some other Controller. ...
    (comp.lang.php)
  • Re: Inserting fields or document properties 2007
    ... You can also enable the DIP for a specific document, or documents based on a specific template, by going to Developer->Document Panel, enabling the DIP, then saving the document. ... Other options would be to use code to display them in another way, or to protect the document for forms, which would make it easier for the user to tab from control to control rather than having to click in each one in turn. ... drag-and-drop in the .dotm, in which case they would update in the .dotm, but would still be linked to the .dotm when Word created a document based on that template. ...
    (microsoft.public.word.docmanagement)