Click here to Skip to main content
16,006,378 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: I'm Done!!! Pin
Nish Nishant12-May-02 15:35
sitebuilderNish Nishant12-May-02 15:35 
GeneralRe: I'm Done!!! Pin
Steve L.12-May-02 15:43
Steve L.12-May-02 15:43 
GeneralRe: I'm Done!!! Pin
Nish Nishant12-May-02 17:10
sitebuilderNish Nishant12-May-02 17:10 
QuestionDialog loop? Pin
12-May-02 13:27
suss12-May-02 13:27 
AnswerRe: Dialog loop? Pin
Corto Maltese12-May-02 14:42
Corto Maltese12-May-02 14:42 
AnswerRe: Dialog loop? Pin
Nish Nishant12-May-02 15:00
sitebuilderNish Nishant12-May-02 15:00 
AnswerRe: Dialog loop? Pin
Paul M Watt12-May-02 17:42
mentorPaul M Watt12-May-02 17:42 
Generalctypedptrarray Pin
pnpfriend12-May-02 12:25
pnpfriend12-May-02 12:25 
I have created CTypedPtrArray'<CPtrArray,FileInfo*>' fileArray; //ignore ' coz i don't have it on my application. ' is only for < to show on this site.
FileInfo is a class name:
<br />
class FileInfo <br />
{<br />
  public : <br />
    int status;<br />
    CString path;<br />
    CString name;<br />
    CString size;<br />
    CString createdTime;<br />
    CString lastWrite;<br />
    CString lastAccess;<br />
    CString type;<br />
};<br />

the problem is when i calling CreateFileArray()from method 1 . no problem at all. but when i call from method 2. there is a run time error. I'm calling the same way. but only calling once at the time. not calling from both of method 1 and 2.
<br />
<br />
void CSMPprojectDlg::CreateFileArray()<br />
{<br />
  HTREEITEM hItem = m_TreeCtrl.GetRootItem();<br />
  CreateEmptyFileArray(); // i have command this line since i'm calling createfilearray() only one time<br />
  CreateFileArray(hItem);<br />
}<br />
//by the way, is this the right way to empty the file array?<br />
void CSMPprojectDlg::CreateEmptyFileArray()<br />
{<br />
  int size = fileArray.GetSize();<br />
  if(size != 0)<br />
  {<br />
    AfxMessageBox("hi");<br />
    for (int i =0;i<size;i++)<br />
    { <br />
      FileInfo* fileinfo =fileArray.GetAt(i);<br />
      delete fileinfo;<br />
<br />
<br />
    }<br />
  }<br />
}<br />
<br />
void CSMPprojectDlg::CreateFileArray( HTREEITEM hItem)<br />
{<br />
  <br />
  while(hItem != NULL)<br />
  {<br />
    //if(m_TreeCtrl.GetCheck(hItem) != 0)<br />
    {<br />
      <br />
      FileInfo *fileinfo= new FileInfo();<br />
      fileinfo = (FileInfo*)m_TreeCtrl.GetItemData(hItem);      <br />
      MessageBox(fileinfo->name);<br />
      if(m_TreeCtrl.ItemHasChildren(hItem) )<br />
        CreateFileArray(m_TreeCtrl.GetChildItem(hItem));<br />
      if(fileinfo->status == FILE)<br />
      {<br />
        MessageBox(fileinfo->name);<br />
        fileArray.Add(fileinfo);<br />
      }<br />
    }<br />
      hItem = m_TreeCtrl.GetNextSiblingItem(hItem);<br />
  }<br />
} 



why can't i call from method 2????? Confused | :confused:
<br />
<br />
void CSMPprojectDlg::PrintChecked()<br />
{<br />
  // TODO: Add your control notification handler code here<br />
 UpdateData(TRUE);<br />
 <br />
 HTREEITEM hItem;<br />
 hItem=m_TreeCtrl.GetRootItem();<br />
 <br />
 if(!(IsAnyItemChecked(hItem,hItem)))<br />
   MessageBox("No file is checked!!"); <br />
 else<br />
   {<br />
      printedfileName.Empty();<br />
      int respond;<br />
      respond= GetLocationAndName(printedfileName);       // get location to save the qcfile.      <br />
      //the user has clicked on cancel <br />
<br />
      if (!respond)<br />
      {<br />
       // goto Exit;<br />
      printedfileName = "j:\\BlowBackQC\\"+Company+"_"+Job+"_"+CD+"_PrintedFileList.txt";<br />
      CString message = "The location and name of the file: \n\t"+printedfileName;<br />
      MessageBox(message);<br />
<br />
      }<br />
<br />
      QC_file.open(printedfileName); //creat a QC_file<br />
<br />
      QC_file<<"\t\t\t  Company Name: "<<Company<<"\n\t\t\t   CD Number: "<<CD<<"\n\t\t\t  Job Number: "<<Job<br />
             <<"\n\t\t\t     Total File: "<<File_counter<<"\n\t\t\t Total Folder: "<<Folder_counter<<endl<<setw(80)<<setfill('=')<<endl<br />
             <<setfill(' ')<<endl;<br />
<br />
      // change the header if the sort by type (1).<br />
      if(m_SortingWay == 1)<br />
        QC_file<<"  Date \t\t Size\t\tEsti_page_print\t\t Ext\t\t FileName\n"<<setw(80)<<setfill('=')<<endl<<setfill(' ')<<endl;<br />
      else<br />
        QC_file<<"  Date \t\t Size\t\tEsti_page_print\t\t FileName\n"<<setw(80)<<setfill('=')<<endl<<setfill(' ')<<endl;<br />
 <br />
//calling the same way. but run time error.    <br />
     CreateFileArray();<br />
  int size = fileArray.GetSize();<br />
  if(size !=0)<br />
  {<br />
      for(int i=0;i<size;i++)<br />
      {<br />
        FileInfo *fileinfo = new FileInfo();<br />
        fileinfo = fileArray.GetAt(i);<br />
        CString a = fileinfo->name +"\n"+ fileinfo->size;<br />
        MessageBox(a);<br />
        <br />
      }<br />
  }<br />
  QC_file.close(); <br />
  <br />
      <br />
      //begin the thread......for printing...<br />
      /*stopPrinting =1;<br />
      printingThread = AfxBeginThread(PrintingThreadFunction,this);//&m_hWnd,THREAD_PRIORITY_BELOW_NORMAL,0,CREATE_SUSPENDED);<br />
      printingThread->m_bAutoDelete = FALSE;<br />
        */   <br />
   }<br />
   printingThread =0;<br />
}<br />


}
Confused | :confused:
GeneralRe: ctypedptrarray Pin
Christian Graus12-May-02 13:06
protectorChristian Graus12-May-02 13:06 
GeneralHelp With A Matrix. Pin
nywebhead12-May-02 11:19
nywebhead12-May-02 11:19 
GeneralRe: Help With A Matrix. Pin
Christian Graus12-May-02 11:33
protectorChristian Graus12-May-02 11:33 
GeneralRe: Help With A Matrix. Pin
nywebhead12-May-02 11:57
nywebhead12-May-02 11:57 
GeneralRe: Help With A Matrix. Pin
nywebhead12-May-02 14:12
nywebhead12-May-02 14:12 
GeneralRe: Help With A Matrix. Pin
Nish Nishant12-May-02 15:04
sitebuilderNish Nishant12-May-02 15:04 
GeneralRe: Help With A Matrix. Pin
nywebhead12-May-02 15:58
nywebhead12-May-02 15:58 
GeneralRe: Help With A Matrix. Pin
Nish Nishant12-May-02 17:12
sitebuilderNish Nishant12-May-02 17:12 
QuestionHow do I change the color of a button. Pin
12-May-02 10:56
suss12-May-02 10:56 
AnswerRe: How do I change the color of a button. Pin
Neville Franks12-May-02 11:29
Neville Franks12-May-02 11:29 
GeneralRe: How do I change the color of a button. Pin
Nish Nishant12-May-02 15:06
sitebuilderNish Nishant12-May-02 15:06 
GeneralCapturing KeyStrokes Pin
12-May-02 9:56
suss12-May-02 9:56 
GeneralRe: Capturing KeyStrokes Pin
Michael Dunn12-May-02 10:21
sitebuilderMichael Dunn12-May-02 10:21 
GeneralRe: Capturing KeyStrokes Pin
Nish Nishant12-May-02 15:09
sitebuilderNish Nishant12-May-02 15:09 
QuestionHow to store a c constant in an int variable Pin
Sam M C12-May-02 9:50
Sam M C12-May-02 9:50 
AnswerRe: How to store a c constant in an int variable Pin
Maxwell Chen12-May-02 10:11
Maxwell Chen12-May-02 10:11 
GeneralRe: How to store a c constant in an int variable Pin
Sam M C12-May-02 10:25
Sam M C12-May-02 10:25 

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.