Control subclassing
-
I develop an MFC application, a plain simple window (non-doc View). I want to add an edit child control on this parent window. For this purpose i need to call
CEdit::Create()
in order to place control. Now, I want to change the behaviour of edit control, for this purpose i derive my own classmyedit
from CEdit i.eclass myedit:public CEdit
. Then i add the member variable ofmyedit
, m_myedit in project. Now do i need to call m_myedit.SubclassWindow() before calling m_myedit.Create() ???? Under what cases we need to call SubclassWindow/SubClassDlgItem() ???? -
I develop an MFC application, a plain simple window (non-doc View). I want to add an edit child control on this parent window. For this purpose i need to call
CEdit::Create()
in order to place control. Now, I want to change the behaviour of edit control, for this purpose i derive my own classmyedit
from CEdit i.eclass myedit:public CEdit
. Then i add the member variable ofmyedit
, m_myedit in project. Now do i need to call m_myedit.SubclassWindow() before calling m_myedit.Create() ???? Under what cases we need to call SubclassWindow/SubClassDlgItem() ????Shah Shehpori wrote: Now do i need to call m_myedit.SubclassWindow() before calling m_myedit.Create() ? Nope! MFC takes care of subclassing the control as it is created when you call
Create()
. Shah Shehpori wrote: Under what cases we need to call SubclassWindow/SubClassDlgItem() ? If the control were already created but did not have an MFC class attached to it, you would then need to sublclass it in order for your custom class to receive messages sent to it. ---My whole life I've practiced the art of self-sabotage -- fearing success perhaps even more than fearing failure. I think I have got this flareup resolved, but I'm constantly waiting to see what new and exciting ways I can spoil my chances for a better life. - koreykruse, Compulsive Skin Picking
-
I develop an MFC application, a plain simple window (non-doc View). I want to add an edit child control on this parent window. For this purpose i need to call
CEdit::Create()
in order to place control. Now, I want to change the behaviour of edit control, for this purpose i derive my own classmyedit
from CEdit i.eclass myedit:public CEdit
. Then i add the member variable ofmyedit
, m_myedit in project. Now do i need to call m_myedit.SubclassWindow() before calling m_myedit.Create() ???? Under what cases we need to call SubclassWindow/SubClassDlgItem() ????be deriving a control when you set the veriable type to the derived type the sublassing is automatic . on presubclasswindow() { //make any modifications before your control is subclassed } I am the mighty keeper of the book on knowledge . Contact me to get your copy .