?
Solved

Cannot Convert from CProgressWnd to CProgressWnd

Posted on 2005-03-21
7
Medium Priority
?
286 Views
Last Modified: 2013-11-20
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
Comment
Question by:ptrennum
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
7 Comments
 
LVL 30

Expert Comment

by:Axter
ID: 13593900
Hi ptrennum,
Please post the exact error you're getting

David Maisonave :-)
Cheers!
0
 
LVL 30

Expert Comment

by:Axter
ID: 13593913
ptrennum,
Also, please post the class declaration for CProgressWnd.

David Maisonave :-}
0
 

Author Comment

by:ptrennum
ID: 13593955
Error:

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


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

PT
0
Technology Partners: 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!

 
LVL 30

Expert Comment

by:Axter
ID: 13594040
Please post the class declaration for CProgressWnd.

Particularly the constructors for class CProgressWnd.

Also please post the code for function 'CZip::RetrieveFileNamesFrom'
0
 

Author Comment

by:ptrennum
ID: 13594148
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
 
LVL 48

Accepted Solution

by:
AlexFM earned 2000 total points
ID: 13594235
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
 

Author Comment

by:ptrennum
ID: 13594269
Thanks - I haven't used it in the func yet but I will be.

PT
0

Featured Post

Technology Partners: 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!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses
Course of the Month11 days, 2 hours left to enroll

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question