Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ListControl in a Dialog box

Status
Not open for further replies.

mpsoutine

Programmer
Jan 6, 2003
87
0
0
US
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::DoModal()
{



/**************************************************************************
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::DoModal();


}
 
Over ride OnInitDialog and put this initialization code in there.
 
Hi,

Thanks for the input. It works like a charm.

Matthew
 
Hi, mpsoutine

I have the same problem that you had.
Would it be possible if you could post your PopulateItems function?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top