Dear All,
I created a series of dialog boxes that share a common
control. I then wanted to create a single parent class for
these CDialog sub-classes to manage this shared control
and resize the windows (they are to be used for a tab
control). To do this I created a dialog resource
containing the shared control and then created a class for
this resource using class wizard. This class contains the
following methods:
CStatsDialog::CStatsDialog(CWnd* pParent /*=NULL*/)
{
ASSERT(FALSE);
Quote:
}
void CStatsDialog::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CStatsDialog)
DDX_Control(pDX, IDC_STATLIST, m_StatsList);
//}}AFX_DATA_MAP
Quote:
}
BEGIN_MESSAGE_MAP(CStatsDialog, CDialog)
//{{AFX_MSG_MAP(CStatsDialog)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
///////////////////////////////////////////////////////////
//////////////////
// CStatsDialog message handlers
CStatsDialog::CStatsDialog(UINT idd)
: ChildIDD(idd)
{
Quote:
}
void CStatsDialog::Create(RECT & rect, CGameCompObj &
dlgObj, CWnd * pParent)
{
WndRect = rect;
DlgObj = &dlgObj;
CDialog::Create(ChildIDD, pParent);
Quote:
}
BOOL CStatsDialog::OnInitDialog()
{
CDialog::OnInitDialog();
SetWindowPos(&wndTop, WndRect.left, WndRect.top,
WndRect.right - WndRect.left,
WndRect.bottom - WndRect.top, NULL);
// Fill in the stats info ctrl
m_StatsList.GetTextColor(); <<< Assert fails in
here
//m_StatsList.InsertColumn( 0, "Stat Name",
LVCFMT_LEFT, 200, 1);
//m_StatsList.InsertColumn( 0, "Stat Value",
LVCFMT_LEFT, 100, 1);
return TRUE; // return TRUE unless you set the
focus to a control
// EXCEPTION: OCX Property Pages
should return FALSE
Quote:
}
This class creates a modeless dialog box (because the
subclasses are dialog boxes in a tab control). After this
I created classes for all of the dialog boxes that are to
make up the tab control pages and changed all references
in these classes from CDialog to CStatsDialog. I then
called Create() from the containing dialog box to create
each tab page. The tab control pages appeared as expected.
The problem is that I can't access the shared control
m_StatsList. When I do this the assert fails in
_AFXCMN_INLINE COLORREF CListCtrl::GetTextColor() const
{ ASSERT(::IsWindow(m_hWnd)); return
(COLORREF) ::SendMessage(m_hWnd, LVM_GETTEXTCOLOR, 0,
0L); }
in AFXCMN.INI (ie. m_hWnd == NULL).
Can anyone suggest why I can't access the shared control?
Thanks for any help,
Hamish