Export (0) Print
Expand All
MFC
Expand Minimize

CWnd::SubclassDlgItem

Call this member function to "dynamically subclass" a control created from a dialog template and attach it to this CWnd object.

BOOL SubclassDlgItem( 
   UINT nID, 
   CWnd* pParent  
);

nID

The control's ID.

pParent

The control's parent (usually a dialog box).

Nonzero if the function is successful; otherwise 0.

When a control is dynamically subclassed, windows messages will route through the CWnd's message map and call message handlers in the CWnd's class first. Messages that are passed to the base class will be passed to the default message handler in the control.

This member function attaches the Windows control to a CWnd object and replaces the control's WndProc and AfxWndProc functions. The function stores the old WndProc in the location returned by the GetSuperWndProcAddr member function.

// The following code fragment is from CMyDlg::OnInitDialog 
// CMyDlg is derived from CDialog. 

// IDC_BUTTON1 is the ID for a button on the  
// dialog template used for CMyDlg.
m_MyButton.SubclassDlgItem(IDC_BUTTON1, this);   

Header: afxwin.h

Community Additions

ADD
Show:
© 2014 Microsoft