Date: 2000oct14
Platform: MFC
Language: C/C++
Q. How do I initialize a class I made that's derived from an existing
MFC class?
A. You can not do it in the constructor because the window does not exist.
You can not do it in OnCreate() either. I am not aware of any Windows
messages you can catch on all Windows versions. So it seems the best way
is to override the PreSubclassWindow() function.
In your .h file do this:
class CMyListCtrl : public CListCtrl
{
private:
// ...
//{{AFX_MSG(CMyListCtrl)
virtual void PreSubclassWindow();
//}}AFX_MSG
// ...
};
In your .cpp file do this:
void CMyListCtrl::PreSubclassWindow()
{
// Place your init code here.
// Since the Window exists you can change styles, colors, etc.
CListCtrl::PreSubclassWindow(); // Call the base class's PreSubclassWindow() just in case
}
| What this info useful to you? You can donate to say thanks |
Add a comment
Sign in to add a comment