Example #1
0
Bool CCompiler::CopySourceCode( const CString& sourceCode )
{
    if( sourceCode.GetLenght() == 0 )
    {
        CL_ERROR("source code is empty");
        return false;
    }

    FileSystem::FileHandle targetFile = FileSystem::CreateFile( EFileType::E_FILE_TYPE_MEMORY );
    
    CString targetFilePath = GetSolutionCppFile();
    if( !CPath::FileExists(targetFilePath) )
    {
        CL_ERROR( "target file:[%s] does not exists", targetFilePath.GetBuffer() );
        return false;
    }

    if( !targetFile->Open( targetFilePath, EAccesMode::E_ACCES_MODE_WRITE ) )
    {
        CL_ERROR( "failed to open target file:[%s]", targetFilePath.GetBuffer() );
        return false;
    }

    if( !targetFile->Write( sourceCode.GetBuffer(), sourceCode.GetLenght(), 1 ) )
    {
        CL_ERROR("failed to write to target file:[%s]", targetFilePath.GetBuffer() );
        return false;
    }

    return true;
}
void ShowGridArea::showGridArea(CString title,CString name) {
	// TODO: 在此添加命令处理程序代码
	CString OpenFilter = title+_T(+"(*.tab)|*.tab;*.TAB|所有文件(*.*)|*.*||");
	CFileDialog FileDlgOpen(FALSE, NULL, NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, OpenFilter);
	FileDlgOpen.m_ofn.lpstrTitle=name.GetBuffer(0);
	if(IDOK == FileDlgOpen.DoModal())
	{
		CString FileName = FileDlgOpen.GetPathName();
		string fileNameString = FileName.GetBuffer(0);
		fileNameString.append(".mif"); 
		//将场强值和颜色进行对应的改变
		//create process
		openProcess();

		//中期数据展示,注释了下面一行
		SetGridColorTool::SetColor(TRUE,title.GetBuffer());
		//MessageBox(_T(",颜色信息已经转换成功!"),_T("通知"),MB_OK);
		//从数据库中取出网格的颜色信息进行展示
		MakeGridFileTool::makeGridFile(fileNameString);

		//在后面加上mif2tab
		Mif2Tab mif2Tab;
		CString path = FileDlgOpen.GetFolderPath();
		mif2Tab.Convert0(path,path);
		//close process
		closeProcess();

		//删除目录中的.mif .mid
		//string cmdLine = "cd " + path;
		//system(cmdLine.c_str());
		//cmdLine = "del *.mif *.mid";
		//system(cmdLine.c_str());
	//	MessageBox(NULL,_T(",已经完成导频污染的判断!"),_T("通知"),MB_OK);
	}
}
Example #3
0
BOOL CImage::Load(CString sFileName)
{
    Destroy();

    FILE* f = NULL;
    _TFOPEN_S(f, sFileName.GetBuffer(0), _T("rb"));
    if(f==NULL)
        return FALSE;
    if(IsBitmap(f))
    {
        fclose(f);
        return LoadBitmapFromBMPFile(sFileName.GetBuffer(0));
    }
    else if(IsPNG(f))
    {
        fclose(f);
        return LoadBitmapFromPNGFile(sFileName.GetBuffer(0));
    }
    else if(IsJPEG(f))
    {
        fclose(f);
        return LoadBitmapFromJPEGFile(sFileName.GetBuffer(0));
    }

    fclose(f);
    return FALSE;
}
Example #4
0
LRESULT CResendDlg::OnOtherActions(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
    CPoint pt;
    GetCursorPos(&pt);
    CMenu menu = LoadMenu(_Module.GetResourceInstance(), MAKEINTRESOURCE(IDR_POPUPMENU));  
    CMenu submenu = menu.GetSubMenu(3);

    strconv_t strconv;
    CString sRemindLater = Utility::GetINIString(
        g_CrashInfo.m_sLangFileName, _T("ResendDlg"), _T("PopupRemindLater"));
    CString sNeverRemind = Utility::GetINIString(
        g_CrashInfo.m_sLangFileName, _T("ResendDlg"), _T("PopupNeverRemind"));

    MENUITEMINFO mii;
    memset(&mii, 0, sizeof(MENUITEMINFO));
    mii.cbSize = sizeof(MENUITEMINFO);
    mii.fMask = MIIM_STRING;

    mii.dwTypeData = sRemindLater.GetBuffer(0);  
    submenu.SetMenuItemInfo(ID_MENU4_REMINDLATER, FALSE, &mii);

    mii.dwTypeData = sNeverRemind.GetBuffer(0);  
    submenu.SetMenuItemInfo(ID_MENU4_NEVERREMIND, FALSE, &mii);

    submenu.TrackPopupMenu(0, pt.x, pt.y, m_hWnd);
    return 0;
}
Example #5
0
void CEzShortcutDlg::OnBnClickedButtonEdit()
{
	int nCursel = m_listboxShortCutInfo.GetCurSel();
	if(nCursel < 0)
	{
		AfxMessageBox(_T("You are not select Shortcut."));
		return;
	}

	CString strShortCutName;
	m_listboxShortCutInfo.GetText(nCursel, strShortCutName);

	SHORTCUT_INFO* pShortCutInfo = GetShortCutInfo(strShortCutName.GetBuffer());
	if( NULL == pShortCutInfo)
	{
		AfxMessageBox(_T("Not find shortcut Information"));
		return;
	}

	if( false == OnEditShortcutDlg( *pShortCutInfo ) )
	{
		return;
	}

	if( _tcsicmp(strShortCutName.GetBuffer(), pShortCutInfo->m_strShortcutName.c_str()) != 0 )
	{
		AddShortCutInfo(*pShortCutInfo);
		RemoveShortCutInfo(strShortCutName.GetBuffer());
		RebuildShortcutList();
	}

	OnLbnSelchangeListShortcut();
	AutoSave();
}
Example #6
0
BOOL CAutoUpdate::isOpened(CString filepathname)
{
	if( !CMyUtility::fileExist(filepathname.GetBuffer()) )
	{
		return FALSE;
	}

	OFSTRUCT ofStruct;
	memset(&ofStruct, 0, sizeof(ofStruct));
	ofStruct.cBytes = sizeof(LPOFSTRUCT);

#ifdef UNICODE
	char chFile[MAX_PATH];
	int nPos = WideCharToMultiByte(CP_ACP,0,filepathname.GetBuffer(),filepathname.GetLength(),chFile,MAX_PATH,NULL,NULL);
	chFile[nPos] = '\0';
#else
	char *chFile = filepathname.GetBuffer();
#endif

	HFILE fret = ::OpenFile(chFile,&ofStruct,OF_SHARE_EXCLUSIVE);
	if(HFILE_ERROR != fret)
	{
		::CloseHandle((HANDLE)fret);
		return FALSE;
	}
	return TRUE;
}
Example #7
0
/*
*01: more than
*02: less than
*03: not more than
*04: not less than
*05: equal
*/
BOOL CAutoUpdate::AopB(CString A, CString op, CString B)
{
	BOOL bRet = TRUE;
	long a,b,iop;

	a  = _ttol(A.GetBuffer(0));
	b  = _ttol(B.GetBuffer(0));
	iop = _ttol(op.GetBuffer(0));
	
	switch(iop)
	{
	case 1:
		if (a<=b)
			bRet = FALSE;break;
	case 2:
		if (a>=b)
			bRet = FALSE;break;
	case 3:
		if (a>b)
			bRet = FALSE;break;
	case 4:
		if (a<b)
			bRet = FALSE;break;
	case 5:
		if (a!=b)
			bRet = FALSE;break;
	}

	return bRet;
}
Example #8
0
void CEntityDlg::OnCbnAnimationChange ()
{
	if ( !editEntity )
	{
		return;
	}

	int sel = cbAnimations.GetCurSel();
	CString animName;
	currentAnimation = NULL;
	int currFrame = 0;

	if ( sel != -1 ) {
		cbAnimations.GetLBText( sel , animName );
		if ( animName.GetLength() > 0 ) {
			//preserve the existing frame number
			currFrame = editEntity->epairs.GetInt ( "frame" , "1" );

			editEntity->epairs.Set("anim" , animName.GetBuffer(0));
			SetKeyValPairs(false/*don't update anims combo box :)*/ );

			//update the slider
			currentAnimation = gameEdit->ANIM_GetAnimFromEntityDef(editEntity->eclass->name , animName.GetBuffer(0));
			currentAnimationFrame = 0;

			if ( currentAnimation ) {
				slFrameSlider.SetRange( 1 , gameEdit->ANIM_GetNumFrames( currentAnimation ), TRUE );
				slFrameSlider.SetPos( currFrame );
				currentAnimationFrame = currFrame;
			}

			Sys_UpdateWindows(W_ALL);
		}
	}
}
// 29-Sep-2005 SFK	Added create pIFacCfgMgr, check if pIFacCfgMgr is NULL and
//					VariantInit of saStationRecord (VERY IMPORTANT TO DO THIS!!!!!!)
bool CFacCfgWrap::GetStationRecord(short sFacID, long lSta, struct db_sta_rec *pdbSta)
{
	VARIANT saStationRecord;
	VariantInit(&saStationRecord);

	// hardwire in station type string
	pIFacCfgMgr.CreateInstance(CLSID_FacilityMgrData);

	if (pIFacCfgMgr)
	{
		pIFacCfgMgr->GetStationRecord(sFacID, lSta, "binary", &saStationRecord);
		pIFacCfgMgr = NULL;
	}
	else
	{
		ASSERT(FALSE);
		VariantClear(&saStationRecord);
		return false;
	}

	if(saStationRecord.vt != VT_EMPTY)	
	{
		//Unload the information from the safearray.
		CString TempStr;

		SA_GetElem(saStationRecord.parray, 0, &(pdbSta->s_sta_num_key));

		SA_GetElem(saStationRecord.parray, 1, &(pdbSta->s_sta_picklist_num));

		SA_GetElem(saStationRecord.parray, 3, &TempStr);
		strncpy(pdbSta->sz_sta_name, TempStr.GetBuffer(MAX_NAME_LEN), MAX_NAME_LEN);
		pdbSta->sz_sta_name[MAX_NAME_LEN] = '\0';
		
		// 10-Aug-2005 SFK  Correct to use short name
		SA_GetElem(saStationRecord.parray, 3, &TempStr);
		strncpy(pdbSta->sz_sta_short_name, TempStr.GetBuffer(MAX_SHRT_NAME_LEN), MAX_SHRT_NAME_LEN);
		pdbSta->sz_sta_short_name[MAX_SHRT_NAME_LEN] = '\0';

		//SA_GetElem(saStationRecord.parray, 2, &TempStr);
		SA_GetElem(saStationRecord.parray, 4, &TempStr); //DR 533 pjm 12/11/2007
		// hardwire in type string
		if (_stricmp(TempStr.GetBuffer(MAX_NAME_LEN), "binary") == 0) 
		{
			pdbSta->s_sta_type = BINARY_TYPE;
			pdbSta->s_data_type = 1;		// 1 is FLOAT_TYPE
		}
		else 
		{
			pdbSta->s_sta_type = 0;
			pdbSta->s_data_type = 0;
		}
	}
	else
	{
		VariantClear(&saStationRecord);
		return(false);
	}
	VariantClear(&saStationRecord);
	return(true);
}
Example #10
0
void KGIniListCtrl::OnDeltaposSpin(NMHDR *pNMHDR, LRESULT *pResult)
{
    LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
    USER_ITEM_DATA useData;
    CString szEditText = _T("");

    KG_PROCESS_ERROR(m_lpCurItem);

    m_lpCurItem->GetStructData(&useData, sizeof(useData));
    float fValue = 0.0f;

    if (useData.dwValueType == VALUE_FLOAT)
    {
        m_editEdit.GetWindowText(szEditText);
        fValue = (float)atof(szEditText.GetBuffer()) + pNMUpDown->iDelta / 100.0f;
        if (fValue >= useData.nMin  && fValue <= useData.nMax)
            szEditText.Format("%.2f", fValue);
        strncpy_s(
            useData.szPropertyValue, szEditText.GetBuffer(), sizeof(useData.szPropertyValue)
        );
        m_editEdit.SetWindowText(szEditText);
    }

    //m_lpCurItem->SetStructData(&useData);

Exit0:
    *pResult = 0;
}
Example #11
0
void CMailMsg::AddAttachment(CString sAttachment, CString sTitle)
{
    strconv_t strconv;
    LPCSTR lpszAttachment = strconv.t2a(sAttachment.GetBuffer(0));
    LPCSTR lpszTitle = strconv.t2a(sTitle.GetBuffer(0));
    m_attachments[lpszAttachment] = lpszTitle;  
}
Example #12
0
void CQueueListCtrl::Localize()
{
	CHeaderCtrl* pHeaderCtrl = GetHeaderCtrl();
	HDITEM hdi;
	hdi.mask = HDI_TEXT;

	if(pHeaderCtrl->GetItemCount() != 0) {
		CString strRes;

		strRes = GetResString(IDS_QL_USERNAME);
		hdi.pszText = strRes.GetBuffer();
		pHeaderCtrl->SetItem(0, &hdi);
		strRes.ReleaseBuffer();

		strRes = GetResString(IDS_FILE);
		hdi.pszText = strRes.GetBuffer();
		pHeaderCtrl->SetItem(1, &hdi);
		strRes.ReleaseBuffer();

		strRes = GetResString(IDS_FILEPRIO);
		hdi.pszText = strRes.GetBuffer();
		pHeaderCtrl->SetItem(2, &hdi);
		strRes.ReleaseBuffer();

		strRes = GetResString(IDS_QL_RATING);
		hdi.pszText = strRes.GetBuffer();
		pHeaderCtrl->SetItem(3, &hdi);
		strRes.ReleaseBuffer();

		strRes = GetResString(IDS_SCORE);
		hdi.pszText = strRes.GetBuffer();
		pHeaderCtrl->SetItem(4, &hdi);
		strRes.ReleaseBuffer();

		strRes = GetResString(IDS_ASKED);
		hdi.pszText = strRes.GetBuffer();
		pHeaderCtrl->SetItem(5, &hdi);
		strRes.ReleaseBuffer();

		strRes = GetResString(IDS_LASTSEEN);
		hdi.pszText = strRes.GetBuffer();
		pHeaderCtrl->SetItem(6, &hdi);
		strRes.ReleaseBuffer();

		strRes = GetResString(IDS_ENTERQUEUE);
		hdi.pszText = strRes.GetBuffer();
		pHeaderCtrl->SetItem(7, &hdi);
		strRes.ReleaseBuffer();

		strRes = GetResString(IDS_BANNED);
		hdi.pszText = strRes.GetBuffer();
		pHeaderCtrl->SetItem(8, &hdi);
		strRes.ReleaseBuffer();
		
		strRes = GetResString(IDS_UPSTATUS);
		hdi.pszText = strRes.GetBuffer();
		pHeaderCtrl->SetItem(9, &hdi);
		strRes.ReleaseBuffer();
	}
}
Example #13
0
void AssignSound()
{
  CString strBasePath = ValueForKey(g_qeglobals.d_project_entity, "basepath");
  AddSlash(strBasePath);
  CString strPath = strBasePath;
  strPath += "sound\\";

  CFileDialog dlgFile(TRUE, NULL, NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, "Sound files (*.wav,*.mp3)|*.wav;*.mp3||", g_pParentWnd);
  dlgFile.m_ofn.lpstrInitialDir = strPath;
  if (dlgFile.DoModal() == IDOK)
  {
	  SendMessage(hwndEnt[EntKeyField], WM_SETTEXT, 0, (LPARAM)"noise");	
    CString str = dlgFile.GetPathName().GetBuffer(0);
    str.MakeLower();
    strBasePath.MakeLower();
    QE_ConvertDOSToUnixName(str.GetBuffer(0), str.GetBuffer(0));
    QE_ConvertDOSToUnixName(strBasePath.GetBuffer(0), strBasePath.GetBuffer(0));
    int n = str.Find(strBasePath);
    if (n == 0)
    {
      str = str.Right(str.GetLength() - strBasePath.GetLength());
    }

	  SendMessage(hwndEnt[EntValueField], WM_SETTEXT, 0, (LPARAM)str.GetBuffer(0));	
    AddProp();
    g_pParentWnd->GetXYWnd()->SetFocus();
  }
}
Example #14
0
void CImagePack::OnBnClickedOk()
{
	int  iW,iH,iSpace;
	CString strTemp;
    m_MaxWEdit.GetWindowText(strTemp);
	iW=atoi(strTemp.GetBuffer());
	m_MaxHEdit.GetWindowText(strTemp);
	iH=atoi(strTemp.GetBuffer());
	m_SpaceEdit.GetWindowText(strTemp);
	iSpace=atoi(strTemp.GetBuffer());
	if(iW<=0||iH<=0){
		AfxMessageBox("最大宽高错误!",MB_OK|MB_ICONINFORMATION);
		return;
	}else if(iSpace<0){
		AfxMessageBox("空隙不能小于0!",MB_OK|MB_ICONINFORMATION);
		return;
	}
	

	
	CString strPath;
	GetDlgItem(IDC_FILEHOSTORY)->GetWindowText(strPath);
	if(strPath=="")
	{
		AfxMessageBox("没有找到路径!",MB_OK|MB_ICONINFORMATION);
		return;
	}
	m_BindCore.setFilePath(strPath);
	m_strPath = strPath;
	strPath+="\\";
	FindInAll(strPath.GetBuffer());

	m_BindCore.Init(iW,iH,iSpace);
	m_BindCore.Reset();
	for (int i=0;i<m_vecName.size();i++)
		m_BindCore.AddImage(strPath+m_vecName[i],m_vecName[i]);
    m_vecName.clear();
	
	CString filename;
	m_EditName.GetWindowText(filename);

	m_BindCore.enableUsedSame(((CButton*)GetDlgItem(IDC_SUBITEMUSE))->GetCheck());
	if(!m_BindCore.AutoBind(filename,((CButton*)GetDlgItem(IDC_OPTIMIZE))->GetCheck(),((CButton*)GetDlgItem(IDC_2MI))->GetCheck()))
		return;
	GetDlgItem(IDC_FILEHOSTORY)->GetWindowText(strPath);
	tagHistoryInfo info;
	info.nSpace = iSpace;
	info.nMaxWidth = iW;
	info.nMaxHeight = iH;
	info.strFilePath = strPath;
	info.strFileName = filename;
	info.nDataType = m_listType.GetCurSel();
	SaveConfig(info);
	m_strPath = strPath;
	DescribeBuild(filename);
	AfxMessageBox("创建成功!",MB_OK|MB_ICONINFORMATION);
	if(((CButton*)GetDlgItem(IDC_LUACORE))->GetCheck())
		luaProcess(filename);
}
Example #15
0
BOOL CSpecialApp::CleanKugooEx(CString strFileName, CString strTable)
{
	BOOL bRet = FALSE;
	CString strFileNameEx;
	CString strTableEx;
	strFileNameEx = strFileName;
	strTableEx = strTable;
	std::string szFileName;
	std::string szTable;
	szTable =UnicodeToUtf8(strTableEx.GetBuffer());
	strTableEx.ReleaseBuffer();
	szFileName = UnicodeToUtf8(strFileNameEx.GetBuffer());
	strFileNameEx.ReleaseBuffer();
	sqlite3* pDB = NULL;
	sqlite3_stmt* sspStart = NULL;
	char szSql[MAX_PATH] = {0};

	int nResult = sqlite3_open(szFileName.c_str(), &pDB);
	if (nResult != SQLITE_OK)
	{
		goto clean0;
	}
	if (szTable.empty())
		goto clean0;

	sprintf_s(szSql, "select * from %s", szTable.c_str());
	nResult = sqlite3_prepare(pDB, szSql, -1, &sspStart, 0);
	if (nResult != SQLITE_OK)
	{
		goto clean0;
	}

	nResult = sqlite3_step(sspStart);

	if(nResult == SQLITE_ROW)
	{
		CString strOutPut = strFileName;
		strOutPut += L"|";
		strOutPut += strTable;
		g_fnScanFile(g_pMain, 9010, strOutPut, 0, 0);
		bRet = TRUE;
	}
clean0:
	if (sspStart)
	{
		sqlite3_finalize(sspStart);
		sspStart = NULL;
	}

	if (pDB)
	{
		sqlite3_close(pDB);
		pDB = NULL;
	}  

	return bRet;
}
Example #16
0
BOOL DocRoot::SaveDocument(const char* pszPathName)
  {
  if (gs_Exec.Busy())
    {
    LogError("SysCAD", 0, "Must not be running");
    return False;
    }
  char Fn[512];
  CString TmpFn;
  if (pszPathName==NULL)
    {
    TmpFn=GetTitle();
    pszPathName = TmpFn.GetBuffer(0);
    }
  
  if (strpbrk(pszPathName, ":\\")==NULL)
    {
    strcpy(Fn, PrjFiles());
    strcat(Fn, pszPathName);
    }
  else
    strcpy(Fn, pszPathName);

  CString Ext;
  VERIFY(GetDocTemplate()->GetDocString(Ext, CDocTemplate::filterExt));
  pchar ext=Ext.GetBuffer(0);
  const int l=strlen(Fn);
  const int el=strlen(ext);
  if (l<=el)
    strcat(Fn, ext);
  else if (_stricmp(&Fn[l-el], ext)!=0)
    {
    if (Fn[l-el]=='.')
      Fn[l-el]=0; //"old" or "incorect" extension needs to be replaced
    strcat(Fn, ext);
    }

  FILE* pFile= fopen(Fn, "wt");
  flag b=(pFile!=NULL);

  if (b)
    b=WriteDocument(Fn, pFile);

  if (pFile) 
    fclose(pFile);
  if (b)
    {
    SetPathName(Fn);
    SetModifiedFlag(FALSE);
    gs_pCmd->Print("%s - Saved\n", Fn);
    }
  else
    {
    gs_pCmd->Print("%s - NOT SAVED\n", Fn);
    }
  return b;
  }
//处理服务器状态
// 返回false 代表不需要进一步处理
// 返回true  代表需要进一步处理
bool CCollectionData::LportState(TSSmartDocEx *pDocEx, TSSmartTask *pTask, 
								    TSCmdBuffer *pBuffer,unsigned char *ucRawData)
{
	CString strText = "";
	int nTotalNo;
	bool bFlag1,bFlag2;

	bFlag1 = false;
	bFlag2 = false;

	nTotalNo = ucRawData[2];

	//服务器有数据
	if( ucRawData[1] != 0x0a ) 
		bFlag1 = true; 
	
	for(int i=0;i<nTotalNo; i++ ) 
	{
		switch(ucRawData[3+i])
		{
		case 0x0a://端口无数据
			break;
		case 0x0b://终端注册号不符合
			strText.Format("端口%d注册号不符合", i+1);
			printf("!!!!设备%s,端口号%d注册号不符\n",pDocEx->pChildDoc[0]->m_szDeviceID, i+1);
			bFlag2 = false;
			break;
		case 0x0c://终端设备无响应
			break;
		case 0x0d://申请签到
			{
			printf("-----设备%sPort=%d申请签到\n", pDocEx->pChildDoc[0]->m_szDeviceID, i+1);			
			strText.Format("端口%d申请签到!", i+1);
			ReportLog(pDocEx->pChildDoc[0], pTask, RET_OK, "实时收数", strText.GetBuffer(0));

			CSingInServer  SingIn;
			SingIn.SignInProcess(pDocEx, pBuffer, i+1, pTask);
			bFlag2 = true;
			}
			break;
		case 0x0e://黑名单有效期过期
  	      printf("!!!!黑名单有效期过期\n");
    		break;
		case 0xFF://未接终端
			break;
		default://其他状态不考虑
			strText.Format("端口%d状态未定义!", i+1);
			ReportLog(pDocEx->pChildDoc[0], pTask, RET_SYSERROR, "实时收数", strText.GetBuffer(0));
			break;
		}
	}

	if(bFlag2 == true)
		return false;

	return bFlag1;
}
Example #18
0
BOOL CSkinBase::ExtractResource(UINT nID, LPCTSTR szType, CString& sTempFilePath, HINSTANCE hInst)
{
	if (!hInst)
		hInst = AfxFindResourceHandle(MAKEINTRESOURCE(nID), szType);
	
	if (!hInst)
		return FALSE;
	
	// compare time with that of module from which it was loaded
	CString sTempPath;
	CFileStatus fsRes, fsModule;
	CString sModulePath;
	::GetModuleFileName(hInst, sModulePath.GetBuffer(MAX_PATH + 1), MAX_PATH);
	sModulePath.ReleaseBuffer();
	
	if (!CFile::GetStatus(sModulePath, fsModule))
		return FALSE;
	
	// create temp filename
	::GetTempPath(MAX_PATH, sTempPath.GetBuffer(MAX_PATH));
	sTempPath.ReleaseBuffer();
	sTempFilePath.Format("%s%s_skin_%d.tmp", sTempPath, szType, nID);
	
	// see if the file has been created before
	if (!CFile::GetStatus(sTempFilePath, fsRes) || fsRes.m_mtime < fsModule.m_mtime)
	{
		// Load the resource into memory
		HRSRC hRes = FindResource(hInst, (LPCSTR)nID, szType);
		
		if (!hRes) 
		{
			TRACE("Couldn't find %s resource %d!\n", szType, nID);
			return FALSE;
		}
		
		DWORD len = SizeofResource(hInst, hRes);
		
		BYTE* lpRes = (BYTE*)LoadResource(hInst, hRes);
		ASSERT(lpRes);
		
		CFile file;
		
		if (file.Open(sTempFilePath, CFile::modeCreate | CFile::modeWrite))
		{
			file.Write(lpRes, len);
			file.Close();
			FreeResource((HANDLE)lpRes);
		}
		else
		{
			FreeResource((HANDLE)lpRes);
			return FALSE;
		}
	}
	
	return TRUE;
}
Example #19
0
STDMETHODIMP CLDAPQuery::pageQuery(
	/* [in] */ LONG connect_id,
	/* [in] */ BSTR basedn,
	/* [in] */ BSTR scope,
	/* [in] */ BSTR filter,
	/* [in] */ BSTR attributes,
	/* [in] */ ULONG total_results,
	/* [retval][out] */ LONG* results_id)
{
	m_errorCode = 0L;
	const int id = m_connections.FindKey(connect_id);
	if(id > -1)
	{
		ÑConnectInfo * const cinfo = m_connections.GetValueAt(id);

		const PLDAP ld = cinfo->ld();

		const ULONG no_limit = LDAP_NO_LIMIT;
		ULONG ulScope = LDAP_SCOPE_BASE;
		CString csScope = scope;
		csScope.MakeLower();
		if(csScope == _T("subtree"))
			ulScope = LDAP_SCOPE_SUBTREE;
		else if(csScope == _T("onelevel"))
			ulScope = LDAP_SCOPE_ONELEVEL;
		else if(csScope == _T("base"))
			ulScope = LDAP_SCOPE_BASE;

		CString csBaseDN = basedn;

		if(csBaseDN.IsEmpty() && (ulScope == LDAP_SCOPE_ONELEVEL || (!cinfo->canFindFromRoot() && ulScope == LDAP_SCOPE_SUBTREE)))
		{
			csBaseDN = cinfo->defaultNamingContext();
		}

		CSimpleArray<PTCHAR> attributesArr;
		PTCHAR nextAttributes = NULL;
		CString csArrs = attributes;
		PTCHAR attribute = _tcstok_s(csArrs.GetBuffer(), _T(","), &nextAttributes);
		while(attribute != NULL)
		{
			attributesArr.Add(attribute);
			attribute = _tcstok_s(NULL, _T(","), &nextAttributes);
		}
		csArrs.ReleaseBuffer();
		attributesArr.Add(NULL); // NULL-terminated array

		PLDAPSearch pPages = ldap_search_init_page(ld, csBaseDN.GetBuffer(), ulScope, CString(filter).GetBuffer(), attributesArr.GetData(), 0, NULL, NULL, no_limit, total_results, NULL);
		m_errorCode = LdapGetLastError();
		if(pPages)
		{
			*results_id = cinfo->addResult(pPages);
		}
	}
	return S_OK;
}
void YouTubeWebPageView::LoadVideo(const VideoInfo& info)
{
   m_bLoaded = false;

   ATLTRACE(_T("%08x: LoadVideo: \"%s\" (%s)\n"),
      m_hWnd,
      info.Name(),
      info.Address());

   m_iLastError = 0;

   CString cszHtml = GetHtmlTemplate();

   cszHtml.Replace(_T("{..$address..}"), info.Address());
   cszHtml.Replace(_T("{..$name..}"), info.Name());
   cszHtml.Replace(_T("\r\n"), _T("\n"));

   // generate temp name
   CString cszTempFolder;
   GetTempPath(MAX_PATH, cszTempFolder.GetBuffer(MAX_PATH));
   cszTempFolder.ReleaseBuffer();

   CString cszFilename;
   GetTempFileName(cszTempFolder, _T("YTP"), 0, cszFilename.GetBuffer(MAX_PATH));
   cszFilename.ReleaseBuffer();

   // write to temporary file
   {
      FILE* fd = NULL;
	  errno_t err = _tfopen_s(&fd, cszFilename, _T("wt"));
	  ATLVERIFY(err == 0 && fd != NULL);

      USES_CONVERSION;
      fprintf(fd, T2CA(cszHtml));
      fclose(fd);
   }

   // navigate to page
   CComPtr<IWebBrowser2> spWebBrowser2;
   HRESULT hr = GetWebBrowser2(spWebBrowser2);
   if (SUCCEEDED(hr))
   {
      CString cszURL = _T("file:///") + cszFilename;
      cszURL.Replace(_T("\\"), _T("/"));

      CComBSTR bstrURL = cszURL;

      CComVariant varFlags(static_cast<int>(navNoHistory | navNoWriteToCache));

      hr = spWebBrowser2->Navigate(bstrURL, &varFlags, NULL, NULL, NULL);
   }

   if (!m_cszHtmlFilename.IsEmpty())
      DeleteFile(m_cszHtmlFilename);
   m_cszHtmlFilename = cszFilename;
}
Example #21
0
Bool CCompiler::OnCompileFail( )
{
    CL_TRACE("Enter CCompiler::OnCompileFail");

    FileSystem::FileHandle compileLogFile = FileSystem::CreateFile(EFileType::E_FILE_TYPE_MEMORY);
    
    if( !compileLogFile->Open( m_compilerOutputFile, EAccesMode::E_ACCES_MODE_READ ) )
    {
        CL_ERROR( "failed to open file:[%s]", m_compilerOutputFile.GetBuffer() );
        return false;
    }

    u64 fileSize = compileLogFile->GetSize();
    CString fileContent;
    fileContent.Resize(fileSize);

    if( !compileLogFile->Read( fileContent.GetBuffer(), fileSize, 1 ) )
    {
        CL_ERROR( "failed to read file content for:[%s]" ,m_compilerOutputFile.GetBuffer() );
        return false;
    }

#define COMPILER_USE_FULL_DEVENV_OUTPUT

#if !defined(COMPILER_USE_FULL_DEVENV_OUTPUT)
    //replace CompilerDummy.cpp with our file
    CString slnCppFileName = GetSolutionCppFileRaw();
    CString sourceFileName = "CodSursa.cpp";

    CRegex regexReplace( slnCppFileName );
    fileContent = regexReplace.Replace( fileContent, sourceFileName);

    CL_TRACE("fileContent:\n[%s]\n=======================", fileContent.GetBuffer());
    //CL_ERROR("fileContent:\n[%s]\n=======================", fileContent.GetBuffer());

    const CString regexString = sourceFileName + "\\([0-9]+\\):.*error C[0-9]+:[^\n]*";
    CRegex errorRegex( regexString, true );
    CRegex::TCaptures errors;

    if( !errorRegex.Find( fileContent, errors ) )
    {
        CL_ERROR( "failed to find errors in file:[%s]",m_compilerOutputFile.GetBuffer() );
        return false;
    }

    for( u64 i=0; i<errors.GetSize(); i++ )
    {
        const CString& error = errors[i];
        m_compileErrors += error;
    }
#else
    m_compileErrors = fileContent;
#endif //COMPILER_USE_FULL_DEVENV_OUTPUT

    return true;    // The OnCompileFailed step succeeded;
}
Example #22
0
void AFXAPI DDX_FieldCBString(CDataExchange* pDX, int nIDC, CString& value,
                              CRecordset* pRecordset)
{
    ASSERT_VALID(pRecordset);

    HWND hWndCtrl = pDX->PrepareCtrl(nIDC);
    if (pDX->m_bSaveAndValidate)
    {
        // just get current edit item text (or drop list static)
        int nLen = ::GetWindowTextLength(hWndCtrl);
        if (nLen != -1)
        {
            CString strTemp;
            ::GetWindowText(hWndCtrl, strTemp.GetBuffer(nLen), nLen+1);
            strTemp.ReleaseBuffer();
            nLen = strTemp.GetLength();
            if (nLen > value.GetAllocLength())
                AfxFailMaxChars(pDX, value.GetAllocLength());
            // get known length
            ::GetWindowText(hWndCtrl, value.GetBuffer(0), nLen+1);
        }
        else
        {
            // for drop lists GetWindowTextLength does not work - assume
            //  preallocated length
            ::GetWindowText(hWndCtrl, value.GetBuffer(0), value.GetAllocLength()+1);
        }
        value.ReleaseBuffer();
        if (value.GetLength() == 0)
        {
            if (pRecordset->IsFieldNullable(&value))
                pRecordset->SetFieldNull(&value, TRUE);
        }
        else
        {
            pRecordset->SetFieldNull(&value, FALSE);
        }
    }
    else
    {
        if (!pRecordset->IsOpen() || pRecordset->IsFieldNull(&value))
        {
            SendMessage(hWndCtrl, CB_SETCURSEL, (WPARAM)-1, 0L);
        }
        else
        {
            // set current selection based on model string
            if (::SendMessage(hWndCtrl, CB_SELECTSTRING, (WPARAM)-1,
                              (LPARAM)(LPCTSTR)value) == CB_ERR)
            {
                // just set the edit text (will be ignored if DROPDOWNLIST)
                AfxSetWindowText(hWndCtrl, value);
            }
        }
    }
}
void CDlgFreeTrainList::OnNew() 
{
  static WORD InFeederUnitID = 0;
  static WORD OutFeederUnitID = 0;
  static float AverCurrent = 300;
  static float AverAngle = 30;
  static float CurrentChangeRate = (float)0.1;
  static WORD InContinuedSeconds = 30;
  static WORD ChangeContinuedSeconds = 5;
  static WORD OutContinuedSeconds = 30;
  static CString InCurrentChangeRateList;
  static CString OutCurrentChangeRateList;

  CDlgFreeTrain dlg;
  struct TagFreeTrainStruct *pFreeTrain = new TagFreeTrainStruct;
  pFreeTrain->InFeederUnitID = InFeederUnitID;
  pFreeTrain->OutFeederUnitID = OutFeederUnitID;
  pFreeTrain->AverCurrent = AverCurrent;
  pFreeTrain->AverAngle = AverAngle;
  pFreeTrain->CurrentChangeRate = CurrentChangeRate;
  pFreeTrain->InContinuedSeconds = InContinuedSeconds;
  pFreeTrain->ChangeContinuedSeconds = ChangeContinuedSeconds;
  pFreeTrain->OutContinuedSeconds = OutContinuedSeconds;
  strcpy(pFreeTrain->InCurrentChangeRateList,InCurrentChangeRateList.GetBuffer(0));
  strcpy(pFreeTrain->OutCurrentChangeRateList,OutCurrentChangeRateList.GetBuffer(0));
  pFreeTrain->StartupDelaySecond = g_StartupDelaySecond;
  dlg.m_pFreeTrain = pFreeTrain;
  if(dlg.DoModal()==IDOK)
  {
    InFeederUnitID = pFreeTrain->InFeederUnitID;
    OutFeederUnitID = pFreeTrain->OutFeederUnitID;
    AverCurrent = pFreeTrain->AverCurrent;
    AverAngle = pFreeTrain->AverAngle;
    CurrentChangeRate = pFreeTrain->CurrentChangeRate;

    InContinuedSeconds = pFreeTrain->InContinuedSeconds;
    ChangeContinuedSeconds = pFreeTrain->ChangeContinuedSeconds;
    OutContinuedSeconds = pFreeTrain->OutContinuedSeconds;
    InCurrentChangeRateList = pFreeTrain->InCurrentChangeRateList;
    OutCurrentChangeRateList = pFreeTrain->OutCurrentChangeRateList;
    g_StartupDelaySecond = pFreeTrain->StartupDelaySecond;

    pFreeTrain->InBeginTime = CTime::GetCurrentTime() + CTimeSpan(0,0,0,pFreeTrain->StartupDelaySecond);;
    pFreeTrain->InFinishTime = pFreeTrain->InBeginTime+CTimeSpan(0,0,0,pFreeTrain->InContinuedSeconds);
    pFreeTrain->ChangeBeginTime = pFreeTrain->InFinishTime;
    pFreeTrain->ChangeFinishTime = pFreeTrain->ChangeBeginTime+CTimeSpan(0,0,0,pFreeTrain->ChangeContinuedSeconds);
    pFreeTrain->OutBeginTime = pFreeTrain->ChangeFinishTime;
    pFreeTrain->OutFinishTime = pFreeTrain->OutBeginTime+CTimeSpan(0,0,0,pFreeTrain->OutContinuedSeconds);

    g_FreeTrainManageList.AddTail(pFreeTrain);
  
	  UpdateList();
    ::SelectListLastItem(m_ctlList);
  }
}
Example #24
0
void CWndStyleEditor::OnBnClickedStyleAdd()
{
	// TODO: Add your control notification handler code here
	CString str;
	m_StylesList.GetWindowText(str);
	SQRGUIStyleManager::GetInst()->AddStyle(utf16_to_utf8(str.GetBuffer()).c_str());

	CString path = L"..\\gui\\style\\" + str;
	_wmkdir(path.GetBuffer());
	RefreshList();
}
HANDLE CoreProcessLauncher::Launch( CString strAppPath, CString strCmdLine )
{
	PROCESS_INFORMATION proInfo = {0};
	STARTUPINFO startInfo = {0};
	BOOL bResult = ::CreateProcess(strAppPath.GetBuffer()
		, strCmdLine.GetBuffer(), NULL, NULL, TRUE
		, CREATE_BREAKAWAY_FROM_JOB
		, NULL, NULL, &startInfo, &proInfo);

	return proInfo.hProcess;
}
Example #26
0
void CAddLinksDlg::initNodes()
{
	const CString notFound=_T("");
	const CString sectionNode=_T("NodeInfo");
	CFileFind finder;
	CString configPath;
	CString valueStr;
	CString comboItemStr=_T("");
	bool isFound=finder.FindFile(_T(".\\*.ini"));
	while(isFound)
	{
		comboItemStr=_T("");
		isFound=finder.FindNextFile();
		configPath=_T(".\\")+finder.GetFileName();
		if(configPath.Find(_T("config["))<0)
		{
			continue;
		}
		::GetPrivateProfileString(sectionNode,_T("LinkType"),notFound,valueStr.GetBuffer(MAX_PATH),MAX_PATH,configPath);
		valueStr.ReleaseBuffer();
		if(valueStr!=notFound)
		{
			continue;
		}
		::GetPrivateProfileString(sectionNode,_T("DstNode"),notFound,valueStr.GetBuffer(MAX_PATH),MAX_PATH,configPath);
		valueStr.ReleaseBuffer();
		if(valueStr!=notFound)
		{
			continue;
		}
		::GetPrivateProfileString(sectionNode,_T("NodeID"),notFound,valueStr.GetBuffer(MAX_PATH),MAX_PATH,configPath);
		valueStr.ReleaseBuffer();
		comboItemStr+=_T("节点 ")+valueStr;
		::GetPrivateProfileString(sectionNode,_T("NodeType"),notFound,valueStr.GetBuffer(MAX_PATH),MAX_PATH,configPath);
		valueStr.ReleaseBuffer();
		comboItemStr+=_T("(")+valueStr+_T(")");

		m_ComboNode1.AddString(comboItemStr);
		m_ComboNode2.AddString(comboItemStr);
		//int intfMACHex=GetPrivateProfileInt(sectionNode,_T("IntfMAC"),0,configPath);
		//valueStr.Format(_T("%012X"),intfMACHex);
		////::GetPrivateProfileString(sectionNode,_T("IntfMac"),notFound,valueStr.GetBuffer(MAX_PATH),MAX_PATH,configPath);
		////valueStr.ReleaseBuffer();
		//m_ListNodes.SetItemText(count,2,valueStr);
	}
	if (m_ComboNode1.GetCount()==0)
	{
		m_ComboNode1.AddString(_T("无未配置节点"));
	}
	if (m_ComboNode2.GetCount()==0)
	{
		m_ComboNode2.AddString(_T("无未配置节点"));
	}
}
Example #27
0
void CMainDlg::AddUserInfoToCrashDescriptorXML(CString sEmail, CString sDesc)
{ 
  USES_CONVERSION;

  HZIP hz = CreateZip(m_sZipName, NULL);
  
  TStrStrMap::iterator cur = m_pUDFiles.begin();
  unsigned int i;
  for (i = 0; i < m_pUDFiles.size(); i++, cur++)
  {
    CString sFileName = cur->first.c_str();
    sFileName = sFileName.Mid(sFileName.ReverseFind('\\')+1);
    if(sFileName.CompareNoCase(_T("crashrpt.xml"))==0)
    {
      TiXmlDocument doc;
  
      bool bLoad = doc.LoadFile(cur->first.c_str());
      if(!bLoad)
        return;

      TiXmlNode* root = doc.FirstChild("CrashRpt");
      if(!root)
        return;

      // Write user e-mail

      TiXmlElement* email = new TiXmlElement("UserEmail");
      root->LinkEndChild(email);

      LPSTR lpszEmail = T2A(sEmail.GetBuffer(0));
      TiXmlText* email_text = new TiXmlText(lpszEmail);
      email->LinkEndChild(email_text);              

      // Write problem description

      TiXmlElement* desc = new TiXmlElement("ProblemDescription");
      root->LinkEndChild(desc);

      LPSTR lpszDesc = T2A(sDesc.GetBuffer(0));
      TiXmlText* desc_text = new TiXmlText(lpszDesc);
      desc->LinkEndChild(desc_text);              

      doc.SaveFile();      
    }

	LPTSTR lptszFilePath = A2T((char*)cur->first.c_str());
    ZRESULT zr = ZipAdd(hz, sFileName, lptszFilePath);
    ATLASSERT(zr==ZR_OK); 
	zr;
  }  

  CloseZip(hz);
}
Example #28
0
void KGIniListCtrl::OnBnClick()
{
    int nResult  = false;
    int nRetCode = false;

    USER_ITEM_DATA itemData;

    KG_PROCESS_ERROR(m_lpCurItem);
    m_lpCurItem->GetStructData(&itemData, sizeof(itemData));

    if (itemData.dwValueType == VALUE_FILE)
    {
        KG3DFileViewDialog fileDlg(
            true, _T(""),  _T(""), NULL,  _T(""), OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
            itemData.szFileFiter, this
        );
        if (fileDlg.DoModal() == IDOK)
        {
            CString strPath = fileDlg.GetPathName();
            char szName[MAX_PATH];
            g_GetFilePathFromFullPath(szName, strPath.GetBuffer());
            if (strPath.Find(g_szDefWorkDirectory) == -1)
                strncpy(szName, strPath.GetBuffer(), sizeof(szName));
            strncpy(
                itemData.szPropertyValue, szName,
                sizeof(itemData.szPropertyValue)
            );
            m_lpCurItem->SetStructData(&itemData);
            Update(m_lpCurItem, true);
        }
    }
    else if (itemData.dwValueType == VALUE_COLOR)
    {
        int nColor = atoi(itemData.szPropertyValue);
        CColorDialog colorDlg((COLORREF)nColor, 0, this);
        if (colorDlg.DoModal() == IDOK)
        {
            nColor = colorDlg.GetColor();
            itoa(nColor, itemData.szPropertyValue, 10);
            m_lpCurItem->SetStructData(&itemData);
            Update(m_lpCurItem, true);
        }

    }
    else
    {

    }

    nResult = true;
Exit0:
    return;
}
Example #29
0
SizeF GDIPluseExt::GetBounds(CString strText,CString strFont,INT nfontsize)
{
	StringFormat strformat;
	GraphicsPath path;

#ifdef _UNICODE


	FontFamily  fontFamily(strFont);
	path.AddString(strText,strText.GetLength(), &fontFamily, 
		FontStyleRegular, 
		(REAL)nfontsize,
		PointF(0,0), 
		&strformat );

#else

	//字符转换
	int font_len = strFont.GetLength();
	WCHAR* pfont_w = new WCHAR[font_len];
	MultiByteToWideChar(CP_ACP,0,strFont.GetBuffer(),-1,pfont_w,font_len);
	strFont.ReleaseBuffer();
	//字符转换
	int text_len = strText.GetLength();
	WCHAR* ptext_w = new WCHAR[text_len];
	MultiByteToWideChar(CP_ACP,0,strText.GetBuffer(),-1,ptext_w,text_len);
	strText.ReleaseBuffer();


	FontFamily  fontFamily(pfont_w);

	Font font(&fontFamily, (REAL)nfontsize, FontStyleRegular, UnitPixel);


	path.AddString(ptext_w,wcsnlen_s(ptext_w,text_len), &fontFamily, 
		font.GetStyle(),
		font.GetSize(),
		PointF(0,0), 
		&strformat );


	DEL_P(ptext_w);
	DEL_P(pfont_w);
#endif

	RectF rcBound;
	// 获取边界范围
	path.GetBounds(&rcBound);
	TRACE("Round_Size:%d\r\n",rcBound.Width);

	// 返回文本的宽高
	return SizeF(rcBound.Width,rcBound.Height);
}
Example #30
0
LRESULT CResendDlg::OnListRClick(int /*idCtrl*/, LPNMHDR /*pnmh*/, BOOL& /*bHandled*/)
{
	CPoint pt;
    GetCursorPos(&pt);
    CMenu menu = LoadMenu(_Module.GetResourceInstance(), MAKEINTRESOURCE(IDR_POPUPMENU));  
    CMenu submenu = menu.GetSubMenu(5);

    strconv_t strconv;
    CString sSelectAll = Utility::GetINIString(g_CrashInfo.m_sLangFileName, _T("ResendDlg"), _T("SelectAll"));
    CString sDeselectAll = Utility::GetINIString(g_CrashInfo.m_sLangFileName, _T("ResendDlg"), _T("DeselectAll"));
	CString sDeleteSelected = Utility::GetINIString(g_CrashInfo.m_sLangFileName, _T("ResendDlg"), _T("DeleteSelected"));
	CString sDeleteAll = Utility::GetINIString(g_CrashInfo.m_sLangFileName, _T("ResendDlg"), _T("DeleteAll"));

    MENUITEMINFO mii;
    memset(&mii, 0, sizeof(MENUITEMINFO));
    mii.cbSize = sizeof(MENUITEMINFO);
    mii.fMask = MIIM_STRING;

    mii.dwTypeData = sSelectAll.GetBuffer(0);  
    submenu.SetMenuItemInfo(ID_MENU6_SELECTALL, FALSE, &mii);

    mii.dwTypeData = sDeselectAll.GetBuffer(0);  
    submenu.SetMenuItemInfo(ID_MENU6_DESELECTALL, FALSE, &mii);

	mii.dwTypeData = sDeleteSelected.GetBuffer(0);  
    submenu.SetMenuItemInfo(ID_MENU6_DELETESELECTED, FALSE, &mii);

	mii.dwTypeData = sDeleteAll.GetBuffer(0);  
    submenu.SetMenuItemInfo(ID_MENU6_DELETEALL, FALSE, &mii);

	// Get count of checked list items
	int nItems = 0;
	int nChecked = 0;
	int i;
    for(i=0; i<m_listReports.GetItemCount(); i++)
    {
		nItems++;

		// If list item checked
		if(m_listReports.GetCheckState(i))
			nChecked++;
	}
	
	submenu.EnableMenuItem(ID_MENU6_SELECTALL, nItems>0?MF_ENABLED:MF_DISABLED);
	submenu.EnableMenuItem(ID_MENU6_DESELECTALL, nItems>0?MF_ENABLED:MF_DISABLED);	
	submenu.EnableMenuItem(ID_MENU6_DELETESELECTED, nChecked>0?MF_ENABLED:MF_DISABLED);
	submenu.EnableMenuItem(ID_MENU6_DELETEALL, nItems>0?MF_ENABLED:MF_DISABLED);

	submenu.TrackPopupMenu(0, pt.x, pt.y, m_hWnd);
    return 0;

	return 0;
}