Click here to Skip to main content
11,702,467 members (73,497 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VS2005 C++ MFC
Hi all,

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

i tried this code like below :

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 11-Apr-12 23:51pm
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

It Worked Like That :

// 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

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

pointing to the Assert Statement (below)

_AFXWIN_INLINE int CFont::GetLogFont(LOGFONT* pLogFont)
    { ASSERT(m_hObject != NULL);
        return ::GetObject(m_hObject, sizeof(LOGFONT), pLogFont); }
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

You declared a pointer to the list control without assigning the address of an existing list control. The solution is to allocate memory:
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:
CListCtrl TmpCobA;
TmpCobA.Create(WS_CHILD|WS_VISIBLE|WS_BORDER|LVS_REPORT,
    CRect(10,10,400,200), NULL, 1);
  Permalink  

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

  Print Answers RSS
0 Maciej Los 515
1 Sergey Alexandrovich Kryukov 355
2 OriginalGriff 299
3 CHill60 145
4 Mika Wendelius 115
0 OriginalGriff 8,369
1 Sergey Alexandrovich Kryukov 7,547
2 CPallini 4,922
3 Maciej Los 4,411
4 Mika Wendelius 3,556


Advertise | Privacy | Mobile
Web04 | 2.8.150819.1 | Last Updated 12 Apr 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100