Article ID: 135048
Article Last Modified on 8/16/2005
SendMessage(LB_INSERTSTRING, nIndex, (long)lpstrText);Because MFC provides wrapper classes for the common Windows controls, it would be useful to be able to use these classes to communicate with the subclassed control. This article illustrates one technique for doing this by showing how to connect the appropriate MFC control class to the COleControl-derived class that subclasses a Windows control.
class CSubclassCtrl : public COleControl
{
...
// Implementation
protected:
CListBox m_ListBox;
...
}
int CSubclassCtrl::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (COleControl::OnCreate(lpCreateStruct) == -1)
return -1;
m_ListBox.m_hWnd = m_hWnd;
// Additional list box initialization can go here.
return 0;
}
CSubclassCtrl::~CSubclassCtrl()
{
m_ListBox.m_hWnd = NULL;
}
m_ListBox.InsertString(nIndex, _T("A String"));
Additional query words: kbHowTo 1.50 1.51 1.52 2.00 2.10 2.20 2.51 2.52 3.00 3.10 3.20
Keywords: kbhowto kbnoupdate kbwndwproc kbctrl KB135048