Link to home
Start Free TrialLog in
Avatar of ptrennum
ptrennum

asked on

Cannot Convert from CProgressWnd to CProgressWnd

I have a recursive function that takes a parameter of CProgressWnd.  In the middle of the function there is a call to itself:

RetrieveFileNamesFrom(AddPath,backupLog,wndProgress);

It throws the error mentioned in the question title.  I'm not sure why it would have a problem converting from itself to itself??  Anyone know why this is?

PT
Avatar of Axter
Axter
Flag of United States of America image

Hi ptrennum,
Please post the exact error you're getting

David Maisonave :-)
Cheers!
ptrennum,
Also, please post the class declaration for CProgressWnd.

David Maisonave :-}
Avatar of ptrennum
ptrennum

ASKER

Error:

error C2664: 'CZip::RetrieveFileNamesFrom' : cannot convert parameter 3 from 'CProgressWnd' to 'CProgressWnd'


DEclaration:
CProgressWnd wndProgress(this, "Progress", TRUE);

PT
Please post the class declaration for CProgressWnd.

Particularly the constructors for class CProgressWnd.

Also please post the code for function 'CZip::RetrieveFileNamesFrom'
CProgressWnd::CProgressWnd()
{
    CommonConstruct();
}

CProgressWnd::CProgressWnd(CWnd* pParent, LPCTSTR pszTitle, BOOL bSmooth /* = FALSE */)
{
    CommonConstruct();
    m_strTitle = pszTitle;

    Create(pParent, pszTitle, bSmooth);
}

void CProgressWnd::CommonConstruct()
{

    m_wRenenableWnd  = NULL;

    m_nNumTextLines  = 4;
    m_nPrevPos       = 0;
    m_nPrevPercent   = 0;
    m_nStep          = 1;
    m_nMinValue      = 0;
    m_nMaxValue      = 100;

    m_strTitle       = _T("Progress");
    m_strCancelLabel = _T(" Cancel ");
    m_bCancelled     = FALSE;
    m_bModal         = FALSE;

    m_bPersistantPosition = TRUE;   // saves and restores position automatically
}



DWORD CZip::RetrieveFileNamesFrom(char *Path, CFile backupLog,CProgressWnd wndProgress)
{
      HANDLE findHndl;
      char FilePath[MAX_PATH], SrchPath[MAX_PATH], AddPath[MAX_PATH];
      WIN32_FIND_DATA fileInfo;
      DWORD ls;
      static const char newLine[] = "\r\n";


      FilePath[0]=0;
      if (Path[0] != '\\' && Path[1] != ':')
      {
            GetCurrentDirectory(MAX_PATH, FilePath);
            ls=strlen(FilePath);
            if (ls != 0)
                  ls--;
            if (FilePath[ls] != '\\')
                  strcat(FilePath, "\\");
      }
      strcat(FilePath, Path);

      ls=strlen(FilePath);
      if (ls != 0)
            ls--;

      if (FilePath[ls] != '\\')
      {
            if ((findHndl=FindFirstFile(FilePath, &fileInfo)) != INVALID_HANDLE_VALUE)
            {
                  if ((fileInfo.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY) != FILE_ATTRIBUTE_DIRECTORY)
                  {
                        backupLog.Write(FilePath, lstrlen(FilePath));
                        backupLog.Write(newLine, lstrlen(newLine));
                        AddNameToList(FilePath);
                        FindClose(findHndl);
                        return TRUE;
                  }
                  else
                        FindClose(findHndl);
            }
            strcat(FilePath, "\\");
      }
      
      strcpy(SrchPath, FilePath);
      strcat(SrchPath, "*.*");

      if ((findHndl=FindFirstFile(SrchPath, &fileInfo)) == INVALID_HANDLE_VALUE)
            return FALSE;

      do
      {
            sprintf(AddPath, "%s%s", FilePath, fileInfo.cFileName);
            if (fileInfo.cFileName[0] != '.')
            {
                  if ((fileInfo.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY)
                        RetrieveFileNamesFrom(AddPath,backupLog,wndProgress);
                  else
                  {
                        backupLog.Write(AddPath, lstrlen(AddPath));      
                        backupLog.Write(newLine, lstrlen(newLine));
                        AddNameToList(AddPath);
                  }
            }
      }
      while(FindNextFile(findHndl, &fileInfo) != 0);
      FindClose(findHndl);
      return TRUE;
}
ASKER CERTIFIED SOLUTION
Avatar of AlexFM
AlexFM

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks - I haven't used it in the func yet but I will be.

PT