⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 capturescreendlg.cpp

📁 在wince中定时捕获桌面图片信息
💻 CPP
📖 第 1 页 / 共 2 页
字号:

	CString strName;
	TCHAR szFilters[]=_T("Route File (*.ini)|*.ini||"); 
	//调用,打开文件对话框,选择Access数据库文件
	CFileDialog fileDlg (TRUE, _T("Route"),_T("*.ini"),OFN_FILEMUSTEXIST,szFilters,this);

	if (fileDlg.DoModal() == IDOK)
	{
		CString	strRouteFile=fileDlg.GetPathName();
		
		CHAR cPath[MAX_PATH];
		memset( cPath, 0, MAX_PATH );
		sprintf(cPath,"%s",strRouteFile);
		//sprintf( cPath, "%s%s",g_cAppPath,STR_PATH_INI_STYLE);"\\Storage Card\\routeinfo.ini"
		m_List.DeleteAllItems();
		
		if(m_fIni.Open(cPath,100))
		{
				//按钮风格
			int count=0;
			CHAR* chResult = NULL;
			chResult = m_fIni.Read("COUNT");
			if ( chResult && strlen(chResult) )
				count = atoi( chResult );			
		
			int id;
		
			double dLongitude,dLatitude;
			for(int i=1;i<=count;i++)
			{
				CString strID, strAddress,strCustName,strCustomCode,strCustomPhone,
					strLongitude,strLatitude;
				char cID[MAX_LEN],cAddress[MAX_LEN],cCustName[MAX_LEN],
					cCustomCode[MAX_LEN],cCustomPhone[MAX_LEN],
					cLongitude[MAX_LEN],cLatitude[MAX_LEN];
				memset(cID,0,MAX_LEN);
				memset(cAddress,0,MAX_LEN);
				memset(cCustName,0,MAX_LEN);
				memset(cCustomCode,0,MAX_LEN);
				memset(cCustomPhone,0,MAX_LEN);
				memset(cLongitude,0,MAX_LEN);
				memset(cLatitude,0,MAX_LEN);
				
				sprintf(cID,  "ID%d",i );
				chResult = m_fIni.Read(cID);
				if ( chResult && strlen(chResult) )
				{
					id = atoi( chResult );
					//strID.GetBuffer(MAX_LEN);
					strID=chResult;
				}
				
				sprintf(cAddress,  "Address%d",i );
				chResult = m_fIni.Read(cAddress);
				if ( chResult && strlen(chResult) )
				{
					//strAddress.GetBuffer(MAX_LEN);
					strAddress=chResult;	
				}
				
				sprintf(cCustomCode,  "CustomCode%d",i );
				chResult = m_fIni.Read(cCustomCode);
				if ( chResult && strlen(chResult) )
				{
				//	USES_CONVERSION; 
				//	strCustomCode=A2W(chResult);
					strCustomCode=chResult;	
				}

				sprintf(cCustName,  "CustomName%d",i );
				chResult = m_fIni.Read(cCustName);
				if ( chResult && strlen(chResult) )
				{
				//	strCustName.GetBuffer(MAX_LEN);
				//	USES_CONVERSION; 
				//	strCustName=A2W(chResult);
					strCustName=chResult;	
				}
				
		
				
				sprintf(cCustomPhone,  "CustomPhone%d",i );
				chResult = m_fIni.Read(cCustomPhone);
				if ( chResult && strlen(chResult) )
				{
					strCustomPhone=chResult;	
				}
		
				sprintf(cLongitude,  "Longitude%d",i );
				chResult = m_fIni.Read(cLongitude);
				if ( chResult && strlen(chResult) )
				{
					dLongitude=atof(chResult);	
					strLongitude=chResult;
				}
				sprintf(cLatitude,  "Latitude%d",i );
				chResult = m_fIni.Read(cLatitude);
				if ( chResult && strlen(chResult) )
				{
					dLatitude=atof(chResult);
					strLatitude=chResult;
				}
				
				m_List.InsertItem(i-1,strID);//名称
 				m_List.SetItemText(i-1,1,strAddress);//x坐标			
 				m_List.SetItemText(i-1,2,strCustName);//y坐标
				m_List.SetItemText(i-1,3,strCustomCode);//y坐标
				m_List.SetItemText(i-1,4,strCustomPhone);//y坐标
				m_List.SetItemText(i-1,5,strLongitude);//y坐标
				m_List.SetItemText(i-1,6,strLatitude);//y坐标

		}
			
// ID1=1
// Address1=科技圆
// CustomCode1=56898946554
// CustomName1=李小二
// CustomPhone1=13838213635
// Longitude1=114.26
// Latitude1=23.11

// 			chResult = NULL;  
// 			chResult = m_fIniStyle.Read("HTTPSERVER");
// 			memset( g_snStyle.cHTTPServer, 0, POI_NAME_MAX_LEN );
// 			if ( chResult &&  strlen(chResult) )
// 			{
// 				memcpy( g_snStyle.cHTTPServer, chResult, strlen(chResult) );
// 			}
		}
// 		CFile cfile;
// 		CFileException e;
// 		TCHAR* pFileName =strRouteFile.GetBuffer(strRouteFile.GetLength()+1);
//     	char pbuf[1024];
// 		if( cfile.Open( pFileName, CFile::modeRead, &e ) )
// 		  {
// 		UINT nBytesRead = cfile.Read( pbuf, 1024 );
// 	
// 		  }
// 	AfxMessageBox(strAddress);
// 					char cAddr[MAX_LEN] ;
// 					memset( cAddr, 0, MAX_LEN );
// 					if ( chResult &&  strlen(chResult) )
// 					{
// 						memcpy(cAddr, chResult, strlen(chResult) );
// 						strAddress=cAddr;
// 					}
// 	
// 	
// 		LPTSTR ptrName = NULL;
// 		if(!ptrName)
// 		{
// 			ptrName = new TCHAR[1024];
// 		}	
// 
// 		DWORD dwMinSize;
// 		dwMinSize = MultiByteToWideChar(CP_ACP, 0,pbuf, -1, NULL, 0);
// 		MultiByteToWideChar (CP_ACP, 0, pbuf, -1, ptrName, dwMinSize);  
// 		////////////////////////////////////////
// 		ptrName=ANSI2Unicode(pbuf);
// 		
// 		CString strq;
// 		strq.GetBuffer(1024);
// 		strq=pbuf;
// 
// 		char		szRouteFile[MAX_PATH];
// 		strcpy(szRouteFile,GetAppPathW());
// 		strcat(szRouteFile,"\\routefile.ini");
// 		CString str=GetMyProfileString(_T("RouteInfo"),_T("Count"),_T("0"),strRouteFile);
// 
// 		char * cCount;
// 	//	cCount=	W2A(str);
// 		memset(cCount, 0,128);//这里的128如果改成256会出错,程序要关掉才能正常,浪费半个多小时
// 		WideCharToMultiByte( CP_ACP, 0, str, -1, cCount, 128, NULL, NULL);	
// 		AfxMessageBox(str);
// 		int count=atoi(cCount);
// 		for(int i=1;i<=count;i++)
// 		{
// 			CString strSelection;
// 			strSelection.Format(_T("RouteInfo%d"),i);
// 			CString strID=GetMyProfileString(strSelection,_T("ID"),_T(""),szRouteFile);
// 		}
	}
}
char *  CString2pChar(CString str)
{
	char * cCount;
	memset(cCount, 0,128);//这里的128如果改成256会出错,程序要关掉才能正常,浪费半个多小时
	WideCharToMultiByte( CP_ACP, 0, str, -1, cCount, 128, NULL, NULL);	
	return cCount;
}

CString CCaptureScreenDlg::GetMyProfileString(const CString strSection, const CString strEntry, const CString strDefault, const CString strIniPath)
{
    if(strSection == L"" || strEntry == L"" || strIniPath == L"")
          return strDefault;

	CFile IniFile;
    TRY
	{		
		CString strCombine;    
        if(! IniFile.Open(strIniPath, CFile::modeRead))  
            return strDefault;
   
        if(IniFile.GetLength() == 0)
        {
            IniFile.Close();
            return strDefault;
        }
	
        char pBuf[1024];
        if(IniFile.Read(pBuf, IniFile.GetLength()+1) != IniFile.GetLength())
        {
          //  delete[] pBuf;
            IniFile.Close();
            return strDefault;
        }
		
// 		LPTSTR ptrName = NULL;
// 		if(!ptrName)
// 		{
// 			ptrName = new TCHAR[IniFile.GetLength()+1];
// 		}	
// 
//         //pBuf[IniFile.GetLength() / 2] = NULL;
// 		DWORD dwMinSize;
// 		dwMinSize = MultiByteToWideChar(CP_ACP, 0,pBuf, -1, NULL, 0);
// 		MultiByteToWideChar (CP_ACP, 0, pBuf, -1, ptrName, dwMinSize);  
// 		////////////////////////////////////////

       // strCombine.GetBuffer(MAX_LEN);
        strCombine = pBuf;
      //  delete[] pBuf;
        
        int iIndex1, iIndex2, iIndex3, iIndexT;
        iIndex1 = strCombine.Find(L"[" + strSection + L"]\r\n");
        if(iIndex1 == -1)
        {
            IniFile.Close();
            return strDefault;
        }
        iIndexT = iIndex1 + 4 + strSection.GetLength();
        iIndex2 = strCombine.Find(strEntry + L"=", iIndexT);
        if(iIndex2 == -1)
        {
            IniFile.Close();
            return strDefault;
        }
        else
        {
            iIndex3 = strCombine.Find(L"\r\n", iIndex2 + 1);
            if(iIndex3 == -1)
            {
                IniFile.Close();
                return strDefault;
            }
            iIndexT = iIndex2 + 1 + strEntry.GetLength();
            IniFile.Close();
            return strCombine.Mid(iIndexT, iIndex3 - iIndexT);
        }
	
    }
    CATCH(CFileException, e)
    {	
    }
    END_CATCH  
		
    IniFile.Close();
    return strDefault;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -