Click here to Skip to main content
15,879,535 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi all,

My issue is clear, I wanna to create a CListCtrl into a FormView Dynamically.

i tried this code like below :

C++
CListCtrl* TmpCobA;
TmpCobA->Create(WS_CHILD|WS_VISIBLE|WS_BORDER|LVS_REPORT,
    CRect(10,10,400,200), NULL, 1);



but when debugging it said

Run-Time Check Failure #3 - The variable 'TmpCobA' is being used without being defined.
Posted

It Worked Like That :

C#
// TODO: Add extra initialization here
    CListCtrl* TmpCobA = new CListCtrl;

    TmpCobA ->Create(WS_CHILD | WS_VISIBLE,
    CRect(10, 10, 320, 280), this, 0x285);


The Main Work is that i wanna create a custom control (the CMultilineList)

But It crashes

C#
CMultilineList *lstCtrl = new CMultilineList;
lstCtrl->Create(this, CRect(10, 10, 320, 280), 0x285, WS_CHILD | WS_VISIBLE);


pointing to the Assert Statement (below)

C#
_AFXWIN_INLINE int CFont::GetLogFont(LOGFONT* pLogFont)
    { ASSERT(m_hObject != NULL);
        return ::GetObject(m_hObject, sizeof(LOGFONT), pLogFont); }
 
Share this answer
 
You declared a pointer to the list control without assigning the address of an existing list control. The solution is to allocate memory:
C++
CListCtrl* TmpCobA = new CListCtrl;
TmpCobA->Create(WS_CHILD|WS_VISIBLE|WS_BORDER|LVS_REPORT,
    CRect(10,10,400,200), NULL, 1);

or use a local variable:
C++
CListCtrl TmpCobA;
TmpCobA.Create(WS_CHILD|WS_VISIBLE|WS_BORDER|LVS_REPORT,
    CRect(10,10,400,200), NULL, 1);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900