Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 294
  • Last Modified:

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
0
ptrennum
Asked:
ptrennum
  • 3
  • 3
1 Solution
 
AxterCommented:
Hi ptrennum,
Please post the exact error you're getting

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

David Maisonave :-}
0
 
ptrennumAuthor Commented:
Error:

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


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

PT
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
AxterCommented:
Please post the class declaration for CProgressWnd.

Particularly the constructors for class CProgressWnd.

Also please post the code for function 'CZip::RetrieveFileNamesFrom'
0
 
ptrennumAuthor Commented:
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;
}
0
 
AlexFMCommented:
If CProgressWnd is CWnd-derived, it is impossible to pass it by value. Replace RetrieveFileNamesFrom function prototype with:

DWORD CZip::RetrieveFileNamesFrom(char *Path, CFile backupLog,CProgressWnd* wndProgress)

or

DWORD CZip::RetrieveFileNamesFrom(char *Path, CFile backupLog,CProgressWnd& wndProgress)

Actually, I don't see why do you need this parameter since it is not used.
0
 
ptrennumAuthor Commented:
Thanks - I haven't used it in the func yet but I will be.

PT
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now