예제 #1
0
void CFileDiffDlg::OnTimer(UINT_PTR nIDEvent)
{
	if (m_bThreadRunning)
		return;

	if( nIDEvent == IDT_FILTER)
	{
		CString sFilterText;
		KillTimer(IDT_FILTER);
		m_cFilter.GetWindowText(sFilterText);

		m_cFileList.SetRedraw(FALSE);
		m_cFileList.DeleteAllItems();

		Filter(sFilterText);

		m_cFileList.SetRedraw(TRUE);

		__super::OnTimer(nIDEvent);
	}

	if( nIDEvent == IDT_INPUT)
	{
		KillTimer(IDT_INPUT);
		TRACE(_T("Input Timer\r\n"));

		GitRev gitrev;
		CString str;
		int mask = 0;
		this->m_ctrRev1Edit.GetWindowText(str);
		if (!gitrev.GetCommit(str))
		{
			m_rev1 = gitrev;
			mask |= 0x1;
		}
		else
		{
			CString msg;
			msg.Format(IDS_PROC_REFINVALID, (LPCTSTR)str);
			m_cFileList.ShowText(msg + _T("\n") + gitrev.GetLastErr());
		}

		this->m_ctrRev2Edit.GetWindowText(str);

		if (!gitrev.GetCommit(str))
		{
			m_rev2 = gitrev;
			mask |= 0x2;
		}
		else
		{
			CString msg;
			msg.Format(IDS_PROC_REFINVALID, (LPCTSTR)str);
			m_cFileList.ShowText(msg + _T("\n") + gitrev.GetLastErr());
		}

		this->SetURLLabels(mask);

		if(mask == 0x3)
		{

			InterlockedExchange(&m_bThreadRunning, TRUE);
			if (AfxBeginThread(DiffThreadEntry, this)==NULL)
			{
				InterlockedExchange(&m_bThreadRunning, FALSE);
				CMessageBox::Show(NULL, IDS_ERR_THREADSTARTFAILED, IDS_APPNAME, MB_OK | MB_ICONERROR);
			}
		}
	}
}
예제 #2
0
BOOL CALLBACK LoadProgram( HWND hWnd, int nMinProgress, int nMaxProgress )
{
	int nMin = nMinProgress;
	int nMax = nMaxProgress;
	int nRange = nMaxProgress-nMinProgress;
	CStkUIApp * pApp = AfxGetStkUIApp();
	if( NULL == pApp )
		return FALSE;

	CStaticDoc * pStaticDoc = pApp->GetStaticDoc();
	CMainFrame * pMainFrame = AfxGetMainFrame();

	HINSTANCE hInstanceOld = AfxGetResourceHandle();
	AfxSetResourceHandle( AfxGetInstanceHandle() );

	SendMessage( hWnd, WM_USER_STARTUP_PROGRESS, nMin, 0 );

	AfxGetStockContainer().Load( &AfxGetDB(), NULL, NULL );
	AfxGetDomainContainer().Load( AfxGetProfile().GetDomainFile() );
	AfxGetGroupContainer().Load( AfxGetProfile().GetGroupFile() );
	SendMessage( hWnd, WM_USER_STARTUP_PROGRESS, nMin+nRange*4/30, 0 );

	pMainFrame->m_SearchBox.InitStocks( TRUE, TRUE, TRUE );
	//pMainFrame->m_DateBox.InitDates( );
	SendMessage( hWnd, WM_USER_STARTUP_PROGRESS, nMin+nRange*8/30, 0 );

	// Open Simulation Strategy
	if( NULL == pApp->GetFirstStrategyPosition() )
	{
		if( 0 == pApp->OpenLastOpenedStrategy( ) )
			pApp->OpenDefaultStrategy( );
	}
	SendMessage( hWnd, WM_USER_STARTUP_PROGRESS, nMin+nRange*12/30, 0 );

	// Show Views
	//if( !pStaticDoc->GetViewIfExist( RUNTIME_CLASS(CWizardView) ) )
	//	pStaticDoc->ShowStaticView( RUNTIME_CLASS(CWizardView), TRUE );
	//SendMessage( hWnd, WM_USER_STARTUP_PROGRESS, nMin+nRange*14/30, 0 );
	//if( !pStaticDoc->GetViewIfExist( RUNTIME_CLASS(CSimuView) ) )
	//	pStaticDoc->ShowStaticView( RUNTIME_CLASS(CSimuView), TRUE );
	//SendMessage( hWnd, WM_USER_STARTUP_PROGRESS, nMin+nRange*16/30, 0 );
	if( !pStaticDoc->GetViewIfExist( RUNTIME_CLASS(CSListView) ) )
		pStaticDoc->ShowStaticView( RUNTIME_CLASS(CSListView), TRUE );
	SendMessage( hWnd, WM_USER_STARTUP_PROGRESS, nMin+nRange*18/30, 0 );
	//if( !pStaticDoc->GetViewIfExist( RUNTIME_CLASS(CRealTimeView) ) )
	//	pStaticDoc->ShowStaticView( RUNTIME_CLASS(CRealTimeView), TRUE );
	//SendMessage( hWnd, WM_USER_STARTUP_PROGRESS, nMin+nRange*20/30, 0 );
	//if( !pStaticDoc->GetViewIfExist( RUNTIME_CLASS(CMultiSortView) ) )
	//	pStaticDoc->ShowStaticView( RUNTIME_CLASS(CMultiSortView), TRUE );
	//SendMessage( hWnd, WM_USER_STARTUP_PROGRESS, nMin+nRange*22/30, 0 );
	//if( !pStaticDoc->GetViewIfExist( RUNTIME_CLASS(CGraphView) ) )
	//	pStaticDoc->ShowStaticView( RUNTIME_CLASS(CGraphView), TRUE );
	//SendMessage( hWnd, WM_USER_STARTUP_PROGRESS, nMin+nRange*24/30, 0 );
	//if( !pStaticDoc->GetViewIfExist( RUNTIME_CLASS(CBaseView) ) )
	//	pStaticDoc->ShowStaticView( RUNTIME_CLASS(CBaseView), TRUE );
	//SendMessage( hWnd, WM_USER_STARTUP_PROGRESS, nMin+nRange*26/30, 0 );
	//if( !pStaticDoc->GetViewIfExist( RUNTIME_CLASS(CInfoView) ) )
	//	pStaticDoc->ShowStaticView( RUNTIME_CLASS(CInfoView), TRUE );
	//SendMessage( hWnd, WM_USER_STARTUP_PROGRESS, nMin+nRange*28/30, 0 );
	//if( !pStaticDoc->GetViewIfExist( RUNTIME_CLASS(CSelectorView) ) )
	//	pStaticDoc->ShowStaticView( RUNTIME_CLASS(CSelectorView), TRUE );

	AfxSwitchToStaticView( RUNTIME_CLASS(CSListView) );

	AfxGetProfile().SetCurrentStock( STKLIB_CODE_SZZS, FALSE );
	pMainFrame->m_SearchBox.SetCurrentWindowText( );
	//pMainFrame->m_DateBox.SetWindowPos(NULL,0,0,135,200,SWP_NOMOVE|SWP_SHOWWINDOW|SWP_NOZORDER|SWP_NOREDRAW);

	AfxBeginThread( LoadKDataCacheMain, NULL, THREAD_PRIORITY_NORMAL);

	SendMessage( hWnd, WM_USER_STARTUP_PROGRESS, nMax, 0 );

	AfxSetResourceHandle( hInstanceOld );

	return TRUE;
}
예제 #3
0
void CPartFileConvert::StartThread() {
	if (convertPfThread==NULL)
		convertPfThread=AfxBeginThread(run, NULL);
}
예제 #4
0
BOOL CFileDiffDlg::OnInitDialog()
{
	CResizableStandAloneDialog::OnInitDialog();
	CString temp;

	CString sWindowTitle;
	GetWindowText(sWindowTitle);
	CString pathText = g_Git.m_CurrentDir;
	if (!m_path1.IsEmpty())
		pathText = g_Git.m_CurrentDir + _T("\\") + m_path1.GetWinPathString();
	CAppUtils::SetWindowTitle(m_hWnd, pathText, sWindowTitle);

	this->m_ctrRev1Edit.Init();
	this->m_ctrRev2Edit.Init();

	m_tooltips.Create(this);
	m_tooltips.AddTool(IDC_SWITCHLEFTRIGHT, IDS_FILEDIFF_SWITCHLEFTRIGHT_TT);

	m_cFileList.SetRedraw(false);
	m_cFileList.DeleteAllItems();
	DWORD exStyle = LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER | LVS_EX_INFOTIP;
	m_cFileList.SetExtendedStyle(exStyle);

	m_nIconFolder = SYS_IMAGE_LIST().GetDirIconIndex();
	m_cFileList.SetImageList(&SYS_IMAGE_LIST(), LVSIL_SMALL);

	m_SwitchButton.SetImage((HICON)LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_SWITCHLEFTRIGHT), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR));
	m_SwitchButton.Invalidate();

	m_cFilter.SetCancelBitmaps(IDI_CANCELNORMAL, IDI_CANCELPRESSED);
	m_cFilter.SetInfoIcon(IDI_FILTEREDIT);
	temp.LoadString(IDS_FILEDIFF_FILTERCUE);
	temp = _T("   ")+temp;
	m_cFilter.SetCueBanner(temp);
	if (!m_sFilter.IsEmpty())
		m_cFilter.SetWindowText(m_sFilter);

	int c = ((CHeaderCtrl*)(m_cFileList.GetDlgItem(0)))->GetItemCount()-1;
	while (c>=0)
		m_cFileList.DeleteColumn(c--);

	temp.LoadString(IDS_FILEDIFF_FILE);
	m_cFileList.InsertColumn(0, temp);
	temp.LoadString(IDS_FILEDIFF_EXT);
	m_cFileList.InsertColumn(1, temp);
	temp.LoadString(IDS_FILEDIFF_ACTION);
	m_cFileList.InsertColumn(2, temp);

	temp.LoadString(IDS_FILEDIFF_STATADD);
	m_cFileList.InsertColumn(3, temp);
	temp.LoadString(IDS_FILEDIFF_STATDEL);
	m_cFileList.InsertColumn(4, temp);

	int mincol = 0;
	int maxcol = ((CHeaderCtrl*)(m_cFileList.GetDlgItem(0)))->GetItemCount()-1;
	int col;
	for (col = mincol; col <= maxcol; col++)
	{
		m_cFileList.SetColumnWidth(col,LVSCW_AUTOSIZE_USEHEADER);
	}

	m_cFileList.SetRedraw(true);

	AddAnchor(IDC_DIFFSTATIC1, TOP_LEFT, TOP_RIGHT);
	AddAnchor(IDC_SWITCHLEFTRIGHT, TOP_RIGHT);
	AddAnchor(IDC_FIRSTURL, TOP_LEFT, TOP_RIGHT);
	AddAnchor(IDC_REV1BTN, TOP_RIGHT);
	//AddAnchor(IDC_DIFFSTATIC2, TOP_LEFT, TOP_RIGHT);
	AddAnchor(IDC_SECONDURL, TOP_LEFT, TOP_RIGHT);
	AddAnchor(IDC_REV2BTN, TOP_RIGHT);
	AddAnchor(IDC_FILTER, TOP_LEFT, TOP_RIGHT);
	AddAnchor(IDC_FILELIST, TOP_LEFT, BOTTOM_RIGHT);
	AddAnchor(IDC_REV1GROUP,TOP_LEFT,TOP_RIGHT);
	AddAnchor(IDC_REV2GROUP,TOP_LEFT,TOP_RIGHT);
	AddAnchor(IDC_REV1EDIT,TOP_LEFT);
	AddAnchor(IDC_REV2EDIT,TOP_LEFT);
	AddAnchor(IDC_LOG, TOP_RIGHT);

	EnableSaveRestore(_T("FileDiffDlg"));

	if(this->m_strRev1.IsEmpty())
		this->m_ctrRev1Edit.SetWindowText(this->m_rev1.m_CommitHash.ToString());
	else
	{
		bool rev1fail = false;
		try
		{
			rev1fail = !!m_rev1.GetCommit(m_strRev1);
		}
		catch (const char *msg)
		{
			rev1fail = true;
			MessageBox(_T("Could not get commit ") + m_strRev1 + _T("\nlibgit reports:\n") + CString(msg), _T("TortoiseGit"), MB_ICONERROR);
		}
		if (rev1fail)
		{
			CString msg;
			msg.Format(IDS_PROC_REFINVALID, m_strRev1);
			this->m_FileListText += msg;
		}

		this->m_ctrRev1Edit.SetWindowText(m_strRev1);
	}

	if(this->m_strRev2.IsEmpty())
		this->m_ctrRev2Edit.SetWindowText(this->m_rev2.m_CommitHash.ToString());
	else
	{
		bool rev2fail = false;
		try
		{
			rev2fail = !!m_rev2.GetCommit(m_strRev2);
		}
		catch (const char *msg)
		{
			rev2fail = true;
			MessageBox(_T("Could not get commit ") + m_strRev2 + _T("\nlibgit reports:\n") + CString(msg), _T("TortoiseGit"), MB_ICONERROR);
		}
		if (rev2fail)
		{
			CString msg;
			msg.Format(IDS_PROC_REFINVALID, m_strRev2);
			this->m_FileListText += msg;
		}

		this->m_ctrRev2Edit.SetWindowText(m_strRev2);
	}

	SetURLLabels();

	InterlockedExchange(&m_bThreadRunning, TRUE);
	if (AfxBeginThread(DiffThreadEntry, this)==NULL)
	{
		InterlockedExchange(&m_bThreadRunning, FALSE);
		CMessageBox::Show(NULL, IDS_ERR_THREADSTARTFAILED, IDS_APPNAME, MB_OK | MB_ICONERROR);
	}

	InterlockedExchange(&m_bLoadingRef, TRUE);
	if (AfxBeginThread(LoadRefThreadEntry, this)==NULL)
	{
		InterlockedExchange(&m_bLoadingRef, FALSE);
		CMessageBox::Show(NULL, IDS_ERR_THREADSTARTFAILED, IDS_APPNAME, MB_OK | MB_ICONERROR);
	}

	this->m_cRev1Btn.AddEntry(CString(MAKEINTRESOURCE(IDS_REFBROWSE)));
	this->m_cRev1Btn.AddEntry(CString(MAKEINTRESOURCE(IDS_LOG)));
	this->m_cRev1Btn.AddEntry(CString(MAKEINTRESOURCE(IDS_REFLOG)));

	this->m_cRev2Btn.AddEntry(CString(MAKEINTRESOURCE(IDS_REFBROWSE)));
	this->m_cRev2Btn.AddEntry(CString(MAKEINTRESOURCE(IDS_LOG)));
	this->m_cRev2Btn.AddEntry(CString(MAKEINTRESOURCE(IDS_REFLOG)));

	// Start with focus on file list
	GetDlgItem(IDC_FILELIST)->SetFocus();

	if(m_rev2.m_CommitHash.IsEmpty())
		m_SwitchButton.EnableWindow(FALSE);

	KillTimer(IDT_INPUT);
	return FALSE;
}
예제 #5
0
UINT ProxyServerThread(LPVOID info){
	LPCLIENTINFO pclientinfo;
	SOCKET ClientSock,connectsock,listensock,newsock;
	sockaddr_in remotesock_addr,sock_addr,localsock_addr;
	char data[MAXDATALEN];
	int datalen,methodlen,i,index;
	unsigned char CMD,ATYP;
	int DestPort,socklen;
	char ip[250];
	struct in_addr ipaddr;
	pclientinfo=(LPCLIENTINFO)info;
	ClientSock=pclientinfo->clientsock;
	remotesock_addr=pclientinfo->remotesock;
	CString remoteip;
	ipaddr.S_un.S_addr=remotesock_addr.sin_addr.S_un.S_addr;
	remoteip.Format("%s",inet_ntoa(ipaddr));
	TRACE(remoteip);
	TRACE(" connect ok...\r\n");
	CString temp;
	datalen=recv(ClientSock,(char *)data,sizeof(data),0);
	if(datalen>2){
		if(data[0]!=PROXYVERSION){
			TRACE("remote server send data no socks5 \r\n");
			SendMethodToClient(ClientSock,NOMETHOD);
			closesocket(ClientSock);
			return 1;
		}
		methodlen=data[1];
		for(i=2;i<(methodlen+2);i++){
			if(data[i]==NOAUTHLOGIN){
				TRACE("send method ok!\r\n");
				SendMethodToClient(ClientSock,NOAUTHLOGIN);
				break;
			}
		}
	}
	else{
		TRACE("remote server send data wrong!\r\n");
		SendMethodToClient(ClientSock,NOMETHOD);
		closesocket(ClientSock);
		return 1;
	}
	datalen=recv(ClientSock,(char *)data,sizeof(data),0);
	temp.Format("%d",datalen);
	TRACE(temp);
	if(datalen>=10){
		TRACE("get cmd ok!");
		CMD=data[1];
		ATYP=(unsigned char)data[3];
		switch(ATYP){
		case ATYP_IPV4:
			memcpy((void *)&DestPort,(const void *)&data[8],2);
			//DestPort=110;
			ZeroMemory(ip,sizeof(ip));
			wsprintf(ip,"%d.%d.%d.%d",(unsigned char)data[4],(unsigned char)data[5],(unsigned char)data[6],(unsigned char)data[7]);
			//strcpy(ip,"mail.sdu.edu.cn");
			TRACE(ip);
			break;
		case ATYP_IPV6:
			DestPort=*(int *)&data[20];
			SendRepToClient(ClientSock,REP_ATYP_WRONG,GetLocalIp(),0);
			closesocket(ClientSock);
			TRACE("ipv6 ok!\r\n");
			return 0;
			break;
		case ATYP_DOMAIN:
			index=data[4];
			memcpy((void *)&DestPort,&data[index+5],2);
			ZeroMemory(ip,sizeof(ip));
			memcpy((void *)ip,(const void *)&data[5],index);
			ip[index]='\0';
			TRACE(ip);
			break;
		default:
			SendRepToClient(ClientSock,REP_ATYP_WRONG,GetLocalIp(),0);
			TRACE("default ok!\r\n");
			closesocket(ClientSock);
			return 0;              
			break;
		}
		sock_addr.sin_family=AF_INET;
		sock_addr.sin_port=DestPort;
		if(ATYP==ATYP_DOMAIN) sock_addr.sin_addr.S_un.S_addr=GetDomainIp(ip);
		else sock_addr.sin_addr.S_un.S_addr=inet_addr(ip);   
		localsock_addr.sin_family=AF_INET;
		localsock_addr.sin_port=htons(8001);
		localsock_addr.sin_addr.S_un.S_addr=INADDR_ANY;  
		if(CMD==CMD_CONNECT){
			TRACE("to connect remote ip...\r\n");
			connectsock=socket(AF_INET,SOCK_STREAM,IPPROTO_TCP);
			if(connect(connectsock,(const sockaddr *)&sock_addr,sizeof(sock_addr))==INVALID_SOCKET){
				SendRepToClient(ClientSock,REP_TTL_TIMEOUT,GetLocalIp(),0);
				closesocket(ClientSock);
				return 0;
			}
			socklen=sizeof(sock_addr);
			if(getsockname(connectsock,(sockaddr *)&sock_addr,&socklen)==SOCKET_ERROR)
				TRACE("get sock name err\r\n");           
			SendRepToClient(ClientSock,REP_SUCCESS,GetLocalIp(),ntohs(sock_addr.sin_port));
			sockinfo.sourcesock=ClientSock;
			sockinfo.destsock=connectsock;
			TRACE("connect ok...\r\n");
			AfxBeginThread(ReciveThread,(LPVOID)&sockinfo);  
			AfxBeginThread(SendThread,(LPVOID)&sockinfo);
			//AfxBeginThread(DeailThread,(LPVOID)&sockinfo);  
		}
		else if(CMD==CMD_BIND){
			TRACE("to bind remote ip...\r\n");
			listensock=socket(AF_INET,SOCK_STREAM,IPPROTO_TCP);
			if(bind(listensock,(sockaddr *)&localsock_addr,sizeof(localsock_addr))==SOCKET_ERROR){
				SendRepToClient(ClientSock,REP_FAILED,GetLocalIp(),0);
				closesocket(ClientSock);
				TRACE("to bind remote failed...\r\n");
				return 0;
			}
			listen(listensock,10);                     
			TRACE("to bind remote ok...\r\n");
			SendRepToClient(ClientSock,REP_SUCCESS,GetLocalIp(),7895);
			newsock=accept(listensock,(sockaddr *)NULL,(int *)NULL);
			if(newsock==INVALID_SOCKET){
				SendRepToClient(ClientSock,REP_FAILED,GetLocalIp(),0);
				closesocket(ClientSock);
				TRACE("to accpet remote failed...\r\n");
				return 0;
			}
			SendRepToClient(ClientSock,REP_SUCCESS,GetLocalIp(),7895);
			sockinfo.sourcesock=ClientSock;
			sockinfo.destsock=newsock;
			TRACE("accept ok...\r\n");
			AfxBeginThread(ReciveThread,(LPVOID)&sockinfo);  
			AfxBeginThread(SendThread,(LPVOID)&sockinfo); 
		}
		else if(CMD==CMD_UDP){
			TRACE("to udp remote ...\r\n");
			TRACE("to bind remote ip...\r\n");
			listensock=socket(AF_INET,SOCK_DGRAM,IPPROTO_UDP);
			if(bind(listensock,(sockaddr *)&localsock_addr,sizeof(localsock_addr))==SOCKET_ERROR){
				SendRepToClient(ClientSock,REP_FAILED,GetLocalIp(),0);
				closesocket(ClientSock);
				TRACE("to bind remote failed...\r\n");
				return 0;
			}                     
			TRACE("to bind remote ok...\r\n");
			SendRepToClient(ClientSock,REP_SUCCESS,GetLocalIp(),8001);
			UdpClientInfo.clientsock=ClientSock;
			UdpClientInfo.remotesock=sock_addr;
			UdpClientInfo.udpsock=listensock;
			TRACE("udp thread ok...\r\n");
			AfxBeginThread(UdpDeailThread,(LPVOID)&UdpClientInfo); 
		}
		else{
			SendRepToClient(ClientSock,REP_FAILED,GetLocalIp(),0);
			closesocket(ClientSock);
			return 0;
		}
   }
   return 1;
}
예제 #6
0
/////
// 主工作线程
// 功能:从数据库表 skucode_t 中读出要查询的货号,分配给子工作线程进行计算
UINT AFX_CDECL MainWorkThreadFunc(LPVOID *lpParam)
{
	ASSERT(lpParam != NULL);

	BOOL bRet = FALSE;
	MYSQL_ROW row = NULL;
	LPMAINWORKTHREADPARAM pParam = (LPMAINWORKTHREADPARAM) lpParam;
	CMPSCore Core;

	AfxGetApp()->GetMainWnd()->PostMessageA(
		WM_USER_UI_UPDATE_PROCESS,
		(WPARAM) RESET_PROCESS,
		(LPARAM) 0);

	// 连接数据库
	bRet = Core.ConnectDB("127.0.0.1", "root", "", "test", 0, NULL, 0);

	// 子进程会添加记录到数据库中,应在此先清空该表
	if (bRet)
	{
		CString SQL, TableName;
		CMPSCore::GenerateTableName(pParam->_StartingDate, pParam->_FirstWeekSale, TableName);
		SQL.Format("TRUNCATE TABLE `%s`", (LPCTSTR)TableName);
		bRet = Core.NonSelectQuery(SQL);
	}

	// 准备所有SKUCODE的集合
	// Map key: SkuCode
	// Map value: Sub SkuCode
	std::multimap <std::string, std::string> SkuCodeMap;
	if (bRet)
	{
		bRet = Core.SelectQuery(
			"select indexcode, mapping1, mapping2, mapping3, mapping4, mapping5, mapping6, mapping7 from skuinfo");
	}
	if (bRet)
	{
		while (row = Core.GetRecord(), row != NULL)
		{
			BOOL bIncludeSelf = FALSE;
			if (IS_EMPTY(row[0]))
				continue;
			for (int i=1; i<=7; i++)
			{
				if (IS_EMPTY(row[i]))
					continue;
				SkuCodeMap.insert(std::pair<std::string,std::string>(row[0],row[i]));
				if ( strcmp(row[0], row[i]) == 0 )
					bIncludeSelf = TRUE;
			}
			if (!bIncludeSelf)
				SkuCodeMap.insert(std::pair<std::string,std::string>(row[0],row[0]));
		}
		Core.FreeRecord();
	}

	// 计数器和记录的总数,用于显示在UI上
	UINT nCount = 0;
	UINT nAmount = 0;
	nAmount = SkuCodeMap.size();

	if (bRet)
	{
		std::multimap<std::string,std::string>::iterator it;
		CString SQL;
		for ( it = SkuCodeMap.begin() ; bRet && it != SkuCodeMap.end(); it++ )
		{
			//////////////////////////////////////////////////////////////////////////
			// 刷新UI上的进度
			//////////////////////////////////////////////////////////////////////////
			nCount++;
			AfxGetApp()->GetMainWnd()->PostMessageA(
				WM_USER_UI_UPDATE_PROCESS,
				(WPARAM) UPDATE_PROCESS,
				(LPARAM) ((nAmount << 16) | nCount));

			//////////////////////////////////////////////////////////////////////////
			SQL.Format("select DISTINCT(`jdewh`) from `openinv_o` where `jdeskucode`='%s'", it->second.c_str());
			bRet = Core.SelectQuery((LPCTSTR)SQL);
			if ( !bRet )
				break;
			while ( row = Core.GetRecord(), row != NULL)
			{
#ifdef _DEBUG
				if (nCount > 50)
					break;
#endif

				if (IS_EMPTY(row[0]))
					continue;

				// 等待子工作线程资源(设置了同时工作的子线程数上限)
				if (WaitForSingleObject((HANDLE)gSubThreadCount, INFINITE) != WAIT_OBJECT_0)
				{
					// 异常结束
					bRet = FALSE;
					break;
				}
				else
				{
					LPSUBWORKTHREADPARAM lpSubThreadParam = new SUBWORKTHREADPARAM;
					CWinThread *pWinThread = NULL;

					// 准备子工作线程的参数
					lpSubThreadParam->_StartingDate = pParam->_StartingDate;
					lpSubThreadParam->_FirstWeekSale = pParam->_FirstWeekSale;
					strcpy_s(lpSubThreadParam->_ParentSkuCode, it->first.c_str());
					strcpy_s(lpSubThreadParam->_SkuCode, it->second.c_str());
					strcpy_s(lpSubThreadParam->_WareHouse, row[0]);

					// 启动一个子工作线程
					pWinThread = AfxBeginThread((AFX_THREADPROC)SubWorkThreadFunc,
						(LPVOID)lpSubThreadParam,
						THREAD_PRIORITY_NORMAL, 0, CREATE_SUSPENDED);
					pWinThread->m_bAutoDelete = TRUE;
					pWinThread->ResumeThread();
				}
			}
			Core.FreeRecord();
		}
	}

	AfxGetApp()->GetMainWnd()->PostMessageA(
		WM_USER_UI_UPDATE_PROCESS,
		(WPARAM) END_PROCESS,
		(LPARAM) ((nAmount << 16) | nCount));

	//TODO: 需等待子线程结束?
	delete pParam;
	return 0;
}
예제 #7
0
void CChatControl::GetConnect()
{
	// Test for internet connection 
	if(!m_autPrefs->GetLanMode() && !m_InetTested)
	{
		CWinThread* pThread = AfxBeginThread(TestInetThread, this, THREAD_PRIORITY_NORMAL, 0, CREATE_SUSPENDED);
		AssignThreadToCPU(pThread, CPU_0);
		pThread->ResumeThread();

		return;
	}

	if(m_autPrefs->GetLanMode())
	{
		if(m_pPrefs->m_InternalIRC)
		{
			CString Host = m_pPrefs->m_InternalIRCAddr;

			int pos = Host.Find(":");

			if(pos != -1)
				AddServer( Host.Left(Host.Find(":")), atoi(Host.Mid(Host.Find(":") + 1)));
			else
				AddServer(m_pPrefs->m_InternalIRCAddr, 6667);
		}

		return;
	}

	// If its for chat
	if(m_pDoc->m_pViewChat)
		if(m_pPrefs->m_PrefNet == "GnuDefault")
		{
			AddServer("irc.freenode.net", 6667);
			return;
		}
			

	// Connect to random server on default network
	for(int i = 0; i < m_pPrefs->m_ChatNets.size(); i++)		
		if(m_pPrefs->m_ChatNets[i].Name == m_pPrefs->m_PrefNet)
			if(m_pPrefs->m_ChatNets[i].Servers.size())
			{
				int servpos = rand() % m_pPrefs->m_ChatNets[i].Servers.size() + 0;
				CString Parse = m_pPrefs->m_ChatNets[i].Servers[servpos];
				
				// Take first server from list, and move it to the back
				//pPrefs->m_ChatNets[i].Servers.erase( pPrefs->m_ChatNets[i].Servers.begin() );
				//pPrefs->m_ChatNets[i].Servers.push_back(Parse);
		
				int colon = Parse.Find( _T(":") );

				if(colon != -1)
				{
					std::vector<UINT> PortList;

					CString Server   = Parse.Left(colon);
					CString PortString = Parse.Mid(colon + 1) + ",";
					
					int pos = 0;
					while(PortString.Find( _T(","), pos) != -1)
					{
						UINT port = atoi(PortString.Mid(pos, PortString.Find( _T(","), pos) - pos));
						PortList.push_back(port);

						pos = PortString.Find( _T(","), pos) + 1;
					}

					if(PortList.size())
					{	
						int portpos = rand() % PortList.size() + 0;
						AddServer(Server, PortList[portpos]);

						return;
					}
				}
			}
}
예제 #8
0
void CSmartCommunicationDlg::OnButtonStart() 
{		
	char		buf[128],Module[30],msg[256];	
	CData		mdata;	
	int			nErrCode=0;	
	int         FunId;
	CSystemInfo	SystemInfo;
	list<CSocketSmart>::iterator SocketSmart;

	memset(buf,   0x00,sizeof buf);
	memset(msg,	  0x00,sizeof msg);
	memset(Module,0x00,sizeof Module);

	g_CInterface.SetParentpDlg(this);
	//清除显示框中的信息
	OnButtonClear();
	Init();
	m_BtCancel.EnableWindow(FALSE);
	m_BtStart.EnableWindow(FALSE);
	m_BtClear.EnableWindow(TRUE);

	strcpy(msg,"前置系统开始启动并监控所有终端设备,请稍后......");
	AddString(msg);
	WriteLog(msg);
	//初始化第三方接口		
	strcpy(msg,"前置系统正在初始化第三方接口,请稍后......");
	AddString(msg);
	WriteLog(msg);
	if( !g_bInitConnectFlag )
	{	
		if( !g_CInterface.SMT_InterfaceInit(m_ServerIP,m_ServerPort) )
		{
			AddString("前置系统正在初始化第三方接口失败,请退出前置重新启动");
			strcpy(m_ErrMsg,g_CInterface.m_szText);
			goto To_SystemEnd;
		}
		g_bInitConnectFlag=true;
	}
	//前置签到	
	strcpy(msg,"前置系统正在向金仕达签到,请稍后......");
	AddString(msg);
	WriteLog(msg);
	if( !g_CInterface.SMT_SmartFrontLogin(5000) )
	{
		sprintf(m_ErrMsg,"前置向金仕达签到失败[金仕达返回:%s]",g_CInterface.m_szText);
		goto To_SystemEnd;
	}

	//获取黑名单
	strcpy(msg,"前置系统正在装载黑名单,请稍后......");
	AddString(msg);
	WriteLog(msg);	
	FunId=SMT_SMARTFRONTDOWNALLBLACK;
	if( !g_CInterface.SMT_GetAllInitBlackList(FunId) )
	{
		strcpy(m_ErrMsg,g_CInterface.m_szText);
		goto To_SystemEnd;
	}
	

	//获取补助名单
	strcpy(msg,"前置系统正在装载补助名单,请稍后......");
	AddString(msg);
	WriteLog(msg);	
	if( !g_CInterface.SMT_GetAllInitAssistantList(false,0) )
	{
		strcpy(m_ErrMsg,g_CInterface.m_szText);
		goto To_SystemEnd;
	}

	//获取设备的主参数	
	strcpy(msg,"前置系统正在获取设备的主参数,请稍后......");
	AddString(msg);
	WriteLog(msg);
	if( !GetDevicePara() ) 
	{
		strcpy(m_ErrMsg,g_CInterface.m_szText);
		goto To_SystemEnd;
	}
	//显示启动的服务总数
	sprintf(m_ErrMsg,"前置系统总共需要启动%ld个链路服务.",g_LTcpsmart.size());
	AddString(m_ErrMsg);	
	WriteLog(m_ErrMsg);	
	//启动所有通过TCP连接的服务	
	for( SocketSmart=g_LTcpsmart.begin();SocketSmart!=g_LTcpsmart.end();SocketSmart++)
	{
		SocketSmart->SetParent(this);
		SocketSmart->Start();
		sprintf(m_ErrMsg,"开始准备启动 %s 的线程......",SocketSmart->m_IpPar.cIPAddress);
		AddString(m_ErrMsg);	
		WriteLog(m_ErrMsg);
	}
	g_StartFlag = 1;
	//取任务线程
	UINT SMT_StartQueryTaskThread( LPVOID pParam );
	if(AfxBeginThread(SMT_StartQueryTaskThread, (LPVOID)this)==NULL)
	{			
		strcpy(m_ErrMsg,"创建从数据库中取任务的线程失败");	
		goto To_SystemEnd;
	}
	//上传交易记录线程
	UINT SMT_StartUpRecordThread( LPVOID pParam );
	if(AfxBeginThread(SMT_StartUpRecordThread, (LPVOID)this)==NULL)
	{			
		strcpy(m_ErrMsg,"创建从数据库中取任务的线程失败");	
		goto To_SystemEnd;
	}
 	//定时取黑名单线程,每12小时取一次数据
	UINT SMT_EveryDayGetAllInitAssistantThread( LPVOID pParam );
	if(AfxBeginThread(SMT_EveryDayGetAllInitAssistantThread, (LPVOID)this)==NULL)
	{			
		strcpy(m_ErrMsg,"创建从数据库中定时取黑名单的线程失败");	
		goto To_SystemEnd;
	}	
	m_BtRate.EnableWindow(TRUE);
	m_BtCancel.EnableWindow(FALSE);
	m_BtStart.EnableWindow(FALSE);
	return ;	
To_SystemEnd:
	AddString(m_ErrMsg);
	WriteLog(m_ErrMsg);
	OnButtonStop();
	m_BtCancel.EnableWindow(TRUE);
	m_BtStart.EnableWindow(TRUE);
	m_BtClear.EnableWindow(TRUE);		
	m_BtRate.EnableWindow(FALSE);
}
예제 #9
0
//////////////////////////////////////////////////////////////////////////
// 
//  Function Name:  StartViewFinder 
//  Description:    Turns the viewfinder on the camera and also ends it
//					when necessary
//  Parameters:                    
//  Returns:        void
//  Summary:        
//  Author:         CannonSDK
//                           
///////////////////////////////////////////////////////////////////////////
void CCameraConnect::StartViewfinder()
{
	cdError			err;
	cdStgMedium		VFMedium;

	/* UI is locked so that information may not be changed. */
	err = CDLockUI( m_hSource );
	if( GETERRORID(err) != cdOK )
	{
	//	goto	camerr;
	}

	if( !m_fVFEnd )
	{
		/* The thread which displays view finder is created. */
		m_fVFEnd = TRUE;
		g_CpVFThread = AfxBeginThread(	(AFX_THREADPROC)ViewFinderProc,
										(LPVOID)this,
										0,
										0,
										CREATE_SUSPENDED,
										NULL );
		
		/* A view finder is started. */
		VFMedium.Type = cdMEMTYPE_STREAM;
		err = CDStartViewfinder(	m_hSource,
									FILEFORMAT_BMP,
									ViewFinderCallBackFun,
									(cdContext)this );
		if( GETERRORID(err) != cdOK )
		{
			//goto	camerr;
		}
		
		//m_CViewFinder.SetWindowText( "Stop" );
	}

	else
	{
		/* A view finder is ended. */
		err = CDTermViewfinder( m_hSource );
		if( GETERRORID(err) != cdOK )
		{
			printf("");
			//goto	camerr;
		}
		
		/* A thread is ended. */
		m_fVFEnd = FALSE;
		g_CpVFThread->ResumeThread();
		WaitForSingleObject( g_CpVFThread->m_hThread, INFINITE );
		
		//m_CViewFinder.SetWindowText( "Start" );		
		//Invalidate();
		//UpdateWindow();	

		/* The lock of UI is canceled. */
		err = CDUnlockUI( m_hSource );
		if( GETERRORID(err) != cdOK )
		{
			//	goto	camerr;
		}
	}
	
}
예제 #10
0
void CAddTaskLinksEdit::UpdateLinksByWindowText()
{
	if (NULL == m_pDoc)
		return;

	//AfxMessageBox(_T("abc"));
	set<CRssFeed*>	setRssUpdatefeed;//订阅
	//	取现在Doc里的所有ed2k的fileHash,组成set。
	set<CFileHashKey>	setKeysInDoc;
	setKeysInDoc = m_pDoc->GetAllKeysInDoc();

	//	把EditCtrl里的内容变成一行一行的字符串,并把每一行放入列表中。
	CString	strText;
	GetWindowText(strText);
	CList<CString>		lstLinks;
	::ConvertStrToStrList(&lstLinks, strText);


	CFileHashKey			key;
	CAddTaskDoc::SItem		docItem;
	CString					strLine;
	CED2KLink				*pLink = NULL;

	//CList<CString>			lstUrls;
	CMapStringToPtr			setUrls;
	CString					strPrefix;

	// Added by VC-yavey on 2010-04-16 <begin> 
	// 初始化rss url
	m_pDoc->GetRssUrlSet().clear();
	// Added by VC-yavey on 2010-04-16 <end>

	// 分析每一行,并做相应的处理。
	POSITION	pos = lstLinks.GetHeadPosition();

	if ( pos == NULL && !m_setLastRssfeed.empty() )
	{
		set<CRssFeed*>::iterator		it;//删除掉无用的rss订阅对象
		for ( it = m_setLastRssfeed.begin(); m_setLastRssfeed.end() != it; ++it )
		{
				delete *it;
		}
		m_setLastRssfeed.clear();
	}

	bool bHasRssLink = false;

	while (NULL != pos)
	{
		strLine = lstLinks.GetNext(pos);

		strLine = Decode3URL(strLine);
		
		strPrefix = strLine.Left(strLine.Find(_T(':')));

		if (0 == strPrefix.CompareNoCase(_T("ed2k")))
		{
			try
			{
				pLink = NULL;

				// MODIFIED by VC-yavey on 2010-04-16
				// 处理订阅协议
				pLink = CED2KLink::CreateLinkFromUrl(strLine);

			}
			catch (...)
			{
				SAFE_DELETE(pLink);
			}

			if (NULL != pLink)
			{
				// MODIFIED by VC-yavey on 2010-04-16
				// 处理订阅协议
				switch ( pLink->GetKind() )
				{
					case CED2KLink::kFile:
						key = ((CED2KFileLink*)pLink)->GetHashKey();

						// MODIFIED by VC-yavey on 2010-04-16, 统一放到最后删除
						//SAFE_DELETE(pLink);

						setKeysInDoc.erase(key);

						docItem.strLinkText = strLine;
						docItem.bCheck = TRUE;
						m_pDoc->SetItem(key, docItem, CAddTaskDoc::IM_TEXT | CAddTaskDoc::IM_CHECK, GetSafeHwnd());
						break;
					
					case CED2KLink::kRss:
						{
							bHasRssLink = true;

							CString strRssLink;
							CAddTaskDoc::RssUrlSet & setUrl = m_pDoc->GetRssUrlSet();
							strRssLink = ((CED2KRssLink*)pLink)->GetRssUrl();

							//added by lost		判断上次获取到订阅中的
							if ( !m_setLastRssfeed.empty() )
							{
								bool	bAlready = false;
								set<CRssFeed*>::iterator		it;
								for ( it = m_setLastRssfeed.begin(); m_setLastRssfeed.end() != it; it++ )
								{
									ASSERT( *it != NULL);
									CRssFeed * pFeed = *it;
									if ( pFeed->m_strFeedUrl  ==  strRssLink )
									{
										bAlready = true;
										setRssUpdatefeed.insert( (*it) );
										break;
									}
								}

								if (!bAlready)
								{
									setUrl.insert( strRssLink ) ;
								}
							}
							else
							{
								setUrl.insert( strRssLink ) ;
							}
							//added by lost

						}
						break;
				}
				SAFE_DELETE(pLink);
			}
		}
		else if (0 == strPrefix.CompareNoCase(_T("http"))
			|| 0 == strPrefix.CompareNoCase(_T("ftp")))
		{
			setUrls.SetAt(strLine, NULL);
			//lstUrls.AddTail(strLine);
		}
	}

	CAddTaskDoc::RssUrlSet & setUrl = m_pDoc->GetRssUrlSet();
	if (!setUrl.empty())
	{
		if (pThread == NULL)
		{
			UPDATERSS_PARAM * paramRSS = new UPDATERSS_PARAM;
			paramRSS->setRssLink		= setUrl;
			paramRSS->thisEdit		= this;

			pThread = AfxBeginThread( ThreadUpdateRSS, paramRSS );//线程获取FEED信息
		}
	}

	//从获取到的FEED集合中得到所有文件hash
	set<CFileHashKey>	setKeysInLastFeed;
	if ( !setRssUpdatefeed.empty() )
	{
		set<CRssFeed*>::iterator		itRss;
		for ( itRss = setRssUpdatefeed.begin(); setRssUpdatefeed.end() != itRss; itRss++ )
		{
			CRssFeed* pFeed = *itRss;
			CED2KLink				*pLinkRss = NULL;
			for ( CRssFeed::ItemIterator it = pFeed->GetItemIterBegin(); it != pFeed->GetItemIterEnd(); ++it )
			{
				CRssFeed::Item & item = it->second;

				try
				{
					pLinkRss = NULL;
					pLinkRss = CED2KLink::CreateLinkFromUrl(item.m_strEnclosure);
				}
				catch (...)
				{
					SAFE_DELETE(pLinkRss);
				}

				if (NULL != pLinkRss)
				{
					switch ( pLinkRss->GetKind() )
					{
					case CED2KLink::kFile:

						key = ((CED2KFileLink*)pLinkRss)->GetHashKey();
						setKeysInLastFeed.insert(key);
					}
				}
			}
			SAFE_DELETE(pLinkRss);
		}

		if ( !m_setRssHash.empty() )
		{
			m_setRssHash.clear();//直接清除set

			//set<CFileHashKey>::iterator		itKey;
			//for ( itKey = m_setRssHash.begin(); m_setRssHash.end() != itKey; itKey++ )//erase后就不可以再用itKey++了 切记
			//{
			//		itKey = m_setRssHash.erase(itKey);
			//}
		}
		m_setRssHash = setKeysInLastFeed;

		set<CRssFeed*>::iterator		it;//删除掉无用的rss订阅对象
		for ( it = m_setLastRssfeed.begin(); m_setLastRssfeed.end() != it; )
		{
			if (setRssUpdatefeed.find(*it) == setRssUpdatefeed.end())
			{
				delete *it;
				it = m_setLastRssfeed.erase(it);
			}
			else
			{
				++it;
			}
		}
		setRssUpdatefeed.clear();//清空set
	}

	// EditCtrl里没有的ed2k链接,则在doc里把它删除。
	set<CFileHashKey>::iterator		it;
	for (it = setKeysInDoc.begin();
		setKeysInDoc.end() != it;
		it++)
	{
		//docItem.bCheck = FALSE;
		//m_pDoc->SetItem(*it, docItem, CAddTaskDoc::IM_CHECK, GetSafeHwnd());
		if ( !setKeysInLastFeed.empty() && setKeysInLastFeed.find(*it) != setKeysInLastFeed.end() )
		{//与Feed中某hash值匹配
			continue;
		}

		m_pDoc->RemoveItem(*it);
	}

	if (bHasRssLink)
		(((CDlgAddTask*)GetParent())->m_chkboxRssAutoDown).ShowWindow(SW_SHOW);
	else
		(((CDlgAddTask*)GetParent())->m_chkboxRssAutoDown).ShowWindow(SW_HIDE);

	m_pDoc->UpdateUrlItems(&setUrls, GetSafeHwnd());
}
예제 #11
0
BOOL CHttpDownloadDlg::OnInitDialog() 
{
	//Let the parent class do its thing
	CDialog::OnInitDialog();

	m_bgImage.LoadFromResource(AfxGetInstanceHandle(),MAKEINTRESOURCE(IDB_BITMAP2));
	if(!m_bgImage.IsNull())
	{
		MoveWindow(0,0,m_bgImage.GetWidth(),m_bgImage.GetHeight());
		CenterWindow();
	}

	//Setup the animation control
	//m_ctrlAnimate.Open(IDR_HTTPDOWNLOAD_ANIMATION);
	m_ctrlAnimate.ShowWindow(SW_HIDE);

	m_static.SetMyText("游戏下载");
	m_static.MoveWindow(10,40,80,80);

	m_listbox.MoveWindow(12,58,410,100);
	m_listbox.InitListCtrl(RGB(194,212,234),RGB(0,0,0),RGB(249,175,40),RGB(0,0,0),"");
	m_listbox.setProcessPos(2);
	m_listbox.SetProcessImage(AfxGetInstanceHandle(),MAKEINTRESOURCE(IDB_BITMAP6),MAKEINTRESOURCE(IDB_BITMAP7));
	m_listbox.InsertColumn(0,"文件名",LVCFMT_CENTER,130);
	m_listbox.InsertColumn(1,"大小(KB)",LVCFMT_CENTER,60);
	m_listbox.InsertColumn(2,"进度",LVCFMT_CENTER,170);
	m_listbox.InsertColumn(3,"速度",LVCFMT_CENTER,50);
	m_listbox.InitListHeader(AfxGetInstanceHandle(),MAKEINTRESOURCE(IDB_BITMAP1),MAKEINTRESOURCE(IDB_BITMAP1),RGB(255,255,255),RGB(255,255,255),1);

	m_listbox.SetTimer(100,10,NULL);

	m_exit.LoadImageFromeResource(AfxGetInstanceHandle(),IDB_BITMAP5);
	m_exit.SetPosition(CPoint(410,10));
	m_cancel.LoadImageFromeResource(AfxGetInstanceHandle(),IDB_BITMAP4);
	m_cancel.SetPosition(CPoint(360,175));

	//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 = CString("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
	CFileStatus fs;
	ASSERT(m_sFileToDownloadInto.GetLength());
	if (CFile::GetStatus(m_sFileToDownloadInto, fs))
	{/*
	 CString sMsg;
	 AfxFormatString1(sMsg, IDS_HTTPDOWNLOAD_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_HTTPDOWNLOAD_FAIL_FILE_OPEN, sError);
		
		//AFCMessageBox(sMsg);
	     DUIMessageBox(m_hWnd,MB_ICONINFORMATION|MB_OK,"系统提示",false,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;

	m_listbox.InsertItem(0,m_sFilename.GetBuffer());

	//Set the file status text
	CString sFileStatus;
	ASSERT(m_sObject.GetLength());
	ASSERT(m_sServer.GetLength());
	AfxFormatString2(sFileStatus, IDS_HTTPDOWNLOAD_FILESTATUS, m_sFilename, m_sServer);
	m_ctrlFileStatus.SetWindowText(sFileStatus);

	//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;
}
예제 #12
0
void CFileAssoc::CheckIconsAssoc(const CMediaFormats& mf)
{
    AfxBeginThread(RunCheckIconsAssocThread, (LPVOID)&mf);
}
예제 #13
0
void CTTToeView::OnTimer(UINT nFlags)
{
	if(nFlags == TMR_FIELD_ID){
		field->updateCells();
	}

	else if (nFlags == TMR_MENU_ID){
		menu->timerTicked();
		menu->displayUpdated();	
	}

	else if(nFlags == TMR_MAIN_ID){
		if(gameStatus != -2){
			if(moveQueued){
				moveMade = false;
				aiThinking = true;

			    aiThread = AfxBeginThread(makeAIMove, &vicCombStartEnd);
				moveQueued = false;
			}
			if(moveMade){
				getMainFrame()->setStPlayersMove();
				getMainFrame()->resetAIPerc();
				getMainFrame()->setMoveNum(field->getMovesMade());

				moveMade = false;
				aiThinking = false;

				if(gameStatus != -1){
					if(aiMove.getIsValid()){
						field->aIPlayed(aiMove);
					}

					vicAnimFirstTime = true;
					OnMouseMove(0,CPoint(0,0));
					
					bool prevValue = settings.showtrack;
					settings.showtrack = true;

					if(gameStatus == RateField::ST_AI_WON){
						gameStatus = -2;
						getMainFrame()->setAIScr(++aiVictoryNumber);
						MessageBox(L"Sorry, you have lost...");
					}
					else if(gameStatus == RateField::ST_PLAYER_WON){
						gameStatus = -2;
						getMainFrame()->setPlayerScr(++playerVicNumber);
						MessageBox(L"Congratulations, you have won!");
					}
					else{
						gameStatus = -1;
						getMainFrame()->setDrawScr(++drawNumber);
						MessageBox(L"Draw!");
					}

					settings.showtrack = prevValue;

					gameStatus = -1;
					field->resetCellModes();
					getMainFrame()->setMoveNum(field->getMovesMade());
					field->display(false,false,false,false);
				}
				else{
					lastMove = aiMove;
					field->aIPlayed(lastMove);
				}
			}
		}
	}

	else if(nFlags == TMR_MENU_ACT_SEQ_ID){
		processMenuActions();
		KillTimer(TMR_MENU_ACT_SEQ_ID);
	}

	else if(nFlags == TMR_WINNING_COMB_ID){
		if(gameStatus == -2){
			animateWinningCombination();
		}
	}

	else if(nFlags == TMR_STATUS_BAR_ID){
		if(aiThinking){
			getMainFrame()->updateStAIThinking();
			getMainFrame()->setAIPerc(field->getAIPercent());
		}
	}

	else if(nFlags == TMR_TEST_ID){
		if(cnt == 0){

		}
		else{
			testProperty = false;
			char* a = new char[20];
			_itoa(cnt, a, 10);
			cnt = 0;
			CString str(a);

			MessageBox(str);
		}	
	}

	CView::OnTimer(nFlags);
}
예제 #14
0
BOOL CCopyDlg::OnInitDialog()
{
    CResizableStandAloneDialog::OnInitDialog();
    CAppUtils::MarkWindowAsUnpinnable(m_hWnd);

    ExtendFrameIntoClientArea(IDC_EXTGROUP);
    m_aeroControls.SubclassControl(this, IDC_DOSWITCH);
    m_aeroControls.SubclassControl(this, IDC_MAKEPARENTS);
    m_aeroControls.SubclassOkCancelHelp(this);
    m_bCancelled = false;

    DWORD exStyle = LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER | LVS_EX_CHECKBOXES;
    m_ExtList.SetExtendedStyle(exStyle);
    SetWindowTheme(m_ExtList.GetSafeHwnd(), L"Explorer", NULL);
    m_ExtList.ShowText(CString(MAKEINTRESOURCE(IDS_COPY_WAITFOREXTERNALS)));

    AdjustControlSize(IDC_COPYHEAD);
    AdjustControlSize(IDC_COPYREV);
    AdjustControlSize(IDC_COPYWC);
    AdjustControlSize(IDC_DOSWITCH);
    AdjustControlSize(IDC_MAKEPARENTS);

    CTSVNPath path(m_path);
    CString sWindowTitle;
    GetWindowText(sWindowTitle);
    CAppUtils::SetWindowTitle(m_hWnd, path.GetUIPathString(), sWindowTitle);

    m_History.SetMaxHistoryItems((LONG)CRegDWORD(L"Software\\TortoiseSVN\\MaxHistoryItems", 25));

    SetRevision(m_CopyRev);

    m_tooltips.AddTool(IDC_HISTORY, IDS_COMMITDLG_HISTORY_TT);

    if (SVN::PathIsURL(path))
    {
        DialogEnableWindow(IDC_COPYWC, FALSE);
        DialogEnableWindow(IDC_DOSWITCH, FALSE);
        SetDlgItemText(IDC_COPYSTARTLABEL, CString(MAKEINTRESOURCE(IDS_COPYDLG_FROMURL)));
    }

    SVN svn;
    CString sUUID;
    m_repoRoot = svn.GetRepositoryRootAndUUID(path, true, sUUID);
    m_repoRoot.TrimRight('/');
    m_wcURL = svn.GetURLFromPath(path);
    if (m_wcURL.IsEmpty() || (!path.IsUrl() && !path.Exists()))
    {
        CString Wrong_URL=path.GetSVNPathString();
        CString temp;
        temp.Format(IDS_ERR_NOURLOFFILE, (LPCTSTR)Wrong_URL);
        ::MessageBox(this->m_hWnd, temp, L"TortoiseSVN", MB_ICONERROR);
        this->EndDialog(IDCANCEL);      //exit
    }
    m_URLCombo.LoadHistory(L"Software\\TortoiseSVN\\History\\repoPaths\\"+sUUID, L"url");
    m_URLCombo.SetCurSel(0);
    CString relPath = m_wcURL.Mid(m_repoRoot.GetLength());
    if (!m_URL.IsEmpty())
    {
        // allow the use of urls relative to the repo root
        if (m_URL[0] != '^')
            relPath = m_URL.Mid(m_repoRoot.GetLength());
        else
            relPath = m_URL.Mid(1);
    }
    CTSVNPath r = CTSVNPath(relPath);
    relPath = r.GetUIPathString();
    relPath.Replace('\\', '/');
    m_URLCombo.AddString(relPath, 0);
    m_URLCombo.SelectString(-1, relPath);
    m_URL = m_wcURL;
    SetDlgItemText(IDC_DESTURL, CPathUtils::CombineUrls(m_repoRoot, relPath));
    SetDlgItemText(IDC_FROMURL, m_wcURL);

    CString reg;
    reg.Format(L"Software\\TortoiseSVN\\History\\commit%s", (LPCTSTR)sUUID);
    m_History.Load(reg, L"logmsgs");

    m_ProjectProperties.ReadProps(m_path);
    if (CRegDWORD(L"Software\\TortoiseSVN\\AlwaysWarnIfNoIssue", FALSE))
        m_ProjectProperties.bWarnIfNoIssue = TRUE;

    m_cLogMessage.Init(m_ProjectProperties);
    m_cLogMessage.SetFont((CString)CRegString(L"Software\\TortoiseSVN\\LogFontName", L"Courier New"), (DWORD)CRegDWORD(L"Software\\TortoiseSVN\\LogFontSize", 8));

    GetDlgItem(IDC_BUGTRAQBUTTON)->ShowWindow(SW_HIDE);
    GetDlgItem(IDC_BUGTRAQBUTTON)->EnableWindow(FALSE);
    CBugTraqAssociations bugtraq_associations;
    bugtraq_associations.Load(m_ProjectProperties.GetProviderUUID(), m_ProjectProperties.sProviderParams);

    if (bugtraq_associations.FindProvider(CTSVNPathList(m_path), &m_bugtraq_association))
    {
        CComPtr<IBugTraqProvider> pProvider;
        HRESULT hr = pProvider.CoCreateInstance(m_bugtraq_association.GetProviderClass());
        if (SUCCEEDED(hr))
        {
            m_BugTraqProvider = pProvider;
            ATL::CComBSTR temp;
            ATL::CComBSTR parameters;
            parameters.Attach(m_bugtraq_association.GetParameters().AllocSysString());
            hr = pProvider->GetLinkText(GetSafeHwnd(), parameters, &temp);
            if (SUCCEEDED(hr))
            {
                SetDlgItemText(IDC_BUGTRAQBUTTON, temp == 0 ? L"" : temp);
                GetDlgItem(IDC_BUGTRAQBUTTON)->EnableWindow(TRUE);
                GetDlgItem(IDC_BUGTRAQBUTTON)->ShowWindow(SW_SHOW);
            }
        }

        GetDlgItem(IDC_LOGMESSAGE)->SetFocus();
    }
    if (m_ProjectProperties.sMessage.IsEmpty())
    {
        GetDlgItem(IDC_BUGID)->ShowWindow(SW_HIDE);
        GetDlgItem(IDC_BUGIDLABEL)->ShowWindow(SW_HIDE);
        GetDlgItem(IDC_LOGMESSAGE)->SetFocus();
    }
    else
    {
        GetDlgItem(IDC_BUGID)->ShowWindow(SW_SHOW);
        GetDlgItem(IDC_BUGIDLABEL)->ShowWindow(SW_SHOW);
        if (!m_ProjectProperties.sLabel.IsEmpty())
            SetDlgItemText(IDC_BUGIDLABEL, m_ProjectProperties.sLabel);
        GetDlgItem(IDC_BUGID)->SetFocus();
    }

    if (!m_sLogMessage.IsEmpty())
        m_cLogMessage.SetText(m_sLogMessage);
    else
        m_cLogMessage.SetText(m_ProjectProperties.GetLogMsgTemplate(PROJECTPROPNAME_LOGTEMPLATEBRANCH));

    OnEnChangeLogmessage();

    m_linkControl.ConvertStaticToLink(m_hWnd, IDC_CHECKALL);
    m_linkControl.ConvertStaticToLink(m_hWnd, IDC_CHECKNONE);

    // line up all controls and adjust their sizes.
#define LINKSPACING 9
    RECT rc = AdjustControlSize(IDC_SELECTLABEL);
    rc.right -= 15; // AdjustControlSize() adds 20 pixels for the checkbox/radio button bitmap, but this is a label...
    rc = AdjustStaticSize(IDC_CHECKALL, rc, LINKSPACING);
    rc = AdjustStaticSize(IDC_CHECKNONE, rc, LINKSPACING);

    CAppUtils::SetAccProperty(m_cLogMessage.GetSafeHwnd(), PROPID_ACC_ROLE, ROLE_SYSTEM_TEXT);
    CAppUtils::SetAccProperty(m_cLogMessage.GetSafeHwnd(), PROPID_ACC_HELP, CString(MAKEINTRESOURCE(IDS_INPUT_ENTERLOG)));
    CAppUtils::SetAccProperty(m_cLogMessage.GetSafeHwnd(), PROPID_ACC_KEYBOARDSHORTCUT, L"Alt+"+CString(CAppUtils::FindAcceleratorKey(this, IDC_INVISIBLE)));

    CAppUtils::SetAccProperty(GetDlgItem(IDC_CHECKALL)->GetSafeHwnd(), PROPID_ACC_ROLE, ROLE_SYSTEM_LINK);
    CAppUtils::SetAccProperty(GetDlgItem(IDC_CHECKNONE)->GetSafeHwnd(), PROPID_ACC_ROLE, ROLE_SYSTEM_LINK);

    CAppUtils::SetAccProperty(m_URLCombo.GetSafeHwnd(), PROPID_ACC_KEYBOARDSHORTCUT, L"Alt+"+CString(CAppUtils::FindAcceleratorKey(this, IDC_TOURLLABEL)));
    CAppUtils::SetAccProperty(GetDlgItem(IDC_FROMURL)->GetSafeHwnd(), PROPID_ACC_KEYBOARDSHORTCUT, L"Alt+"+CString(CAppUtils::FindAcceleratorKey(this, IDC_COPYSTARTLABEL)));
    CAppUtils::SetAccProperty(GetDlgItem(IDC_DESTURL)->GetSafeHwnd(), PROPID_ACC_KEYBOARDSHORTCUT, L"Alt+"+CString(CAppUtils::FindAcceleratorKey(this, IDC_DESTLABEL)));

    AddAnchor(IDC_REPOGROUP, TOP_LEFT, TOP_RIGHT);
    AddAnchor(IDC_COPYSTARTLABEL, TOP_LEFT, TOP_RIGHT);
    AddAnchor(IDC_FROMURL, TOP_LEFT, TOP_RIGHT);
    AddAnchor(IDC_TOURLLABEL, TOP_LEFT);
    AddAnchor(IDC_URLCOMBO, TOP_LEFT, TOP_RIGHT);
    AddAnchor(IDC_BROWSE, TOP_RIGHT);
    AddAnchor(IDC_DESTLABEL, TOP_LEFT, TOP_RIGHT);
    AddAnchor(IDC_DESTURL, TOP_LEFT, TOP_RIGHT);
    AddAnchor(IDC_MSGGROUP, TOP_LEFT, MIDDLE_RIGHT);
    AddAnchor(IDC_HISTORY, TOP_LEFT);
    AddAnchor(IDC_BUGTRAQBUTTON, TOP_LEFT);
    AddAnchor(IDC_BUGIDLABEL, TOP_RIGHT);
    AddAnchor(IDC_BUGID, TOP_RIGHT);
    AddAnchor(IDC_INVISIBLE, TOP_RIGHT);
    AddAnchor(IDC_LOGMESSAGE, TOP_LEFT, MIDDLE_RIGHT);
    AddAnchor(IDC_FROMGROUP, MIDDLE_LEFT, MIDDLE_RIGHT);
    AddAnchor(IDC_COPYHEAD, MIDDLE_LEFT);
    AddAnchor(IDC_COPYREV, MIDDLE_LEFT);
    AddAnchor(IDC_COPYREVTEXT, MIDDLE_RIGHT);
    AddAnchor(IDC_BROWSEFROM, MIDDLE_RIGHT);
    AddAnchor(IDC_COPYWC, MIDDLE_LEFT);
    AddAnchor(IDC_EXTGROUP, MIDDLE_LEFT, BOTTOM_RIGHT);
    AddAnchor(IDC_SELECTLABEL, MIDDLE_LEFT);
    AddAnchor(IDC_CHECKALL, MIDDLE_LEFT);
    AddAnchor(IDC_CHECKNONE, MIDDLE_LEFT);
    AddAnchor(IDC_EXTERNALSLIST, MIDDLE_LEFT, BOTTOM_RIGHT);
    AddAnchor(IDC_DOSWITCH, BOTTOM_LEFT);
    AddAnchor(IDC_MAKEPARENTS, BOTTOM_LEFT);
    AddAnchor(IDOK, BOTTOM_RIGHT);
    AddAnchor(IDCANCEL, BOTTOM_RIGHT);
    AddAnchor(IDHELP, BOTTOM_RIGHT);

    if ((m_pParentWnd==NULL)&&(GetExplorerHWND()))
        CenterWindow(CWnd::FromHandle(GetExplorerHWND()));
    EnableSaveRestore(L"CopyDlg");

    m_bSettingChanged = false;
    if (!m_path.IsUrl())
    {
        // start a thread to obtain the highest revision number of the working copy
        // without blocking the dialog
        if ((m_pThread = AfxBeginThread(FindRevThreadEntry, this))==NULL)
        {
            OnCantStartThread();
        }
    }

    return TRUE;
}
예제 #15
0
BOOL CInstall::InitInstance()
{
	// Log
	CLog::Instance()->Log(_T("CInstall::InitInstance()"));

	// Set parent to NULL
	m_pParent = NULL;

	// We are not started yet
	m_bStarted = false;
	
	// Reserve memory for buffer
	m_szFilename = (TCHAR *)malloc(sizeof(TCHAR) * 500);
	ZeroMemory(m_szFilename, sizeof(TCHAR) * 500);

	// Start install files thread
	m_pInstallFiles = (CInstallFiles *)AfxBeginThread(RUNTIME_CLASS(CInstallFiles),
		THREAD_PRIORITY_NORMAL,
		0,
		0,
		NULL);

	// Start install ini thread
	m_pInstallIni = (CInstallIni *)AfxBeginThread(RUNTIME_CLASS(CInstallIni),
		THREAD_PRIORITY_NORMAL,
		0,
		0,
		NULL);
	
	// Start install registry thread
	m_pInstallRegistry = (CInstallRegistry *)AfxBeginThread(RUNTIME_CLASS(CInstallRegistry),
		THREAD_PRIORITY_NORMAL,
		0,
		0,
		NULL);

	// Init singleton classes
	m_pFunctions = CFunctions::Instance();
	m_pSettings = CSettings::Instance();
	m_pUpdateInfo = CUpdateInfo::Instance();
	m_pLanguage = CLanguage::Instance();
	m_pPath = CPath::Instance();

	// Extract UpdaterCopy.exe from this executable
	if (m_pUpdateInfo->GetSelfUpdate())
		ExtractUpdaterCopy();

	// Set parent
	m_pInstallFiles->PostThreadMessage(WMU_SETPARENT, (WPARAM)this, 0);
	m_pInstallIni->PostThreadMessage(WMU_SETPARENT, (WPARAM)this, 0);
	m_pInstallRegistry->PostThreadMessage(WMU_SETPARENT, (WPARAM)this, 0);

	// Suspend all threads
	/*m_pInstallFiles->SuspendThread();
	m_pInstallIni->SuspendThread();
	m_pInstallRegistry->SuspendThread();*/

	// Set some default values
	m_iPreviousActionsPerformed = 0;
	m_iTotalActionsPerformed = 0;

	return TRUE;
}
예제 #16
0
void CChildView::BeginThinkThread()
{
	//my
	AfxBeginThread( ThinkThread, 0, THREAD_PRIORITY_BELOW_NORMAL/*THREAD_PRIORITY_TIME_CRITICAL*/ );
	//end
}
예제 #17
0
void CFoldView::OnStart() 
{
	int i;

	//a trap to make sure the calculation is started more than once
	if (started) return;
	started=true;

	if(m_sequencename=="") {
		MessageBox("Please specify a sequence name.");
		return;
	}
	UpdateData(TRUE);



    //if (dynnumber<m_number) dynnumber = m_number;
    //if (dynpercent<m_percent) dynpercent = m_percent;
    //if (dynwindow>m_window) dynwindow = m_window;
	//check to see if the temperature has been changed.
	if (GetFoldDocument()->T<310||GetFoldDocument()->T>311) {

		//change the temperature from 310.15
		if (GetFoldDocument()->newtemp()==0) {
			//if newtemp returned zero, pass a warning to the user
			AfxMessageBox( "An enthalpy data file could not be found!\nTemperature of prediction will revert back to 37 degrees C.\nData files can be downloaded on the Mathews Lab website,\nhttp://rna.urmc.rochester.edu.", 
				MB_OK|MB_ICONHAND);

		}

	}

	//TProgressDialog *progress;
	progress = new TProgressDialog();//parent,"Folding the RNA..."
	CRect *rect;
	rect = new CRect(10,40,210,120);
	
	if (GetFoldDocument()->ISRNA)
	progress->Create(NULL,"Folding the RNA...",WS_CHILD|WS_VISIBLE|WS_CAPTION,*rect);//(IDD_PROGRESSDIALOG);//
	else progress->Create(NULL,"Folding the DNA...",WS_CHILD|WS_VISIBLE|WS_CAPTION,*rect);
	delete rect;


	
	
	foldobject.parent=this;
	foldobject.ct=&(GetFoldDocument()->ct);
	foldobject.data=&GetFoldDocument()->data;
	foldobject.dynpercent = m_percent;
	foldobject.dynwindow = m_window;
	foldobject.progress = progress;
	foldobject.ctoutfile = m_ctname.GetBuffer(10);
	foldobject.dynnumber = m_number ;
	foldobject.maximuminternalloopsize=GetFoldDocument()->maximuminternalloopsize;

	if (m_save) {
		i = m_ctname.GetLength();
		
		foldobject.savefile = new char[i+4];
		strcpy(foldobject.savefile,m_ctname.GetBuffer(10));
		//count the characters to the .
		
		while(i>=0){
			
			if (foldobject.savefile[i]=='.') break;
			i--;
		}
		if (i==0) i = strlen(foldobject.savefile);
		strcpy(foldobject.savefile+i+1,"sav\0");
		*GetFoldDocument()->savefile = true; 

	}
	else {
		foldobject.savefile = 0;
		*GetFoldDocument()->savefile = false; 
	}

	
	foldobject.subfold=subfold;

	
	
	AfxBeginThread(FoldProc,&foldobject);
	

	


	

	
}
예제 #18
0
void CMessageSender::SendMsg(CInstantMessage msg)
{
    this->message = msg;

    AfxBeginThread(SendMsgWorkerThread, this);
}
예제 #19
0
BOOL CclockDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	// 设置此对话框的图标。当应用程序主窗口不是对话框时,框架将自动
	//  执行此操作
	//SetIcon(m_hIcon, TRUE);			// 设置大图标
	//SetIcon(m_hIcon, FALSE);		// 设置小图标

	// TODO: 在此添加额外的初始化代码
	//设置程序运行时不在任务栏的运行区显示图标
	SetWindowLong(this->m_hWnd,GWL_EXSTYLE,WS_EX_TOOLWINDOW); 
	
	//设置控制时针走动的触发器为每秒一次,即引发WM_TIMER消息的频率是每秒一次。
	m_timer = this->SetTimer(1, 1000, NULL);
	
///////////////////////////////////////////////////////////////	
	CRgn  rgn;   
	CRect  rc;   
	GetClientRect(&rc);   
    rgn.CreateEllipticRgn(rc.left,rc.top,rc.right,rc.bottom);   
    SetWindowRgn(rgn,TRUE);   
    rgn.DeleteObject();  
//////////////////////////////////////////////////////////////
	CBitmap   bm;   
	bm.LoadBitmap(IDB_BITMAP1);   //   IDB_BITMAP1为BITMAP资源ID,可以指定bitmap图片的路径   
	m_brush.CreatePatternBrush(&bm);   

	//SoundTime();
	//sndPlaySoundA("AM.wav",SND_ASYNC);
	//将对话框的句柄传递到CWinSunApp类中。sunxin
//	((CclockApp*)AfxGetApp())->m_hwndDlg=m_hWnd;




	DWORD dwParam;
	pThread=AfxBeginThread(ThreadProc,&dwParam,THREAD_PRIORITY_HIGHEST,0,CREATE_SUSPENDED,0);
	if(pThread==NULL)
		AfxMessageBox("创建线程错误!");



	DWORD dwParam2;
	pThread2=AfxBeginThread(ThreadProc2,&dwParam2,THREAD_PRIORITY_HIGHEST,0,CREATE_SUSPENDED,0);
	if(pThread2==NULL)
		AfxMessageBox("创建线程错误!");



	DWORD dwParam3;
	pThread3=AfxBeginThread(ThreadProc3,&dwParam3,THREAD_PRIORITY_HIGHEST,0,CREATE_SUSPENDED,0);
	if(pThread3==NULL)
		AfxMessageBox("创建线程错误!");



	int temp=AfxGetApp()->GetProfileInt("Sound","hoursound",0);
	if(temp==1)
		hoursound=true;
	else
		hoursound=false;
	temp=AfxGetApp()->GetProfileInt("Sound","halfhoursound",0);
	if(temp==1)
		halfhoursound=true;
	else
		halfhoursound=false;



	ringnum=AfxGetApp()->GetProfileIntA("ring","ringnum",0);
	CString time;
	CString temps;
	for(int i=0;i<ringnum;i++)
	{
		temps.Format("ring%d",i+1);
		time=AfxGetApp()->GetProfileStringA("ring",temps);
		mytimearray[i].hour=(time[0]-48)*10+time[1]-48;
		mytimearray[i].minute=(time[3]-48)*10+time[4]-48;
		mytimearray[i].second=(time[6]-48)*10+time[7]-48;
	}

	tasknum=AfxGetApp()->GetProfileIntA("task","tasknum",0);
	CString taskdate;
	CString tasktime;
	for(int i=0;i<tasknum;i++)
	{
		temps.Format("taskdate%d",i+1);
		taskdate=AfxGetApp()->GetProfileStringA("taskdate",temps);
		temps.Format("tasktime%d",i+1);
		tasktime=AfxGetApp()->GetProfileStringA("tasktime",temps);
		mytaskarray[i].year=(taskdate[0]-48)*1000+(taskdate[1]-48)*100+(taskdate[2]-48)*10+taskdate[3]-48;
		mytaskarray[i].month=(taskdate[5]-48)*10+taskdate[6]-48;
		mytaskarray[i].day=(taskdate[8]-48)*10+taskdate[9]-48;
		mytaskarray[i].hour=(tasktime[0]-48)*10+tasktime[1]-48;
		mytaskarray[i].minute=(tasktime[3]-48)*10+tasktime[4]-48;
		mytaskarray[i].second=(tasktime[6]-48)*10+tasktime[7]-48;
		temps.Format("task%d",i+1);
		mytaskarray[i].typle=AfxGetApp()->GetProfileIntA("task",temps,0);
	}





	return TRUE;  // 除非将焦点设置到控件,否则返回 TRUE
}
예제 #20
0
BOOL CVideoSourceListBox::OnCommand(WPARAM wParam, LPARAM lParam) 
{
	// TODO: Speziellen Code hier einfügen und/oder Basisklasse aufrufen
	CVideoInformationDlg*	lpvidlg;
	int						iIndex;
	VIDEOSOURCE*			lpVS;
	// TODO: Speziellen Code hier einfügen und/oder Basisklasse aufrufen
	CWinThread*	thread;
//	CFileDialog*	cfd;
	CAVIMux_GUIDlg*	cMainDlg = (CAVIMux_GUIDlg*)GetParent();
	char cFilter[256];
	std::basic_string<TCHAR> cDefExt;
	int open = 0;
	VIDEOSOURCE* v;
	OPENFILENAME o; 
	memset(&o, 0, sizeof(o));


	switch (LOWORD(wParam))
	{
		case IDM_VIDEOINFORMATION:
			iIndex=GetCurSel();
			if (iIndex!=LB_ERR)
			{
				lpVS=(VIDEOSOURCE*)GetItemData(iIndex);
				lpvidlg=new CVideoInformationDlg;
				lpvidlg->SetVideoSource(lpVS);
				lpvidlg->DoModal();
				delete lpvidlg;
			}
			break;
		case IDM_EXTRACT_BINARY:
			ZeroMemory(cFilter,sizeof(cFilter));
//			ZeroMemory(cDefExt,sizeof(cDefExt));
			
			iIndex = GetCurSel();
			if (iIndex == LB_ERR)
				iIndex = 0;

			v = (VIDEOSOURCE*)GetItemData(iIndex);

	
			strcpy(cFilter,"*.raw|*.raw||");
			cDefExt = _T("mp3");
			 

			PrepareSimpleDialog(&o, m_hWnd, cFilter);
			o.Flags |= OFN_OVERWRITEPROMPT;
			o.lpstrDefExt = cDefExt.c_str();
			open = GetOpenSaveFileNameUTF8(&o, 0);
			
			if (open) {
				EXTRACT_THREAD_VIDEO_DATA* lpETD = new EXTRACT_THREAD_VIDEO_DATA;
				lpETD->file = new CFileStream;
				if (lpETD->file->Open(o.lpstrFile,STREAM_WRITE)!=STREAM_ERR) {
					lpETD->dlg = cMainDlg;
					lpETD->v = v;
					cMainDlg->m_Prg_Dest_File.SetWindowText(o.lpstrFile);
					thread=AfxBeginThread((AFX_THREADPROC)ExtractThread,lpETD);
				} else {
					CUTF8 message(LoadString(IDS_COULDNOTOPENOUTPUTFILE));
					CUTF8 title(LoadString(STR_GEN_ERROR));

					MessageBox(message.TStr(), title.TStr(), MB_OK | MB_ICONERROR);

					//MessageBox(LoadString(IDS_COULDNOTOPENOUTPUTFILE),LoadString(STR_GEN_ERROR),
					//	MB_OK | MB_ICONERROR);
				}
			}
			
			break;
	}
	
	return CEnhancedListBox::OnCommand(wParam, lParam);
}
예제 #21
0
void CFileDiffDlg::OnTimer(UINT_PTR nIDEvent)
{
	if (m_bThreadRunning)
		return;

	if( nIDEvent == IDT_FILTER)
	{
		CString sFilterText;
		KillTimer(IDT_FILTER);
		m_cFilter.GetWindowText(sFilterText);

		m_cFileList.SetRedraw(FALSE);
		m_cFileList.DeleteAllItems();

		Filter(sFilterText);

		m_cFileList.SetRedraw(TRUE);

		__super::OnTimer(nIDEvent);
	}

	if( nIDEvent == IDT_INPUT)
	{
		KillTimer(IDT_INPUT);
		TRACE(_T("Input Timer\r\n"));

		GitRev gitrev;
		CString str;
		int mask = 0;
		this->m_ctrRev1Edit.GetWindowText(str);
		try
		{
			if (!gitrev.GetCommit(str))
			{
				m_rev1 = gitrev;
				mask |= 0x1;
			}
		}
		catch (const char *msg)
		{
			CMessageBox::Show(m_hWnd, _T("Could not get commit ") + str + _T("\nlibgit reports:\n") + CString(msg), _T("TortoiseGit"), MB_ICONERROR);
		}

		this->m_ctrRev2Edit.GetWindowText(str);

		try
		{
			if (!gitrev.GetCommit(str))
			{
				m_rev2 = gitrev;
				mask |= 0x2;
			}
		}
		catch (const char *msg)
		{
			CMessageBox::Show(m_hWnd, _T("Could not get commit ") + str + _T("\nlibgit reports:\n") + CString(msg), _T("TortoiseGit"), MB_ICONERROR);
		}

		this->SetURLLabels(mask);

		if(mask == 0x3)
		{

			InterlockedExchange(&m_bThreadRunning, TRUE);
			if (AfxBeginThread(DiffThreadEntry, this)==NULL)
			{
				InterlockedExchange(&m_bThreadRunning, FALSE);
				CMessageBox::Show(NULL, IDS_ERR_THREADSTARTFAILED, IDS_APPNAME, MB_OK | MB_ICONERROR);
			}
		}
	}
}
예제 #22
0
/*******************************************************************************
  Function Name  : OnKeyDown
  Input(s)       : nChar, nRepCnt, nFlags
  Output         : -
  Functionality  : Handle the case of VK_ADD CTRL + NumPlus (Auto size all columns).
  Member of      : CRxMsgList
  Author(s)      : Arunkumar K
  Date Created   : 20-05-2010
  Modifications  : 14-09-2010, ArunKumar K,
                   Added new Handlers for VK_PRIOR, VK_NEXT, VK_END, VK_HOME.
                   15-07-2010, ArunKumar K,
                   Added new Handlers for VK_UP, VK_DOWN.
                   13-07-2010, ArunKumar K,
                   Added new Handlers for VK_LEFT, VK_RIGHT, VK_RETURN.
*******************************************************************************/
void CRxMsgList::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
    switch(nChar)
    {
        case VK_ADD:    // CTRL + NumPlus (Auto size all columns)
        {
            if (GetKeyState(VK_CONTROL) < 0)
            {
                // Special handling to avoid showing "hidden" columns
                SetColumnWidthAuto(-1);
                return;
            }
        }
        break;
        case VK_UP:
        {
            BOOL bInterpret = FALSE;
            ::SendMessage( m_hParent, WM_GET_INTERPRET_STATE, (WPARAM)&bInterpret, 0);
            if(bInterpret)
            {
                INT nItem = GetNextItem(-1, LVNI_SELECTED);
                if (nItem != -1)
                {
                    GetParent()->SendMessage(WM_GET_NEXT_PREV_MSG_INDEX, (WPARAM)false, (LPARAM)&nItem);
                    SetItemState(nItem-1,LVIS_SELECTED , LVIS_SELECTED );
                    return;
                }
            }
            break;
        }
        case VK_DOWN:
        {
            BOOL bInterpret = FALSE;
            ::SendMessage( m_hParent, WM_GET_INTERPRET_STATE, (WPARAM)&bInterpret, 0);
            if(bInterpret)
            {
                INT nItem = GetNextItem(-1, LVNI_SELECTED);
                if (nItem != -1)
                {
                    GetParent()->SendMessage(WM_GET_NEXT_PREV_MSG_INDEX, (WPARAM)true, (LPARAM)&nItem);
                    SetItemState(nItem+1,LVIS_SELECTED , LVIS_SELECTED );
                    return;
                }
            }
            break;
        }
        case VK_LEFT:
        {
            INT nItem = GetNextItem(-1, LVNI_SELECTED);
            if (nItem != -1)
            {
                GetParent()->SendMessage(WM_EXPAND_COLLAPSE_MSG, nItem, TREESTATE_COLLAPSE);
                SetItemState(nItem,LVIS_SELECTED , LVIS_SELECTED );
                return;
            }
            break;
        }
        case VK_RIGHT:
        {
            INT nItem = GetNextItem(-1, LVNI_SELECTED);
            if (nItem != -1)
            {
                GetParent()->SendMessage(WM_EXPAND_COLLAPSE_MSG, nItem, TREESTATE_EXPAND);
                SetItemState(nItem,LVIS_SELECTED , LVIS_SELECTED );
                return;
            }
            break;
        }
        case VK_RETURN:
        {
            INT nItem = GetNextItem(-1, LVNI_SELECTED);
            if (nItem != -1)
            {
                GetParent()->SendMessage(WM_EXPAND_COLLAPSE_MSG, nItem, TREESTATE_TOGGLE);
            }
            break;
        }
        case VK_PRIOR:
        case VK_NEXT:
        case VK_END:
        case VK_HOME:
        {
            BOOL bInterpret = FALSE;
            ::SendMessage( m_hParent, WM_GET_INTERPRET_STATE, (WPARAM)&bInterpret, 0);
            if ( bInterpret )
            {
                AfxBeginThread(UpDateThread, (LPVOID)this);
            }
        }
    }
    CListCtrl::OnKeyDown(nChar, nRepCnt, nFlags);
}
예제 #23
0
void CFileDiffDlg::ClickRevButton(CMenuButton *button, GitRev *rev, CACEdit *edit)
{
	INT_PTR entry=button->GetCurrentEntry();
	if(entry == 0) /* Browse Refence*/
	{
		{
			CString str = CBrowseRefsDlg::PickRef();
			if(str.IsEmpty())
				return;

			if(FillRevFromString(rev,str))
				return;

			edit->SetWindowText(str);
		}
	}

	if(entry == 1) /*Log*/
	{
		CLogDlg dlg;
		dlg.SetSelect(true);
		if(dlg.DoModal() == IDOK)
		{
			if( dlg.GetSelectedHash().IsEmpty() )
				return;

			if(FillRevFromString(rev,dlg.GetSelectedHash()))
				return;

			edit->SetWindowText(dlg.GetSelectedHash());

		}
		else
			return;
	}

	if(entry == 2) /*RefLog*/
	{
		CRefLogDlg dlg;
		if(dlg.DoModal() == IDOK)
		{
			if(FillRevFromString(rev,dlg.m_SelectedHash))
				return;

			edit->SetWindowText(dlg.m_SelectedHash);

		}
		else
			return;
	}

	SetURLLabels();

	InterlockedExchange(&m_bThreadRunning, TRUE);
	if (AfxBeginThread(DiffThreadEntry, this)==NULL)
	{
		InterlockedExchange(&m_bThreadRunning, FALSE);
		CMessageBox::Show(NULL, IDS_ERR_THREADSTARTFAILED, IDS_APPNAME, MB_OK | MB_ICONERROR);
	}
	KillTimer(IDT_INPUT);
}
예제 #24
0
파일: djvuDlg.cpp 프로젝트: mar80nik/djvu
void SearchRsltDlg::OnProced() 
{
	MAINAPP->m_pMainWnd->SetWindowText("Working"); 
	MAINAPP->StopThread=AfxBeginThread(Collect_Function2,NULL);	
	Proceed.EnableWindow(false);
}
예제 #25
0
void StartListener()
{
	ListenerInfo.KeepGoing = true;
	AfxBeginThread(ListenThreadFunction, &ListenerInfo);
}
예제 #26
0
BOOL CHttpDownloadDlg::OnInitDialog()
{
	static const uint16 s_auResTbl[][2] =
	{
		{ IDCANCEL, IDS_CANCEL },
		{ IDC_STATIC_ESTTIME, IDS_DLCOL_REMAININGTIME },
		{ IDC_STATIC_TRATE, IDS_INFLST_USER_AVERAGEDOWNRATE }
	};
	CString	strTmp;

	for (unsigned ui = 0; ui < ARRSIZE(s_auResTbl); ui++)
		SetDlgItemText(s_auResTbl[ui][0], GetResString(s_auResTbl[ui][1]));
	SetWindowText(m_strInitializingTitle);

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

	//Setup the animation control
	m_ctrlAnimate.Open(IDR_HTTPDOWNLOAD_ANIMATION);

	//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_uPort))
	{
		//Try sticking "http://" before it
		m_sURLToDownload = _T("http://") + m_sURLToDownload;
		if (!AfxParseURL(m_sURLToDownload, m_dwServiceType, m_sServer, m_sObject, m_uPort))
		{
			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
	CFileStatus fs;
	ASSERT(m_sFileToDownloadInto.GetLength());
	if (CFile::GetStatus(m_sFileToDownloadInto, fs))
	{
		strTmp.Format(GetResString(IDS_HTTPDOWNLOAD_OK_TO_OVERWRITE), m_sFileToDownloadInto);
		if (AfxMessageBox(strTmp, 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());
		strTmp.Format(GetResString(IDS_HTTPDOWNLOAD_FAIL_FILE_OPEN), ::GetLastError());
		AfxMessageBox(strTmp);
		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;

	//Set the file status text
	strTmp.Format(GetResString(IDS_HTTPDOWNLOAD_OF), m_sFilename, m_sServer);
	m_ctrlFileStatus.SetWindowText(strTmp);

	//Spin off the background thread which will do the actual downloading
	m_pThread = AfxBeginThread(_DownloadThread, this, THREAD_PRIORITY_NORMAL+ g_App.m_pPrefs->GetMainProcessPriority(), 0, 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;
}
예제 #27
0
void CpeepmBrowser::OnBnClickedBrowserButton()
{
    CStringA tmp = "http://";
    tmp.Append(Server);
    CString server(tmp);

    CString content = _T("");
    m_Edit.GetWindowText(content);
    if (content.GetLength() > 0 && content.Find(server) > -1)
    {
        TCHAR tmp[1024] = {0};
        GetModuleFileName(NULL, tmp, sizeof(tmp));
        CString path = tmp;
        path = path.Left(path.ReverseFind('\\'));
        path.Append(_T("\\"));

        CFileDialog open(TRUE);
        open.m_ofn.lpstrTitle = _T("选择账号");
        open.m_ofn.lpstrInitialDir = path;
        INT_PTR resp = open.DoModal();
        if (resp == IDOK)
        {
            CString path = open.GetPathName();

            char* url = CpeepmUtil::WideCharToChar(content, content.GetLength());
            if (url == NULL)
                return;

            char* p = CpeepmUtil::WideCharToChar(path, path.GetLength());

            CpeepmDlg* parent = (CpeepmDlg*)GetParent();
            m_ThreadMax = 1;
            DWORD delay = parent->GetDelay();

            BOOL* success = new BOOL;
            *success = FALSE;
            CCriticalSection* section = new CCriticalSection();
            CEvent* event = new CEvent(FALSE, TRUE, NULL, NULL);
            PeepmBrowser* browser = new PeepmBrowser();
            browser->path = p;
            browser->username = NULL;
            browser->password = NULL;
            browser->next = NULL;
            browser->use = FALSE;
            browser->section = NULL;

            m_Crack = new CpeepmCrack*[m_ThreadMax];

            for (UINT i = 0; i < m_ThreadMax; i++)
            {
                CpeepmCrack* crack = new CUrlBrowser(browser, url, success, i, m_ThreadMax, delay, section, event, NULL, *this);
                m_Crack[i] = crack;
                CWinThread* thread = AfxBeginThread(CpeepmCrack::OnThread, crack);
                crack->SetThread(thread);
            }

            CWinThread* thread = AfxBeginThread(CUrlBrowser::InitAccount, m_Crack[0]);
            m_Button.EnableWindow(FALSE);
        }
    }
}
예제 #28
0
int CFrontendDlg::StartOlsrd()
{
	WSADATA WsaData;
	CString CmdLine;
	char Path[MAX_PATH];
	char TempPath[MAX_PATH];
	int Try;

	m_TabCtrl.m_Dialog3.ClearNodeInfo();
	m_TabCtrl.m_Dialog4.ClearRoutes();

	if (WSAStartup(0x0202, &WsaData))
	{
		AfxMessageBox("Cannot initialize WinSock library.");
		return -1;
	}

	::GetModuleFileName(NULL, Path, MAX_PATH);

	CmdLine = Path;
	CmdLine = CmdLine.Mid(0, CmdLine.ReverseFind('\\')) + "\\Shim.exe";

	::GetTempPath(MAX_PATH - 16, Path);
	::GetTempFileName(Path, "GNU", 0, TempPath);

	StoredTempFile = TempPath;

	if (m_TabCtrl.m_Dialog2.SaveConfigFile(StoredTempFile, 0) < 0)
	{
		AfxMessageBox("Cannot save temporary configuration file '" + 
			StoredTempFile + "'.");
		return -1;
	}

	CmdLine += " -f " + StoredTempFile;

	if (ExecutePipe((const char *)CmdLine, &InWrite, &OutRead, &ShimProc) < 0)
	{
		AfxMessageBox("Cannot execute '" + CmdLine + "'.");
		return -1;
	}

	PipeMode = PIPE_MODE_RUN;

	LogThread = AfxBeginThread(LogThreadStub, (void *)this);

	struct sockaddr_in Addr;

	Addr.sin_family = AF_INET;
	Addr.sin_port = ::htons(1212);
	Addr.sin_addr.s_addr = ::inet_addr("127.0.0.1");

	SockHand = ::socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);

	if (SockHand < 0)
	{
		AfxMessageBox("Cannot create IPC socket.");

		::SetEvent(Event);
		::WaitForSingleObject((HANDLE)LogThread, INFINITE);

		LogThread = NULL;

		return -1;
	}

	for (Try = 0; Try < 5; Try++)
	{
		if (::connect(SockHand, (struct sockaddr *)&Addr,
			sizeof (struct sockaddr_in)) >= 0)
			break;

		::Sleep(500);
	}

	if (Try == 10)
	{
		AfxMessageBox("Cannot connect to IPC port.");

		::SetEvent(Event);
		::WaitForSingleObject((HANDLE)LogThread, INFINITE);

		::closesocket(SockHand);

		LogThread = NULL;

		return -1;
	}

	NetThread = AfxBeginThread(NetThreadStub, (void *)this);

	return 0;
}
예제 #29
0
BOOL CTrafficMonitorApp::InitInstance()
{
	//设置配置文件的路径
	wchar_t path[MAX_PATH];
	GetModuleFileNameW(NULL, path, MAX_PATH);
	m_module_path = path;
	m_system_path = CCommon::GetSystemPath();
	m_temp_path = CCommon::GetTemplatePath();
	m_app_data_cfg_path = CCommon::GetAppDataConfigPath();
#ifdef _DEBUG
	m_config_path = L".\\config.ini";
	m_history_traffic_path = L".\\history_traffic.dat";
	m_log_path = L".\\error.log";
	m_skin_path = L".\\skins";
#else
	//AppData里面的程序配置文件路径
	m_config_path = m_app_data_cfg_path + L"config.ini";
	m_history_traffic_path = m_app_data_cfg_path + L"history_traffic.dat";
	m_log_path = m_app_data_cfg_path + L"error.log";
	//原来的、程序所在目录下的配置文件的路径
	wstring exe_path = CCommon::GetExePath();
	wstring config_path_old = exe_path + L"config.ini";
	wstring history_traffic_path_old = exe_path + L"history_traffic.dat";
	wstring log_path_old = exe_path + L"error.log";
	//如果程序所在目录下含有配置文件,则将其移动到AppData对应的目录下面
	CCommon::MoveAFile(config_path_old.c_str(), m_config_path.c_str());
	CCommon::MoveAFile(history_traffic_path_old.c_str(), m_history_traffic_path.c_str());
	CCommon::MoveAFile(log_path_old.c_str(), m_log_path.c_str());

	m_skin_path = exe_path + L"skins";
#endif

	m_is_windows10_fall_creator = CCommon::IsWindows10FallCreatorOrLater();

	//从ini文件载入设置
	LoadConfig();

	//初始化界面语言
	CCommon::SetThreadLanguage(m_general_data.language);

#ifndef _DEBUG
	wstring cmd_line{ m_lpCmdLine };
	bool is_restart{ cmd_line.find(L"RestartByRestartManager") != wstring::npos };		//如果命令行参数中含有字符串“RestartByRestartManager”则说明程序是被Windows重新启动的
	//bool when_start{ CCommon::WhenStart(m_no_multistart_warning_time) };
	if (is_restart && m_is_windows10_fall_creator)		//当前Windows版本是秋季创意者更新时,如果程序被重新启动,则直接退出程序
	{
		//AfxMessageBox(_T("调试信息:程序已被Windows的重启管理器重新启动。"));
		return FALSE;
	}

	//检查是否已有实例正在运行
	HANDLE hMutex = ::CreateMutex(NULL, TRUE, _T("TrafficMonitor-1419J3XLKL1w8OZc"));
	if (hMutex != NULL)
	{
		if (GetLastError() == ERROR_ALREADY_EXISTS)
		{
			//char buff[128];
			//string cmd_line_str{ CCommon::UnicodeToStr(cmd_line.c_str()) };
			//sprintf_s(buff, "when_start=%d, m_no_multistart_warning=%d, cmd_line=%s", when_start, m_no_multistart_warning, cmd_line_str.c_str());
			//CCommon::WriteLog(buff, _T(".\\start.log"));
			if (!m_no_multistart_warning)
			{
				AfxMessageBox(CCommon::LoadText(IDS_AN_INSTANCE_RUNNING));
			}
			return FALSE;
		}
	}
#endif

	SaveConfig();

	// 如果一个运行在 Windows XP 上的应用程序清单指定要
	// 使用 ComCtl32.dll 版本 6 或更高版本来启用可视化方式,
	//则需要 InitCommonControlsEx()。  否则,将无法创建窗口。
	INITCOMMONCONTROLSEX InitCtrls;
	InitCtrls.dwSize = sizeof(InitCtrls);
	// 将它设置为包括所有要在应用程序中使用的
	// 公共控件类。
	InitCtrls.dwICC = ICC_WIN95_CLASSES;
	InitCommonControlsEx(&InitCtrls);

	CWinApp::InitInstance();


	AfxEnableControlContainer();

	// 创建 shell 管理器,以防对话框包含
	// 任何 shell 树视图控件或 shell 列表视图控件。
	CShellManager *pShellManager = new CShellManager;

	// 激活“Windows Native”视觉管理器,以便在 MFC 控件中启用主题
	CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerWindows));

	// 标准初始化
	// 如果未使用这些功能并希望减小
	// 最终可执行文件的大小,则应移除下列
	// 不需要的特定初始化例程
	// 更改用于存储设置的注册表项
	// TODO: 应适当修改该字符串,
	// 例如修改为公司或组织名
	SetRegistryKey(_T("应用程序向导生成的本地应用程序"));

	//启动时检查更新
	if (m_general_data.check_update_when_start)
	{
		m_pUpdateThread = AfxBeginThread(CheckUpdateThreadFunc, NULL);
	}

	CTrafficMonitorDlg dlg;
	m_pMainWnd = &dlg;
	INT_PTR nResponse = dlg.DoModal();
	if (nResponse == IDOK)
	{
		// TODO: 在此放置处理何时用
		//  “确定”来关闭对话框的代码
	}
	else if (nResponse == IDCANCEL)
	{
		// TODO: 在此放置处理何时用
		//  “取消”来关闭对话框的代码
	}
	else if (nResponse == -1)
	{
		TRACE(traceAppMsg, 0, "警告: 对话框创建失败,应用程序将意外终止。\n");
		TRACE(traceAppMsg, 0, "警告: 如果您在对话框上使用 MFC 控件,则无法 #define _AFX_NO_MFC_CONTROLS_IN_DIALOGS。\n");
	}

	// 删除上面创建的 shell 管理器。
	if (pShellManager != NULL)
	{
		delete pShellManager;
	}

#ifndef _AFXDLL
	ControlBarCleanUp();
#endif

	// 由于对话框已关闭,所以将返回 FALSE 以便退出应用程序,
	//  而不是启动应用程序的消息泵。
	return FALSE;
}
예제 #30
0
void CAgentMonitorDlg::BroadcastSend()
{
	static int nSeq = 1;
	CString s;

	if (m_pThread == NULL)
	{
		m_bRun = TRUE;
		m_pEvent = new CEvent(FALSE, FALSE);
		m_pThread = AfxBeginThread(WorkProc, this);

		if (m_pThread == NULL)
		{
			m_bRun = FALSE;
			delete m_pEvent;
			m_pEvent = NULL;

			ReportMessageWrite(_T("쓰레드 생성 실패"));
			return;
		}
		
		m_pThread->m_bAutoDelete = FALSE;

		ReportMessageWrite(_T("쓰레드 생성 성공"));
	}

	SOCKET sock = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
	if (sock == INVALID_SOCKET)
	{
		s.Format(_T("\r\nSEND %d -> 실패: 소켓생성(%d)"), nSeq, WSAGetLastError());
		BroadcastMessageWrite(s);
	}

	char opt = 1; 
	setsockopt(sock, SOL_SOCKET, SO_BROADCAST, (char*)&opt, sizeof(char));

	SOCKADDR_IN sockaddr;
	memset(&sockaddr, 0, sizeof(sockaddr));
	sockaddr.sin_family = AF_INET;
	sockaddr.sin_port = htons(_UDP_PORT);
	sockaddr.sin_addr.s_addr = inet_addr("192.168.0.255");

	char msg[256];
	int nMsg = sprintf_s(msg, _T("SHi, there! (%d)"), nSeq);
	int n = sendto(sock, msg, nMsg, 0, (struct sockaddr*)&sockaddr, (int)sizeof(sockaddr));

	if (n == SOCKET_ERROR)
	{
		s.Format(_T("\r\nSEND %d -> 실패: 발송(%d)"), nSeq, WSAGetLastError());
		BroadcastMessageWrite(s);
	}
	else
	{
		s.Format(_T("\r\nSEND %d -> 성공(%d/%d)"), nSeq, n, nMsg);
		BroadcastMessageWrite(s);
	}

	::closesocket(sock);

	nSeq++;
	m_nTimer = SetTimer(1, _INTERVAL_BROADCAST * 1000, NULL);
}