Downloading from web page: status callback

My question is a simple one.  How can I get the "!" point to be displayed in the OnStatusCallback function?  I would think that the "!" would be printed a bunch before the code was displayed.  The ! is not displayed at all.

// Global functions
CString Read (CHttpFile *file);

// Classes
class CInternetSession2 : public CInternetSession
{ void OnStatusCallback (DWORD dwContext, DWORD dwInternetStatus, LPVOID lpvStatusInformation, DWORD dwStatusInformationLength);
};

void CInternetSession2::OnStatusCallback (DWORD dwContext, DWORD dwInternetStatus, LPVOID lpvStatusInformation, DWORD dwStatusInformationLength)
{ printf ("\r\n\r\n!\r\n\r\n"); // Doesn't display this, ever.
}

int _tmain (int argc, TCHAR* argv[], TCHAR* envp[])
{ if (!AfxWinInit (::GetModuleHandle (NULL), NULL, ::GetCommandLine (), 0))
  { printf ("Fatal Error: MFC initialization failed.");
    return 1;
  }

  CInternetSession2 session;
  CHttpFile *file;

  file = (CHttpFile *) session.OpenURL ("http://etc", 1);

  CString data = Read (file);
  printf (data);

  session.Close ();

  return 0;
}

// Reads all data from a CHttpFile, and then closes and deletes the file.
CString Read (CHttpFile *file)
{ CString ret;

  char data[2];
  int numbytes;

  for (;;)
  { memset (data, 0, 2);

    numbytes = file->Read (data, 1);
    data[numbytes] = 0; // VERY important.
    ret += data;

    if (numbytes == 0)
    { break; }
  }

  file->Close ();
  delete file;

  return ret;
}
joeshmoAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

jhanceCommented:
Are you sure that CInternetSession2::OnStatusCallback is even getting called?
0
joeshmoAuthor Commented:
That's probably part of the question.  I strongly doubt it's even being called.  The code for the web pages print out to the screen without a problem.  There are no exclamation marks however.

Why isn't it being called?  How can I get it to be called?
0
jhanceCommented:
Where are you calling EnableStatusCallback()?  I don't see it here.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
joeshmoAuthor Commented:
That was what the problem was.  I must have forgotten to add it because I knew it was necessary.  Oops.  Thanks for your help!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.