Browse - Programming Tips - How do I initialize a class I made that's derived from an existing MFC class?
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
virtual void PreSubclassWindow();
In your .cpp file do this:
// 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