Click here to Skip to main content
16,005,316 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Is This Thread Safe Pin
BobInNJ26-Dec-08 6:16
BobInNJ26-Dec-08 6:16 
GeneralRe: Is This Thread Safe Pin
Code-o-mat26-Dec-08 7:57
Code-o-mat26-Dec-08 7:57 
GeneralRe: Is This Thread Safe Pin
BobInNJ26-Dec-08 8:28
BobInNJ26-Dec-08 8:28 
GeneralRe: Is This Thread Safe Pin
Mark Salsbery26-Dec-08 10:20
Mark Salsbery26-Dec-08 10:20 
GeneralRe: Is This Thread Safe Pin
Code-o-mat26-Dec-08 10:56
Code-o-mat26-Dec-08 10:56 
GeneralRe: Is This Thread Safe Pin
Mark Salsbery26-Dec-08 11:27
Mark Salsbery26-Dec-08 11:27 
GeneralRe: Is This Thread Safe Pin
Code-o-mat26-Dec-08 10:38
Code-o-mat26-Dec-08 10:38 
Questioncannot delete CStringArray like this? [modified] Pin
kaviniswell25-Dec-08 15:58
kaviniswell25-Dec-08 15:58 
hi,
these days i want to learn CStringArray and CTypedPtrList,so i creat a listbox for this:

/// .h ///

private:
    // to save all listitem string,like 
    // [listitem0:string1] [listitem0:string2]...  
    // [listitem1:string1] [listitem1:string2]...   
    CTypedPtrList < CPtrList,CStringArray* > m_ptrListAllListItem;

/// .cpp ///

// to add one listitem
void CListboxstrDlg::OnBtnAddlistitem() 
{
    static int sItemIndex = 0;
    CString str;
    str.Format("[listitem%d]",sItemIndex++);
    int nSel = m_list.AddString(str);
  
    CStringArray* pstrArry = new CStringArray [1];
    ASSERT(pstrArry != NULL);
    TRACE("------the new pstrArry addr is:%x \n",pstrArry);  // the addr is:3850cc
    pstrArry->Add(str);
    m_ptrListAllListItem.AddTail((CStringArray*)pstrArry);

    m_list.SetCurSel(m_list.GetCount()-1);
}

// to del one listitem
void CListboxstrDlg::OnBtnDellistitem() 
{
    int nSel = m_list.GetCurSel();
    if (LB_ERR == nSel)
    {
        return;
    }

    POSITION pos;
    pos = m_ptrListAllListItem.FindIndex(nSel);
    if (pos)
    {
        CStringArray* ptStrArry;
        ptStrArry = (CStringArray*)m_ptrListAllListItem.GetAt(pos);   
        TRACE("the ptStrArry addr is %x \n",ptStrArry); // the addr also is:3850cc
          
        m_ptrListAllListItem.RemoveAt(pos);
        delete ptStrArry;    // but this line debug info:
        // HEAP[listboxstr.exe]: Invalid Address specified to RtlValidateHeap( 00380000, 003850AC )        
        // :(  the CStringArray cannot delete like this? :confused:
        
        m_list.DeleteString(nSel);
        m_list.SetCurSel(nSel - 1);
    }    
}


thank u very much!!

modified on Thursday, December 25, 2008 10:07 PM

AnswerRe: cannot delete CStringArray like this? Pin
kaviniswell25-Dec-08 16:12
kaviniswell25-Dec-08 16:12 
AnswerRe: cannot delete CStringArray like this? Pin
BobInNJ25-Dec-08 16:38
BobInNJ25-Dec-08 16:38 
GeneralRe: cannot delete CStringArray like this? [modified] Pin
kaviniswell25-Dec-08 17:31
kaviniswell25-Dec-08 17:31 
GeneralRe: cannot delete CStringArray like this? Pin
kaviniswell25-Dec-08 17:45
kaviniswell25-Dec-08 17:45 
GeneralRe: cannot delete CStringArray like this? Pin
Richard Andrew x6426-Dec-08 0:40
professionalRichard Andrew x6426-Dec-08 0:40 
GeneralRe: cannot delete CStringArray like this? Pin
kaviniswell26-Dec-08 1:23
kaviniswell26-Dec-08 1:23 
Questionwindow in thread Pin
dene9997025-Dec-08 13:00
dene9997025-Dec-08 13:00 
AnswerRe: window in thread Pin
Richard Andrew x6425-Dec-08 13:28
professionalRichard Andrew x6425-Dec-08 13:28 
QuestionAdding a .wav file as a resource in visual studio 2008 express, Hi, I need some help with this Pin
Sadaiyappan25-Dec-08 5:57
Sadaiyappan25-Dec-08 5:57 
AnswerRe: Adding a .wav file as a resource in visual studio 2008 express, Hi, I need some help with this Pin
Richard Andrew x6425-Dec-08 8:10
professionalRichard Andrew x6425-Dec-08 8:10 
GeneralRe: Adding a .wav file as a resource in visual studio 2008 express, Hi, I need some help with this Pin
Sadaiyappan25-Dec-08 8:18
Sadaiyappan25-Dec-08 8:18 
GeneralRe: Adding a .wav file as a resource in visual studio 2008 express, Hi, I need some help with this Pin
Richard Andrew x6425-Dec-08 8:20
professionalRichard Andrew x6425-Dec-08 8:20 
QuestionCAtlRegExp Match Pin
dehseth25-Dec-08 2:41
dehseth25-Dec-08 2:41 
AnswerRe: CAtlRegExp Match Pin
Yuriy Levytskyy25-Dec-08 5:24
Yuriy Levytskyy25-Dec-08 5:24 
AnswerRe: CAtlRegExp Match Pin
Stuart Dootson25-Dec-08 22:33
professionalStuart Dootson25-Dec-08 22:33 
Questionflcose API is taking so much time to close the large file [modified] Pin
Vishal Kumar Soni25-Dec-08 0:37
Vishal Kumar Soni25-Dec-08 0:37 
QuestionCAsyncSocket in CWinThread Pin
Mustapha Rédouane24-Dec-08 23:06
Mustapha Rédouane24-Dec-08 23:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.