SubclassDlgItem() vs "text substitution" - Programmer

This is a discussion on SubclassDlgItem() vs "text substitution" - Programmer ; Hi, I'd like an enlightment about the following question: In this newsgroup and in some other places I found that, to use a custom derived class for an MFC control, the programmer can simply replace in the source code all ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: SubclassDlgItem() vs "text substitution"

  1. SubclassDlgItem() vs "text substitution"

    Hi,

    I'd like an enlightment about the following question:

    In this newsgroup and in some other places I found that, to use a custom
    derived class for an MFC control, the programmer can simply replace in
    the source code all the occurrences of C (e.g. CStatic)
    with his own custom control (e.g. CMyStatic).

    On other places (e.g. some CodeProject articles), I found the usage of
    SubclassDlgItem() method.

    What's the difference (if any...) between the two methods?

    Thanks in advance,
    Dan

  2. Re: SubclassDlgItem() vs "text substitution"

    Danguard wrote:

    > Hi,
    >
    > I'd like an enlightment about the following question:
    >
    > In this newsgroup and in some other places I found that, to use a custom
    > derived class for an MFC control, the programmer can simply replace in
    > the source code all the occurrences of C (e.g. CStatic)
    > with his own custom control (e.g. CMyStatic).
    >
    > On other places (e.g. some CodeProject articles), I found the usage of
    > SubclassDlgItem() method.
    >
    > What's the difference (if any...) between the two methods?
    >
    > Thanks in advance,
    > Dan


    These two techniques are almost always used together. Changing a
    variable type from an MFC control class to your derived class gives you
    a place to put customizing code but it does not "connect" the class to
    any particular control.

    This "connecting" is called window subclassing. What it accomplishes is
    routing all messages sent to the control via your class message map, so
    you can intercept control input such as mouse messages.

    One way to do it is to call SubclassDlgItem. Another way to do it is
    use class wizard to create the control member variable. Class wizard
    inserts a DDX_Control call (that calls SubclassDlgItem behind the scenes).

    --
    Scott McPhillips [VC++ MVP]


  3. Re: SubclassDlgItem() vs "text substitution"

    In article , "Scott McPhillips
    [MVP]" says...

    > These two techniques are almost always used together.
    > [...CUT...]


    Thank you.
    Your posts are helpful to me!

    Ciao,
    Dan

+ Reply to Thread