Discussion:
OnCreate in CStatic
(too old to reply)
unknown
2004-10-26 10:49:10 UTC
Permalink
i made a class from CStatic and i added OnCreate function to this new class
but this function never runs. why? (new class is connected with static
resourse)

winnicki
David Lowndes
2004-10-26 11:09:13 UTC
Permalink
Post by unknown
i made a class from CStatic and i added OnCreate function to this new class
but this function never runs. why? (new class is connected with static
resourse)
I guess you're using your class for a control in a dialog?

In that situation, your class is attached to the control after the
control has been created - therefore you never get to handle the
WM_CREATE message.

Dave
RainMan
2004-10-26 18:43:01 UTC
Permalink
I think is the other way around. Window is attached to a class’ object by
means of performing SubclassWindow in DDX_Control.
Post by David Lowndes
Post by unknown
i made a class from CStatic and i added OnCreate function to this new class
but this function never runs. why? (new class is connected with static
resourse)
I guess you're using your class for a control in a dialog?
In that situation, your class is attached to the control after the
control has been created - therefore you never get to handle the
WM_CREATE message.
Dave
David Lowndes
2004-10-26 20:54:28 UTC
Permalink
I think is the other way around. Window is attached to a class’ object by
means of performing SubclassWindow in DDX_Control.
It depends which way you look at it. :)

Dave
--
MVP VC++ FAQ: http://www.mvps.org/vcfaq
RainMan
2004-10-26 21:15:03 UTC
Permalink
I do not think so.

You have to have MFC object instantiated first in order to have ability to
attach window to it.

It can be existing window that you attach by calling SubclassWindow or
Attach in order for MFC object to map (attach) window’s handle.

If window does not exist you call Create that in turn calls API
implementation of the Create. Then new window’s handle is mapped into MFC
object.

Therefore it is always that you attach window to MFC object. Object is using
existing window and is aware of it. Windows window does not have the
slightest idea about any MFC let alone MFC object. Another words, you do not
use any Windows’ function to attach MFC object to it.

:)
Post by David Lowndes
Post by RainMan
I think is the other way around. Window is attached to a class’ object by
means of performing SubclassWindow in DDX_Control.
It depends which way you look at it. :)
Dave
--
MVP VC++ FAQ: http://www.mvps.org/vcfaq
David Lowndes
2004-10-26 23:11:57 UTC
Permalink
Post by RainMan
I do not think so.
I think we're labouring the point.

Dave
--
MVP VC++ FAQ: http://www.mvps.org/vcfaq
AliR
2004-10-26 21:04:13 UTC
Permalink
If you are using the class as a control within a dialog using the
DDX_Control macro to attach it to a control you will need to overwrite the
PreSubclassWindow method.

AliR.
Post by unknown
i made a class from CStatic and i added OnCreate function to this new class
but this function never runs. why? (new class is connected with static
resourse)
winnicki
Sergey Kochkarev
2004-10-27 07:18:08 UTC
Permalink
Post by unknown
i made a class from CStatic and i added OnCreate function to this new class
but this function never runs. why? (new class is connected with static
resourse)
winnicki
Also try my_static.SublcassDlgItem(ID_MY_STATIC, this) in OnInitDialog.
Loading...