Hi,
I'm trying to populate a list control within a dialogbox with the records in a database. The user clicks on a "Show Employee List" button and a dialogbox appears. I'm trying to populate the the list control within DoModal().
The following runtime error was generated when I ran the program and debugged: I've figured out that I'm trying to get information about a window that does not exist yet. This makes sense but I can't figure out where I should put the code to get information about the List Control.
_AFXWIN_INLINE void CWnd::GetClientRect(LPRECT lpRect) const
{ ASSERT
:IsWindow(m_hWnd)); ::GetClientRect(m_hWnd, lpRect); }
Here is my Do Modal function.
int CCheckListDialog:
oModal()
{
/**************************************************************************
Beginning of code to populate the List Control
***************************************************************************/
CRect clientRect;
int colWidth;
m_lcEmployeeList.GetClientRect(&clientRect);
colWidth = clientRect.Width()/3;
CString FirstName = "First Name";
CString LastName = "Last Name";
CString Birthday = "Birthday";
m_lcEmployeeList.InsertColumn(0,FirstName,LVCFMT_CENTER,colWidth,-1);
m_lcEmployeeList.InsertColumn(1,LastName,LVCFMT_CENTER,colWidth,-1);
m_lcEmployeeList.InsertColumn(2,Birthday,LVCFMT_CENTER,colWidth,-1);
CPersonSet Tmpset;
CPersonSet* m_pSet = &Tmpset;
CListCtrl* pList;
pList = &m_lcEmployeeList;
Tmpset.PopulateItems(pList);
/**************************************************************************
End of code to populate List Control
***************************************************************************/
return CDialog:
oModal();
}
I'm trying to populate a list control within a dialogbox with the records in a database. The user clicks on a "Show Employee List" button and a dialogbox appears. I'm trying to populate the the list control within DoModal().
The following runtime error was generated when I ran the program and debugged: I've figured out that I'm trying to get information about a window that does not exist yet. This makes sense but I can't figure out where I should put the code to get information about the List Control.
_AFXWIN_INLINE void CWnd::GetClientRect(LPRECT lpRect) const
{ ASSERT
Here is my Do Modal function.
int CCheckListDialog:
{
/**************************************************************************
Beginning of code to populate the List Control
***************************************************************************/
CRect clientRect;
int colWidth;
m_lcEmployeeList.GetClientRect(&clientRect);
colWidth = clientRect.Width()/3;
CString FirstName = "First Name";
CString LastName = "Last Name";
CString Birthday = "Birthday";
m_lcEmployeeList.InsertColumn(0,FirstName,LVCFMT_CENTER,colWidth,-1);
m_lcEmployeeList.InsertColumn(1,LastName,LVCFMT_CENTER,colWidth,-1);
m_lcEmployeeList.InsertColumn(2,Birthday,LVCFMT_CENTER,colWidth,-1);
CPersonSet Tmpset;
CPersonSet* m_pSet = &Tmpset;
CListCtrl* pList;
pList = &m_lcEmployeeList;
Tmpset.PopulateItems(pList);
/**************************************************************************
End of code to populate List Control
***************************************************************************/
return CDialog:
}