亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? downdlg.cpp

?? 本程序是VC為平臺(tái)開發(fā)的股票資訊系統(tǒng)
?? CPP
字號(hào):
// DownDlg.cpp : implementation file
//

#include "stdafx.h"
#include "Resource.h"
#include "DownDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

const UINT WM_HTTPDOWNLOAD_THREAD_FINISHED = WM_APP + 10;

/////////////////////////////////////////////////////////////////////////////
// CDownDlg dialog
IMPLEMENT_DYNAMIC(CDownDlg, CDialog);

CDownDlg::CDownDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CDownDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CDownDlg)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
	m_hInternetSession = NULL;
	m_hHttpConnection = NULL;
	m_hHttpFile = NULL;
	m_bAbort = FALSE;
	m_bSafeToClose = FALSE;
	m_pThread = NULL;
	m_bOverwrite = FALSE;
}


void CDownDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CDownDlg)
	DDX_Control(pDX, IDC_ANIMATE1, m_ctrlAnimate);
	DDX_Control(pDX, IDC_PROGRESS1, m_ctrlProgress);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CDownDlg, CDialog)
	//{{AFX_MSG_MAP(CDownDlg)
	ON_WM_DESTROY()
	ON_WM_CLOSE()
	//}}AFX_MSG_MAP
	ON_MESSAGE(WM_HTTPDOWNLOAD_THREAD_FINISHED, OnThreadFinished)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDownDlg message handlers

LRESULT CDownDlg::OnThreadFinished(WPARAM wParam, LPARAM /*lParam*/)
{
	//It's now safe to close since the thread has signaled us
	m_bSafeToClose = TRUE;

	//Stop the animation
	m_ctrlAnimate.Stop();

	//If an error occured display the message box
	if (m_bAbort)
		EndDialog(IDCANCEL);
	else if (wParam)
	{
		AfxMessageBox(m_sError);
		EndDialog(IDCANCEL);
	}
	else
		EndDialog(IDOK);

	return 0L;
}

BOOL CDownDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	// Setup the animation control
	m_ctrlAnimate.Open(IDR_AVI_UPDATE);

	//Validate the URL
	ASSERT(m_sURLToDownload.GetLength()); //Did you forget to specify the file to download
	if (!AfxParseURL(m_sURLToDownload, m_dwServiceType, m_sServer, m_sObject, m_nPort))
	{
		//Try sticking "http://" before it
		m_sURLToDownload = _T("http://") + m_sURLToDownload;
		if (!AfxParseURL(m_sURLToDownload, m_dwServiceType, m_sServer, m_sObject, m_nPort))
		{
			TRACE(_T("Failed to parse the URL: %s\n"), m_sURLToDownload);
			EndDialog(IDCANCEL);
			return TRUE;
		}
	}

	//Check to see if the file we are downloading to exists and if
	//it does, then ask the user if they were it overwritten
	if(!m_sFileToDownloadInto.IsEmpty())
	{
		CFileStatus fs;
		ASSERT(m_sFileToDownloadInto.GetLength());
		if (!m_bOverwrite && CFile::GetStatus(m_sFileToDownloadInto, fs))
		{
			CString sMsg;
			AfxFormatString1(sMsg, IDS_OK_TO_OVERWRITE, m_sFileToDownloadInto);
			if (AfxMessageBox(sMsg, MB_YESNO) != IDYES)
			{
				TRACE(_T("Failed to confirm file overwrite, download aborted\n"));
				EndDialog(IDCANCEL);
				return TRUE;
			}
		}

		//Try and open the file we will download into
		if (!m_FileToWrite.Open(m_sFileToDownloadInto, CFile::modeCreate | CFile::modeWrite | CFile::shareDenyWrite))
		{
			TRACE(_T("Failed to open the file to download into, Error:%d\n"), GetLastError());
			CString sError;
			sError.Format(_T("%d"), ::GetLastError());
			CString sMsg;
			AfxFormatString1(sMsg, IDS_FAIL_FILE_OPEN, sError);
			AfxMessageBox(sMsg);
			EndDialog(IDCANCEL);
			return TRUE;
		}
	}

	//Pull out just the filename component
	int nSlash = m_sObject.ReverseFind(_T('/'));
	if (nSlash == -1)
		nSlash = m_sObject.ReverseFind(_T('\\'));
	if (nSlash != -1 && m_sObject.GetLength() > 1)
		m_sFilename = m_sObject.Right(m_sObject.GetLength() - nSlash - 1);
	else
		m_sFilename = m_sObject;

	//Spin off the background thread which will do the actual downloading
	m_pThread = AfxBeginThread(_DownloadThread, this, THREAD_PRIORITY_NORMAL, CREATE_SUSPENDED);
	if (m_pThread == NULL)
	{
		TRACE(_T("Failed to create download thread, dialog is aborting\n"));
		EndDialog(IDCANCEL);
		return TRUE;
	}
	m_pThread->m_bAutoDelete = FALSE;
	m_pThread->ResumeThread();
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

UINT CDownDlg::_DownloadThread(LPVOID pParam)
{
	//Convert from the SDK world to the C++ world
	CDownDlg* pDlg = (CDownDlg*) pParam;
	ASSERT(pDlg);
	ASSERT(pDlg->IsKindOf(RUNTIME_CLASS(CDownDlg)));
	pDlg->DownloadThread();
	return 0;
}

void CDownDlg::SetProgressRange(DWORD dwFileSize)
{
	m_ctrlProgress.SetRange(0, (short)((dwFileSize+512)/1024));
}

void CDownDlg::SetProgress(DWORD dwBytesRead)
{
	m_ctrlProgress.SetPos(dwBytesRead/1024);
}

void CDownDlg::PlayAnimation()
{
	m_ctrlAnimate.Play(0, (UINT)-1, (UINT)-1);
}

void CDownDlg::HandleThreadErrorWithLastError(UINT nIDError, DWORD dwLastError)
{
	//Form the error string to report
	CString sError;
	if (dwLastError)
		sError.Format(_T("%d"), dwLastError);
	else
		sError.Format(_T("%d"), ::GetLastError());
	AfxFormatString1(m_sError, nIDError, sError);

	//Delete the file being downloaded to if it is present
	if(!m_sFileToDownloadInto.IsEmpty())
		m_FileToWrite.Close();
	::DeleteFile(m_sFileToDownloadInto);

	PostMessage(WM_HTTPDOWNLOAD_THREAD_FINISHED, 1);
}

void CDownDlg::HandleThreadError(UINT nIDError)
{
	m_sError.LoadString(nIDError);
	PostMessage(WM_HTTPDOWNLOAD_THREAD_FINISHED, 1);
}

void CDownDlg::DownloadThread()
{
	//Create the Internet session handle
	ASSERT(m_hInternetSession == NULL);
	m_hInternetSession = ::InternetOpen(NULL, INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
	if (m_hInternetSession == NULL)
	{
		TRACE(_T("Failed in call to InternetOpen, Error:%d\n"), ::GetLastError());
		HandleThreadErrorWithLastError(IDS_HTTPDOWNLOAD_GENERIC_ERROR);
		return;
	}

	//Should we exit the thread
	if (m_bAbort)
	{
		PostMessage(WM_HTTPDOWNLOAD_THREAD_FINISHED);
		return;
	}  

	//Should we exit the thread
	if (m_bAbort)
	{
		PostMessage(WM_HTTPDOWNLOAD_THREAD_FINISHED);
		return;
	}  

	//Make the connection to the HTTP server          
	ASSERT(m_hHttpConnection == NULL);
	if (m_sUserName.GetLength())
		m_hHttpConnection = ::InternetConnect(m_hInternetSession, m_sServer, m_nPort, m_sUserName, 
			m_sPassword, m_dwServiceType, 0, (DWORD) this);
	else
		m_hHttpConnection = ::InternetConnect(m_hInternetSession, m_sServer, m_nPort, NULL, 
			NULL, m_dwServiceType, 0, (DWORD) this);
	if (m_hHttpConnection == NULL)
	{
		TRACE(_T("Failed in call to InternetConnect, Error:%d\n"), ::GetLastError());
		HandleThreadErrorWithLastError(IDS_FAIL_CONNECT_SERVER);
		return;
	}

	//Should we exit the thread
	if (m_bAbort)
	{
		PostMessage(WM_HTTPDOWNLOAD_THREAD_FINISHED);
		return;
	}  

	//Start the animation to signify that the download is taking place
	PlayAnimation();

	//Issue the request to read the file
	LPCTSTR ppszAcceptTypes[2], lpszVerb;
	ppszAcceptTypes[0] = _T("*/*");  //We support accepting any mime file type since this is a simple download of a file
	ppszAcceptTypes[1] = NULL;
	ASSERT(m_hHttpFile == NULL);
	if(m_sFormData.IsEmpty())
		lpszVerb = NULL;
	else
		lpszVerb = _T("POST");
	m_hHttpFile = HttpOpenRequest(m_hHttpConnection, lpszVerb, m_sObject, NULL, NULL, ppszAcceptTypes, INTERNET_FLAG_RELOAD | 
		INTERNET_FLAG_DONT_CACHE | INTERNET_FLAG_KEEP_CONNECTION, (DWORD) this);
	if (m_hHttpFile == NULL)
	{
		TRACE(_T("Failed in call to HttpOpenRequest, Error:%d\n"), ::GetLastError());
		HandleThreadErrorWithLastError(IDS_FAIL_CONNECT_SERVER);
		return;
	}

	//Should we exit the thread
	if (m_bAbort)
	{
		PostMessage(WM_HTTPDOWNLOAD_THREAD_FINISHED);
		return;
	}  

	//label used to jump to if we need to resend the request
	resend:

	//Issue the request
	LPCTSTR lpszHeaders = NULL;
	LPCTSTR lpszFormData = NULL;
	DWORD	dwHeadersLength = 0;
	DWORD	dwFormDataLength = 0;
	if(!m_sFormData.IsEmpty())
	{
		lpszHeaders = _T("Content-Type: application/x-www-form-urlencoded");
		dwHeadersLength = strlen(lpszHeaders);
		lpszFormData = m_sFormData;
		dwFormDataLength = m_sFormData.GetLength();
	}
	BOOL bSend = ::HttpSendRequest(m_hHttpFile, lpszHeaders, dwHeadersLength, (LPVOID)lpszFormData, dwFormDataLength);
	if (!bSend)
	{
		TRACE(_T("Failed in call to HttpSendRequest, Error:%d\n"), ::GetLastError());
		HandleThreadErrorWithLastError(IDS_FAIL_CONNECT_SERVER);
		return;
	}

	//Check the HTTP status code
	TCHAR szStatusCode[32];
	DWORD dwInfoSize = 32;
	if (!HttpQueryInfo(m_hHttpFile, HTTP_QUERY_STATUS_CODE, szStatusCode, &dwInfoSize, NULL))
	{
		TRACE(_T("Failed in call to HttpQueryInfo for HTTP query status code, Error:%d\n"), ::GetLastError());
		HandleThreadError(IDS_HTTPDOWNLOAD_INVALID_SERVER_RESPONSE);
		return;
	}
	else
	{
		long nStatusCode = _ttol(szStatusCode);

		//Handle any authentication errors
		if (nStatusCode == HTTP_STATUS_PROXY_AUTH_REQ || nStatusCode == HTTP_STATUS_DENIED)
		{
			// We have to read all outstanding data on the Internet handle
			// before we can resubmit request. Just discard the data.
			char szData[51];
			DWORD dwSize;
			
			do
			{
				::InternetReadFile(m_hHttpFile, (LPVOID)szData, 50, &dwSize);
			}
			while (dwSize != 0);

			//Bring up the standard authentication dialog
			if (::InternetErrorDlg(GetSafeHwnd(), m_hHttpFile, ERROR_INTERNET_INCORRECT_PASSWORD, FLAGS_ERROR_UI_FILTER_FOR_ERRORS |
					FLAGS_ERROR_UI_FLAGS_GENERATE_DATA | FLAGS_ERROR_UI_FLAGS_CHANGE_OPTIONS, NULL) == ERROR_INTERNET_FORCE_RETRY)
			goto resend;
		}
  		else if (nStatusCode != HTTP_STATUS_OK)
		{
			TRACE(_T("Failed to retrieve a HTTP 200 status, Status Code:%d\n"), nStatusCode);
			HandleThreadErrorWithLastError(IDS_HTTPDOWNLOAD_INVALID_HTTP_RESPONSE, nStatusCode);
			return;
		}
	}

	// Get the length of the file.            
	TCHAR szContentLength[32];
	dwInfoSize = 32;
	DWORD dwFileSize = 0;
	BOOL bGotFileSize = FALSE;
	if (::HttpQueryInfo(m_hHttpFile, HTTP_QUERY_CONTENT_LENGTH, szContentLength, &dwInfoSize, NULL))
	{
		//Set the progress control range
		bGotFileSize = TRUE;
		dwFileSize = (DWORD) _ttol(szContentLength);
		SetProgressRange(dwFileSize);
	}

	//Now do the actual read of the file
	DWORD dwBytesRead = 0;
	char szReadBuf[1024];
	DWORD dwBytesToRead = 1024;
	DWORD dwTotalBytesRead = 0;
	DWORD dwLastPercentage = 0;
	
	do
	{
		if (!::InternetReadFile(m_hHttpFile, szReadBuf, dwBytesToRead, &dwBytesRead))
		{
			TRACE(_T("Failed in call to InternetReadFile, Error:%d\n"), ::GetLastError());
			HandleThreadErrorWithLastError(IDS_ERROR_READFILE);
			return;
		}
		else if (dwBytesRead && !m_bAbort)
		{
			//Write the data to file
			TRY
			{
				if(!m_sFileToDownloadInto.IsEmpty())
					m_FileToWrite.Write(szReadBuf, dwBytesRead);
				else
					m_sBuffer += szReadBuf;
			}
			CATCH(CFileException, e);                                          
			{
				TRACE(_T("An exception occured while writing to the download file\n"));
				HandleThreadErrorWithLastError(IDS_ERROR_READFILE, e->m_lOsError);
				e->Delete();
				return;
			}
			END_CATCH

			//Increment the total number of bytes read
			dwTotalBytesRead += dwBytesRead;  

			UpdateControlsDuringTransfer(dwTotalBytesRead, dwLastPercentage, bGotFileSize, dwFileSize);
		}
	} 
	while (dwBytesRead && !m_bAbort);

	//Delete the file being downloaded to if it is present and the download was aborted
	if(!m_sFileToDownloadInto.IsEmpty())
		m_FileToWrite.Close();
	if (m_bAbort)
		::DeleteFile(m_sFileToDownloadInto);

	//We're finished
	PostMessage(WM_HTTPDOWNLOAD_THREAD_FINISHED);
}

void CDownDlg::UpdateControlsDuringTransfer(DWORD dwTotalBytesRead, DWORD& dwLastPercentage, BOOL bGotFileSize, DWORD dwFileSize)
{
	if (bGotFileSize)
	{
		//Update the percentage downloaded in the caption
		DWORD dwPercentage = (DWORD) (dwTotalBytesRead * 100.0 / dwFileSize);
		if (dwPercentage != dwLastPercentage)
		{
			//Update the progress control bar
			SetProgress(dwTotalBytesRead);
		}
	}
}

void CDownDlg::OnDestroy() 
{
	//Wait for the worker thread to exit
	if (m_pThread)
	{
		WaitForSingleObject(m_pThread->m_hThread, INFINITE);
		delete m_pThread;
		m_pThread = NULL;
	}

	//Free up the internet handles we may be using
	if (m_hHttpFile)
	{
		::InternetCloseHandle(m_hHttpFile);
		m_hHttpFile = NULL;
	}
	if (m_hHttpConnection)
	{
		::InternetCloseHandle(m_hHttpConnection);
		m_hHttpConnection = NULL;
	}
	if (m_hInternetSession)
	{
		::InternetCloseHandle(m_hInternetSession);
		m_hInternetSession = NULL;
	}

	//Let the parent class do its thing
	CDialog::OnDestroy();
}

void CDownDlg::OnClose() 
{
	// TODO: Add your message handler code here and/or call default
	if (m_bSafeToClose)	
		CDialog::OnClose();
	else
	{
		//Just set the abort flag to TRUE and
		//disable the cancel button
		m_bAbort = TRUE;	
	}
}

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
美国精品在线观看| 精品国产三级a在线观看| 91在线播放网址| 成人午夜av电影| www.欧美色图| 色综合久久综合网| 在线视频国内自拍亚洲视频| 色视频欧美一区二区三区| 日本韩国欧美一区| 中文字幕国产一区| 国产精品剧情在线亚洲| 国产精品国产三级国产三级人妇| 亚洲欧洲国产专区| 亚洲大片精品永久免费| 日韩av一二三| 国产资源在线一区| 成人av网在线| 欧美性生活大片视频| 日韩一区二区视频| 久久免费视频色| 亚洲四区在线观看| 三级一区在线视频先锋 | 欧美经典三级视频一区二区三区| 国产欧美日产一区| 一区二区三区四区激情| 亚洲一区二区三区在线播放| 日韩国产高清影视| 国内外成人在线| 99久久99久久精品免费观看| 欧美三级在线看| 欧美tickling网站挠脚心| 国产精品嫩草99a| 亚洲成人免费影院| 国产一区二区三区黄视频| 99免费精品视频| 91精品国产91久久久久久一区二区 | 久久精品999| 不卡av电影在线播放| 欧美日韩亚洲丝袜制服| 久久精品亚洲乱码伦伦中文| 一区二区在线观看av| 久久成人免费网站| 99久久精品一区| 欧美成人女星排名| 亚洲欧美日韩国产另类专区 | 欧美日韩免费观看一区三区| 欧美成人福利视频| 亚洲精品国产无套在线观| 久久se这里有精品| 欧美综合一区二区| 久久精品亚洲一区二区三区浴池| 亚洲免费视频中文字幕| 国产自产2019最新不卡| 欧美日韩一级片网站| 中文字幕av不卡| 免费观看日韩电影| 欧美中文字幕亚洲一区二区va在线 | 亚洲欧美日韩一区二区三区在线观看| 亚洲国产精品久久人人爱| 国产一区二区三区视频在线播放| 欧美主播一区二区三区| 欧美激情在线看| 日本aⅴ精品一区二区三区| 91蜜桃在线观看| 精品国产一二三区| 午夜电影一区二区三区| 91亚洲精品久久久蜜桃网站| 久久综合久久综合九色| 日韩和欧美一区二区三区| 91免费视频大全| 国产日产精品一区| 麻豆成人免费电影| 这里只有精品99re| 亚洲成人动漫一区| 日本电影亚洲天堂一区| 亚洲欧美在线高清| 国产精品夜夜嗨| www国产成人| 六月婷婷色综合| 欧美日韩国产高清一区二区| 亚洲精品老司机| av午夜一区麻豆| 久久精品一区二区三区四区| 九九国产精品视频| 日韩视频在线你懂得| 亚洲超碰97人人做人人爱| 色香蕉成人二区免费| 日韩毛片一二三区| 色综合中文字幕国产| 欧美激情在线看| 国产精品456露脸| 久久久.com| 国产一区二区三区在线观看免费| 欧美tickling挠脚心丨vk| 老司机精品视频线观看86| 91精品国产色综合久久不卡电影| 五月天精品一区二区三区| 欧美日韩在线播放三区四区| 亚洲成人tv网| 欧美男同性恋视频网站| 亚洲 欧美综合在线网络| 欧美色电影在线| 午夜影视日本亚洲欧洲精品| 欧美日韩小视频| 日韩精品高清不卡| 欧美大片日本大片免费观看| 麻豆久久久久久久| 久久综合九色综合97婷婷女人 | 免费观看一级欧美片| 欧美一区二区视频免费观看| 日韩和欧美的一区| 日韩欧美高清在线| 91精品国产欧美一区二区成人| 亚洲国产精品精华液网站 | 一区二区三区四区高清精品免费观看| 91亚洲精华国产精华精华液| 夜夜夜精品看看| 欧美一区二区人人喊爽| 久久精品久久久精品美女| 26uuu另类欧美亚洲曰本| 成人免费视频视频在线观看免费| 最新成人av在线| 欧美日韩在线播| 国产最新精品精品你懂的| 国产精品久久久一区麻豆最新章节| 99久久精品免费观看| 五月激情综合网| 久久一区二区三区四区| 91在线丨porny丨国产| 亚洲午夜激情av| 日韩欧美你懂的| 播五月开心婷婷综合| 亚洲妇熟xx妇色黄| 久久综合九色综合欧美亚洲| 成人av在线播放网址| 亚洲va欧美va国产va天堂影院| 欧美草草影院在线视频| 国产成人啪午夜精品网站男同| 一区二区中文视频| 欧美军同video69gay| 国产精品亚洲一区二区三区妖精 | 亚洲最快最全在线视频| 在线播放一区二区三区| 国产成人精品亚洲日本在线桃色 | 亚洲最新在线观看| 精品电影一区二区三区| 色综合久久中文字幕| 日韩中文字幕91| 欧美极品aⅴ影院| 欧美精品电影在线播放| 国产91综合网| 日韩电影一区二区三区| 国产精品色眯眯| 日韩一区二区电影| 91在线视频观看| 九九九精品视频| 亚洲精品成人悠悠色影视| 久久影院电视剧免费观看| 在线观看亚洲专区| 国产成人免费在线视频| 日韩高清欧美激情| 亚洲欧美一区二区在线观看| 欧美电影免费观看高清完整版在线 | 大尺度一区二区| 亚洲国产欧美在线人成| 中文字幕成人av| 日韩免费性生活视频播放| 在线观看亚洲一区| 高清shemale亚洲人妖| 三级影片在线观看欧美日韩一区二区| 国产色产综合产在线视频| 欧美在线观看禁18| 成人黄色大片在线观看| 久久精品999| 婷婷中文字幕一区三区| 日韩美女啊v在线免费观看| 国产亚洲午夜高清国产拍精品| 欧美一级一区二区| 欧美日韩亚洲综合一区| 日本久久一区二区| 99国产精品国产精品久久| 国产麻豆一精品一av一免费| 奇米精品一区二区三区在线观看一| 亚洲三级在线看| 国产精品精品国产色婷婷| 国产亚洲短视频| 久久综合久色欧美综合狠狠| 欧美一区二区视频在线观看2020 | www.在线成人| 国产一区二区三区在线观看免费视频 | 欧美精品一区二区在线播放| 欧美日韩电影在线| 欧美日韩在线亚洲一区蜜芽| 91麻豆国产在线观看| 成人avav在线| 成人a级免费电影| 成人av电影观看| 99久久国产综合精品色伊| 成人精品国产福利| 成人精品鲁一区一区二区|