CUserAdmin ua; // ua is a property page
CString header[2]={"Name","Password"};
for(int i=0;i<2;++i)
ua.m_List.InsertColumn(i,header[i]);
Could anybody help me? Thanks in advance.
Regards,
Xiao
In all likelihood, you're doing this way too early. In a dialog, the
MFC member variables for controls (like "m_List" in your example) don't
actually have Windows controls associated with them until OnInitDialog time;
if you try to do something earlier than that that requires the Windows
control to be present (like inserting columns into a list control), you'll
get the assertion failure in your debug build, and the call will fail.
Property pages work in the same way, with the added complication that
the Windows controls aren't created until the page actually becomes visible
to the user; in other words, you often can't assume that the controls will
_ever_ be created. (If you display a property sheet with three property
pages, and the user just clicks "OK" right away, then the second and third
pages will never have become visible, so their controls will never have been
created.)
To add columns to your list control, you should do it from your
CUserAdmin class's OnInitDialog handler, after that handler calls the base
class's OnInitDialog.
--
\o\ If you're interested in books and stories with transformation themes, \o\
/o/ please have a look at <URL:http://www.halcyon.com/phaedrus>. Thanks! /o/
\o\ FC1.21:FC(W/C)p6arw A- C->++ D>++ H+ M>+ P R T++++ W** Z+ Sm RLCT \o\
/o/ a cmn++++$ d e++ f+++ h- i++wf p-- sm# /o/
When are you using this code? I guess that your ua.m_List member does
not yet have a Window attached to it. I normally set the columns in a
dialog's OnInitDialog handler - after the call to the default
OnInitDialog (as that's what sets up the member variables if you're
using the DDX).
Dave
----
My address is altered to discourage junk mail.
Please post responses to the newsgroup thread,
there's no need for follow-up email copies.
Xiao <xia...@990.net> wrote in message news:#fH$I0#j#GA.199@cppssbbsa03...
> Hi everybody,
> I'm developing an application using a List Control. I drew the control
> in the resouce editor, and when I launched the program the control did
> display correctly. However after I added the following codes to insert 2
> columns into the list control the program popped out telling me "Debug
> Assertion Failed". The codes are:
>
> CUserAdmin ua; // ua is a property page
> CString header[2]={"Name","Password"};
>
> for(int i=0;i<2;++i)
> ua.m_List.InsertColumn(i,header[i]);
>
> Could anybody help me? Thanks in advance.
>
> Regards,
> Xiao
>
>
Bernd Wißler wrote in message
<968276C0E8D3D21199D200400550C38801099C@DRUBADIX>...