Click here to Skip to main content
15,926,062 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionWhen resizing, some child control doesn't show correctly until I put the mouse curson on it Pin
followait6-May-08 16:42
followait6-May-08 16:42 
AnswerRe: When resizing, some child control doesn't show correctly until I put the mouse curson on it Pin
Naveen6-May-08 17:34
Naveen6-May-08 17:34 
GeneralRe: When resizing, some child control doesn't show correctly until I put the mouse curson on it Pin
followait6-May-08 23:02
followait6-May-08 23:02 
Questionhttp download question Pin
monsieur_jj6-May-08 16:28
monsieur_jj6-May-08 16:28 
AnswerRe: http download question Pin
Randor 6-May-08 16:46
professional Randor 6-May-08 16:46 
GeneralRe: http download question Pin
monsieur_jj6-May-08 16:57
monsieur_jj6-May-08 16:57 
GeneralRe: http download question Pin
Randor 6-May-08 17:16
professional Randor 6-May-08 17:16 
GeneralRe: http download question Pin
monsieur_jj6-May-08 21:20
monsieur_jj6-May-08 21:20 
This is my new code, I believe the code finally locates the zip file however the download is incomplete and i cant open the zip file. The zip file should be around 500mb i only get 2kb.

<br />
hOpen = InternetOpen("PauseResumeDemo",INTERNET_OPEN_TYPE_PRECONFIG ,NULL, NULL, NULL);<br />
	if(!hOpen)<br />
	{<br />
         return false;<br />
	}<br />
<br />
	DWORD dwContext = 123;<br />
<br />
	strStaus.Format("Connecting to server..");<br />
	GetDlgItem(IDC_STATIC_STATUSNEW)->SetWindowText(strStaus);<br />
<br />
	if ( !(hConnect = InternetConnect ( hOpen, "10.5.1.4" , INTERNET_DEFAULT_HTTP_PORT, NULL, NULL, INTERNET_SERVICE_HTTP, 0  , 0) ) )<br />
	{<br />
		CString strMsg;<br />
		string strReposeFromServer;<br />
		GetLastResponse(strReposeFromServer);<br />
		strMsg.Format("Error:%d\nDescription:%s", GetLastError(), strReposeFromServer.c_str());<br />
		AfxMessageBox(strMsg, MB_OK);<br />
		return false;<br />
	}<br />
	<br />
	strStaus.Format("Finding out if this server supoprts Pause & Resume..");<br />
	GetDlgItem(IDC_STATIC_STATUSNEW)->SetWindowText(strStaus);<br />
	<br />
	hHttpRequest = HttpOpenRequest( hConnect, "GET", "downloads/", NULL, NULL, NULL, 0, 0);<br />
	hHttpRequest = HttpOpenRequest( hConnect, "GET", "Managepoint/", NULL, NULL, NULL, 0, 0);<br />
	hHttpRequest = HttpOpenRequest( hConnect, "GET", strFileNameAtServer.c_str(), NULL, NULL, NULL, 0, 0);<br />
<br />
	if(FindPauseResumeSupported(hHttpRequest))<br />
	{<br />
		strStaus.Format("Pause & Resume Supported..");<br />
		GetDlgItem(IDC_STATIC_STATUSNEW)->SetWindowText(strStaus);<br />
	}<br />
	else<br />
	{<br />
		strStaus.Format("Pause & Resume not Supported..");<br />
		GetDlgItem(IDC_STATIC_STATUSNEW)->SetWindowText(strStaus);<br />
	}<br />
<br />
<br />
	double dCurrentFileSize;<br />
<br />
	if(IfLocalFileExist(strTmpFileName.c_str(), &dCurrentFileSize)) <br />
	{<br />
		dOffsetToSeek				= dCurrentFileSize;<br />
	}<br />
	<br />
<br />
   if  ( !(pFile = fopen (strTmpFileName.c_str(), "ab" ) ) )<br />
   {<br />
		CString strMsg;<br />
		strMsg.Format("Error:%d", GetLastError());<br />
		AfxMessageBox(strMsg, MB_OK); <br />
        return false;<br />
   }<br />
<br />
   if(dOffsetToSeek >=0)<br />
   {<br />
		strStaus.Format("Seeking to local file...");<br />
		GetDlgItem(IDC_STATIC_STATUSNEW)->SetWindowText(strStaus);<br />
<br />
	   int n = fseek(pFile, dOffsetToSeek, SEEK_SET);<br />
   }<br />
<br />
<br />
	dwBytesWrrittenToFile = dOffsetToSeek;<br />
	GetDlgItem(IDC_BUTTON2)->EnableWindow(TRUE);<br />
<br />
   do<br />
   {<br />
		   PUMPMESSAGE();<br />
<br />
		   //Intentional delay so that user get chance to hit stop button<br />
		   Sleep(100);<br />
		   <br />
		   strStaus.Format("Sending RETRIVE..");<br />
		   GetDlgItem(IDC_STATIC_STATUSNEW)->SetWindowText(strStaus);<br />
			<br />
			if(m_bStopped)<br />
			{<br />
				strStaus.Format("Stopped..");<br />
				GetDlgItem(IDC_STATIC_STATUSNEW)->SetWindowText(strStaus);<br />
				<br />
				AfxMessageBox("Download aborted\nThere is an incomplete temp file 'Temp_ManagePoint431InstallerBuild_47.zip' at current directory. Don't delete it just check it out. It has useful data downloaded so far...\nOnce you are done click Start again, now download will start from exact location where it left off");<br />
<br />
				m_bStopped = FALSE;<br />
				bInComplete = TRUE;<br />
				GetDlgItem(IDC_BUTTON1)->EnableWindow(TRUE);<br />
				GetDlgItem(IDC_BUTTON2)->EnableWindow(FALSE);<br />
				break;<br />
			}<br />
			<br />
			if (!InternetReadFile (hHttpRequest, (LPVOID)pBuffer, dwToRead,  &dwSize) )<br />
			{<br />
				fclose (pFile);<br />
				CString strMsg;<br />
				string strReposeFromServer;<br />
				GetLastResponse(strReposeFromServer);<br />
				strMsg.Format("Error:%d\nDescription:%s", GetLastError(), strReposeFromServer.c_str());<br />
				AfxMessageBox(strMsg, MB_OK); <br />
				return false;<br />
			}<br />
          if (!dwSize)<br />
		  {<br />
			m_ProgressCtl.SetPos(100);<br />
			CString	strTmpPercentage;<br />
			strTmpPercentage.Format("Percentage Completed:%d%%", 100);<br />
			GetDlgItem(IDC_STATIC_PERCENTAGE)->SetWindowText(strTmpPercentage);<br />
			break;  // Condition of dwSize=0 indicate EOF. Stop.<br />
		  }<br />
          else<br />
		  {<br />
			fwrite(pBuffer, sizeof (char), dwSize , pFile);<br />
<br />
			dwBytesWrrittenToFile = dwBytesWrrittenToFile + dwSize;<br />
<br />
			int nPercentageComplete = (int)floor(((dwBytesWrrittenToFile) * 100)/dFileSize);<br />
<br />
			CString	strTmpPercentage;<br />
			strTmpPercentage.Format("Percentage Completed:%d%%", nPercentageComplete);<br />
			GetDlgItem(IDC_STATIC_PERCENTAGE)->SetWindowText(strTmpPercentage);<br />
<br />
			//m_pMainFrame->m_ProgressCtl.SetBkColor(RGB(0, 255, 0));<br />
			int nLower, nUpper;<br />
			m_ProgressCtl.GetRange(nLower, nUpper );<br />
<br />
			m_ProgressCtl.SetPos(((nUpper-nLower)/100) * nPercentageComplete);<br />
		  }<br />
       }   // do<br />
      while (TRUE);<br />
<br />
	fflush (pFile);<br />
	fclose (pFile);<br />
	delete [] pBuffer;<br />
<br />
<br />
	if(!bInComplete)<br />
	{<br />
		strStaus.Format("Renaming file at local machine..");<br />
		GetDlgItem(IDC_STATIC_STATUSNEW)->SetWindowText(strStaus);<br />
<br />
		if(!MoveFile(strTmpFileName.c_str(), strFileNameAtLocalMachine.c_str() ))<br />
		{<br />
			CString strMsg;<br />
			strMsg.Format("Error:%d", GetLastError());<br />
			AfxMessageBox(strMsg, MB_OK); <br />
<br />
		}<br />
		strStaus.Format("Done..");<br />
		GetDlgItem(IDC_STATIC_STATUSNEW)->SetWindowText(strStaus);<br />
	}<br />
<br />
	if(!bInComplete)<br />
	{<br />
		AfxMessageBox("File has downloaded..");<br />
		GetDlgItem(IDC_BUTTON2)->EnableWindow(FALSE);<br />
		GetDlgItem(IDC_BUTTON1)->EnableWindow(FALSE);<br />
	}<br />
<br />
	if(hConnect)<br />
	  InternetCloseHandle(hConnect);<br />
	if(hOpen)<br />
		InternetCloseHandle(hOpen);<br />
	if(hOpenFile)<br />
		InternetCloseHandle(hOpenFile);<br />
<br />
	  return TRUE;<br />

GeneralRe: http download question Pin
Randor 7-May-08 4:01
professional Randor 7-May-08 4:01 
GeneralRe: http download question Pin
monsieur_jj7-May-08 15:23
monsieur_jj7-May-08 15:23 
Questionsomething wrong when use createservice Pin
abruzzi6-May-08 14:48
abruzzi6-May-08 14:48 
AnswerRe: something wrong when use createservice Pin
Randor 6-May-08 15:25
professional Randor 6-May-08 15:25 
GeneralRe: something wrong when use createservice Pin
abruzzi6-May-08 15:34
abruzzi6-May-08 15:34 
GeneralRe: something wrong when use createservice Pin
Randor 6-May-08 15:55
professional Randor 6-May-08 15:55 
GeneralRe: something wrong when use createservice Pin
abruzzi6-May-08 16:33
abruzzi6-May-08 16:33 
GeneralRe: something wrong when use createservice Pin
Randor 6-May-08 16:58
professional Randor 6-May-08 16:58 
GeneralRe: something wrong when use createservice Pin
JudyL_MD7-May-08 3:02
JudyL_MD7-May-08 3:02 
QuestionCan I use a local Bitmap object constructor a global CachedBitmap object? Pin
followait6-May-08 14:08
followait6-May-08 14:08 
AnswerRe: Can I use a local Bitmap object constructor a global CachedBitmap object? Pin
Randor 6-May-08 15:21
professional Randor 6-May-08 15:21 
AnswerRe: Can I use a local Bitmap object constructor a global CachedBitmap object? Pin
Saurabh.Garg6-May-08 15:27
Saurabh.Garg6-May-08 15:27 
Questionrestore data to edit box when double click a file Pin
lahom6-May-08 13:46
lahom6-May-08 13:46 
AnswerRe: restore data to edit box when double click a file Pin
Hamid_RT6-May-08 17:25
Hamid_RT6-May-08 17:25 
AnswerRe: restore data to edit box when double click a file Pin
dehseth6-May-08 19:59
dehseth6-May-08 19:59 
GeneralRe: restore data to edit box when double click a file Pin
lahom7-May-08 2:23
lahom7-May-08 2:23 
GeneralRe: restore data to edit box when double click a file Pin
lahom8-May-08 17:13
lahom8-May-08 17:13 

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.