BOOL OnInitDialog()
{
CListBox wndListBox;
wndListBox.Attach (GetDlgItem (IDC_LIST1)->m_hWnd);
wndListBox.AddString (_T ("One"));
wndListBox.AddString (_T ("Two"));
wndListBox.AddString (_T ("Three"));
wndListBox.Detach ();
return true;
}

When I use this code above in BOOL OnInitDialog() function of CDialog class, this code below can't execute. (IDC_LIST1 is a member of IDD_DLTEST1). Can you explain for me ? If I want to open IDD_DLTEST1 dialog, What do I have to do?

void CallDialog()
{
Dlg d1(IDD_DLTEST1);
d1.DoModal();
}