Example #1
0
void CConfigPtz::OnChangeEditAddressRs485() 
{
	// TODO: If this is a RICHEDIT control, the control will not
	// send this notification unless you override the CDialog::OnInitDialog()
	// function and call CRichEditCtrl().SetEventMask()
	// with the ENM_CHANGE flag ORed into the mask.
	
	// TODO: Add your control notification handler code here
 	CString strTemp;
 	int iDeviceAddress;
 	
 	UpdateData();
 	m_editAddress485.GetWindowText(strTemp);
 	
 	iDeviceAddress = atoi(strTemp.GetBuffer(0));
 	// 云台地址范围为0-255
 	if (iDeviceAddress > 255)
 	{
 		CString strAddress;
 		strAddress.Format("%d", 255);
 		m_editAddress485.SetWindowText(strAddress);
 	}
 	if (iDeviceAddress < 0)
 	{
 		CString strAddress;
 		strAddress.Format("%d", 0);
 		m_editAddress485.SetWindowText(strAddress);
 	}
}
HRESULT CMsgContainerCAN::GetMessageName(STCANDATA& sCANMsg, CString& msgName, bool formatHexForId)
{
    if (IS_ERR_MESSAGE(sCANMsg.m_ucDataType))
    {
        GetErrorInfo(sCANMsg, msgName);
    }
    else
    {
        //Message Name
        std::string strName = "";
        IFrame* pouFrame = nullptr;
        ERRORCODE eResult = mBmNetwork->GetFrame(CAN, 0, sCANMsg.m_uDataInfo.m_sCANMsg.m_unMsgID, nullptr, &pouFrame);
        if (EC_SUCCESS == eResult && nullptr != pouFrame)
        {
            pouFrame->GetName(strName);
            msgName = strName.c_str();
        }
        else
        {
            if (formatHexForId == true)
            {
                msgName.Format("0x%X", sCANMsg.m_uDataInfo.m_sCANMsg.m_unMsgID);
            }
            else
            {
                msgName.Format("%d", sCANMsg.m_uDataInfo.m_sCANMsg.m_unMsgID);
            }
        }
    }
    return S_OK;
}
Example #3
0
CString CSourceODBC::SDBField::GetValueAsString()
{
    switch( ID_TYPE )
    {
    case LONG:
    {
        CString ret;
        ret.Format( _T("%d"), lValue );
        return ret;
    }

    case STRING:
        return  strValue;

    case TIME:
        return CString(timeValue.Format( _T("%d/%m/%Y") ));

    case DOUBLE:
    {
        CString ret;
        ret.Format( _T("%.2f"), dValue );
        return ret;
    }

    case DOUBLE4:
    {
        CString ret;
        ret.Format( _T("%.4f"), dValue );
        return ret;
    }
    }
    return _T("Неизвестный тип данных");
}
Example #4
0
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// Access:    public 
// Returns:   void
// Parameter: UINT nEditID
// Parameter: INT nPrecision:
// Comment(2015-6-3):
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// Access:    public 
// Returns:   void
// Parameter: UINT nEditID
// Parameter: INT nAdd:1表示+1(上按),-1表示减少1(下按)
// Parameter: INT nPrecision小数点个数,为0表示整数,1,表示形如:0.1; 2表示形如:0.2....
// Comment(2015-6-3):用于点击spin后修改edit文本
////////////////////////////////////////////////////////////////////////////////
void CSpinUtil::ChangeText( UINT nEditID,INT nAdd,  INT nPrecision /*= 0*/ )
{
	FLOAT fDelta = pow(10.0, -nPrecision);
	CString temp;
	m_pDlg->GetDlgItemText(nEditID, temp);
	if (0 == nPrecision)//整数
	{
		INT nCur = 0;
		if (_T("") != temp)
		{
			nCur = _ttoi(temp);
		}//eif
		nCur += -nAdd * fDelta;
		temp.Format(_T("%d"), nCur);
		m_pDlg->SetDlgItemText(nEditID, temp);
	}
	else
	{
		FLOAT fCur = 0;
		if (_T("") != temp)
		{
			fCur = _tstof(temp);
		}//eif
		fCur += -nAdd * fDelta;
		CString strFormat;
		strFormat.Format(_T("%%.%df"), nPrecision);
		temp.Format(strFormat, fCur);
		m_pDlg->SetDlgItemText(nEditID, temp);
	}//eif
}
// Should be changed to use locale settings
void CGridCellDateTime::SetTime(CTime time)
{
	m_cTime = time;

	if (DTS_TIMEFORMAT == m_dwStyle) 
	{
#ifdef _WIN32_WCE
		CString strTemp;
		strTemp.Format(_T("%02d:%02d:%02d"), 
			           m_cTime.GetHour(), m_cTime.GetMinute(), m_cTime.GetSecond());
		SetText(strTemp);
#else

//		SetText(m_cTime.Format(_T("%H:%M:%S")));
    	SetText(m_cTime.Format(_T("%X")));
#endif
	}
	else if (DTS_SHORTDATEFORMAT == m_dwStyle) 
	{
#ifdef _WIN32_WCE
		CString strTemp;
		strTemp.Format(_T("%02d/%02d/%02d"), 
			           m_cTime.GetMonth(), m_cTime.GetDay(), m_cTime.GetYear());
		SetText(strTemp);
#else
//		SetText(m_cTime.Format(("%d/%m/%Y")));
		SetText(m_cTime.Format(("%x")));
#endif
	}
}
Example #6
0
void DuoXuanDlg::showTest(int i)
{
	CString sql;
	sql.Format("select * from tb_test where subject='%s'and [id]=%d and leixing='%s'",subject,i,"多选题");
//	MessageBox(sql);
	ADOConn m_ado;
	_RecordsetPtr m_pRs;
	m_ado.OnInitADOConn();
	m_pRs=m_ado.GetRecordSet((_bstr_t)sql);
	while(!m_pRs->adoEOF)
	{
//	MessageBox(sql);
	question=(char *)(_bstr_t)m_pRs->GetCollect("question");
	answera=(char *)(_bstr_t)m_pRs->GetCollect("answera");
	answerb=(char *)(_bstr_t)m_pRs->GetCollect("answerb");	
	answerc=(char *)(_bstr_t)m_pRs->GetCollect("answerc");
	answerd=(char *)(_bstr_t)m_pRs->GetCollect("answerd");
	rightanswer=(char *)(_bstr_t)m_pRs->GetCollect("rightanswer");
//	MessageBox(i+" ."+answerc);
	CString str;
	str.Format("第%d题",i);
	GetDlgItem(IDC_STATIC2)->SetWindowText(str+question);
	GetDlgItem(IDC_CHECK1)->SetWindowText("A."+answera);
	GetDlgItem(IDC_CHECK2)->SetWindowText("B."+answerb);
	GetDlgItem(IDC_CHECK3)->SetWindowText("C."+answerc);
	GetDlgItem(IDC_CHECK4)->SetWindowText("D."+answerd);
	m_pRs->MoveNext();
	}
	clearAnswer();
	m_ado.ExitConn();
}
Example #7
0
void CDlgArmLogICImage::UpdataFolderStatus()
{
	// Get the folder name
	m_Folder.RemoveAll();

	CString csFilePath = _T("");
	csFilePath = m.FilePath.ArmLogICImagePath;
	CFileFind finder;											//建立搜尋用的CFileFind物件
	BOOL bResult = finder.FindFile( csFilePath  + "*.*" );		//尋找第一個檔案
	while(bResult)
	{
		bResult = finder.FindNextFile();						//尋找下一個檔案
		if(!finder.IsDots() && finder.IsDirectory())
		{
			CString csFileDirectory = _T("");
			csFileDirectory.Format("%s", finder.GetFileTitle() );
			
			m_Folder.Add( csFileDirectory );
		}
	}
	
	m_listFolderStatus.ResetContent();
	int iSize = m_Folder.GetSize();
	for(int i=0;i<iSize;i++)
	{
		CString csFolderName = _T("");
		csFolderName = m_Folder.GetAt(i);
		m_listFolderStatus.AddString( csFolderName );
	}
	CString csFolderCounter = _T("");
	csFolderCounter.Format("Folder Counter: %d", iSize );
	m_wndlistFolderCounter.SetWindowText( csFolderCounter );
}
void CFilterBlacklist::SaveToRegistry(CRegKey& regkey) const
{
    // delete old values
    TCHAR strValName[MAX_PATH];
    DWORD strValNameLength = MAX_PATH;
    while(ERROR_SUCCESS == RegEnumValue(regkey, 0, strValName, &strValNameLength, NULL, NULL, NULL, NULL))
        regkey.DeleteValue(strValName);

    // write new values
    CString valName;
    int nFilterCount = 0;
    SSIZE_T nCount = m_aBlacklist.GetSize();
	for (SSIZE_T i = 0; i < nCount; ++i)
	{
        if (!IsEqualCLSID(m_aBlacklist[i].get_CLSID(), CLSID_NULL))
        {
            valName.Format(_T("clsid_%d"), nFilterCount);

            LPOLESTR strClsid = NULL;
            StringFromCLSID(m_aBlacklist[i].get_CLSID(), &strClsid);
            CString val(strClsid);
            regkey.SetStringValue(valName, val);
            if (strClsid) CoTaskMemFree(strClsid);
            nFilterCount++;
        }
        else if(!m_aBlacklist[i].get_Wildcard().IsEmpty())
        {
            valName.Format(_T("wildcard_%d"), nFilterCount);

            regkey.SetStringValue(valName, m_aBlacklist[i].get_Wildcard());
            nFilterCount++;
        }
	}
}
void CDialogEpsGraph::InitChartROE()
{
	int nYear0 = m_pCompany->GetYear()-9;
	double x[11], y[11];
	for(int i=0; i<=10; i++)
	{
		x[i] = nYear0 + i;
		y[i] = m_pCompany->GetROE(ROCEPS_HYTORY_SIZE - 11 + i);
	}

	m_pGraph->AddSeries("ROE", x, y, 11, SERIES_TYPE_PT_LINE, 1, PS_SOLID, RGB(0,0,200));

	double rx[2], ry[2], slope, intercept, coeff;
	CMath::SimpleRegression(x,y,11, slope, intercept, coeff);
	
	rx[0] = x[0];
	rx[1] = x[10];
	ry[0] = slope*x[0]+intercept;
	ry[1] = slope*x[10]+intercept;
	
	CString sName;
	if(intercept > 0.0)
		sName.Format("y = %.3f*x + %.3f", slope, intercept);
	else
		sName.Format("y = %.3f*x - %.3f", slope, -intercept);

	m_pGraph->AddSeries(sName, rx, ry, 2, SERIES_TYPE_LINE, 1, PS_SOLID, RGB(200,0,0));

	m_pGraph->m_sLabelX = "Years";
	m_pGraph->m_sLabelY = "ROE %";

	CString sCoeff;
	sCoeff.Format("Regression Coefficient: %.3f", coeff);
	GetDlgItem(IDC_STATIC_FOOTER)->SetWindowText(sCoeff);	
}
Example #10
0
	void CGameDoc::OnWriteScoreFile(CString pszFileName, int mode){

		CStdioFile file; 
		CFileException e;
		CFileStatus status;
		
		if(mode != -1) pszFileName.Format(pszFileName+("_%d"), mode);

		if(CFile::GetStatus(pszFileName, status)){//파일이 존재하는 경우 읽어오기만함
			if(!(file.Open(pszFileName, CFile::modeReadWrite | CFile::shareDenyNone, &e))) { 
				TRACE( _T("Can't open file %s, error = %u\n"), pszFileName, e.m_cause );
				return;
			} 
		}else{//파일이 존재하지 않는다면 생성한다
			if(!(file.Open(pszFileName, CFile::modeCreate | CFile::modeReadWrite | CFile::shareDenyNone, &e))) { 
				TRACE( _T("Can't open file %s, error = %u\n"), pszFileName, e.m_cause );
				return;
			} 
		}

		file.SeekToEnd(); // 라인 끝으로 이동한다.

		CString time;
		time.Format(_T("%d:%d:%d:%d"),  m_nH, m_nM, m_nS, m_nTimeSet);

		file.WriteString(m_strName);
		file.WriteString(_T(","));
		file.WriteString(time);
		file.WriteString(_T("\n"));

		file.Close();	
	}
Example #11
0
void CMainFrame::OnFileOpen()
{
    CString filter;
    filter.LoadString(IDS_OPEN_FILE_FILTER);

    CFileDialog fileDlg(TRUE, 0, 0, OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY, filter, this, 0);
    if (fileDlg.DoModal() != IDOK)
        return;

    CString path = fileDlg.GetPathName();
    SHOWBMP_TRACE("path=%s", (const TCHAR*) path);

    CString err;
    if (_taccess_s(path, 4) != 0) {
        _TCHAR buf[BUF_SIZE];
        __tcserror_s(buf, (const _TCHAR*) 0);
        err.Format(_T("Cannot read file: %s\n%s (%d)"), path, buf, errno);
        MessageBox(err, _T("Error"), MB_ICONERROR | MB_OK);
        return;
    }

    if (!m_ClientView.LoadBmp(path)) {
        err.Format(_T("Cannot load bitmap: %s"), path);
        MessageBox(err, _T("Error"), MB_ICONERROR | MB_OK);
    }
}
Example #12
0
void CSelectUnitsDlg::OnCbnSelchangeComboBook()
{
	m_nSelectedBookID = m_cboBook.GetItemData(m_cboBook.GetCurSel());
	CString str;
	str.Format(_T("BOOKID=%d"), m_nSelectedBookID);
	m_rsBook.FindFirst(str);

	m_cboPartFrom.ResetContent();
	m_cboPartTo.ResetContent();
	CString strParts = m_rsBook.GetFieldValueAsString(_T("PARTS"));
	for(int curPos = 0;;){
		CString str = strParts.Tokenize(_T(" "), curPos);
		if(str.IsEmpty()) break;
		m_cboPartFrom.AddString(str);
		m_cboPartTo.AddString(str);
	}

	int nNumUnits = m_rsBook.GetFieldValueAsInt(_T("UNITSINBOOK"));
	str.Format(_T("(%d in all)"), nNumUnits);
	m_stcUnitInAllFrom.SetWindowText(str);
	m_stcUnitInAllTo.SetWindowText(str);
	m_spnUnitFrom.SetRange32(1, nNumUnits);
	m_spnUnitTo.SetRange32(1, nNumUnits);
	int nUnitFrom = m_rsBook.GetFieldValueAsInt(_T("UNITFROM"));
	int nPartFrom = m_rsBook.GetFieldValueAsInt(_T("PARTFROM"));
	int nUnitTo = m_rsBook.GetFieldValueAsInt(_T("UNITTO"));
	int nPartTo = m_rsBook.GetFieldValueAsInt(_T("PARTTO"));
	m_spnUnitFrom.SetPos32(nUnitFrom);
	m_cboPartFrom.SetCurSel(nPartFrom - 1);
	m_spnUnitTo.SetPos32(nUnitTo);
	m_cboPartTo.SetCurSel(nPartTo - 1);
	m_chkTo.SetCheck(nUnitFrom == nUnitTo && nPartFrom == nPartTo ? BST_UNCHECKED : BST_CHECKED);
	OnBnClickedCheckTo();
}
Example #13
0
void CEnterRoomGuide::InitGuideBrowser()
{
    Room_Get_Room_List roomList;
    g_RoomModule->m_pModuleManager->CallService(Room::SERVICE_ROOM_GET_ROOM_LIST, (param)&roomList);

    Hall::WebInterfaceUrl weburl;
    weburl.m_WebWithPara = false;
    weburl.m_WebInterfaceKeyName = SYSSET_INI_KEYNAME_ENTERROOM_GUIDE_RECROOM;
    g_RoomModule->m_pModuleManager->CallService(Hall::SERVICE_VALUE_HALL_GET_WEBINTERFACEURL, (param)&weburl);
    CString strRoomId, strUrl;
    strRoomId.Format(L"?roomid=");
    for (int i = 0; i < roomList.vecRoomList.size(); ++i)
    {
        CString roomId;
        if (i + 1 == roomList.vecRoomList.size())
        {
            roomId.Format(L"%u", roomList.vecRoomList[i]);
        } else
        {
            roomId.Format(L"%u,", roomList.vecRoomList[i]);
        }

        strRoomId.Append(roomId);
    }
    strUrl.Format(L"%s%s", weburl.m_WebInterfaceUrl.c_str(), strRoomId.GetBuffer());

    m_htmlRecommendRoom.SetUrl(std::wstring(strUrl.GetBuffer()), true);
    m_htmlRecommendRoom.UpdateURL();
}
Example #14
0
void CPIDCPDialog::updateGrid(std::vector<ControlPara> *PCMV)
{
	if (!PCMV)
		return;
	if (PCMV->size() == 0)
		return;
	int i, j, index = 0;
	CString text;
	for (i = 1; i < m_Grid.GetRowCount(); i++) {
		for (j = 1; j < m_Grid.GetColumnCount(); j++) {
			if ((*PCMV)[index].type == 'l') {
				text.Format("%ld", (*PCMV)[index].vl);
			} else if ((*PCMV)[index].type == 'b') {
				text.Format("%d", (*PCMV)[index].vb);
			} else if ((*PCMV)[index].type == 'f') {
				text.Format("%.4g", (*PCMV)[index].vf);
			}
			index++;
			m_Grid.SetItemText(i, j, text);
		}
	}
	m_Grid.Invalidate();
	
	UpdateData(FALSE);
}
Example #15
0
//050506
LRESULT CMapDlg::LoadNames(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
  CFileDialog dlg(TRUE, 0,0,0,"Biosemi *.cfg files\0*.cfg\0All Files (*.*)\0*.*");
  if (dlg.DoModal() == IDOK)
  {
    CString strFile = dlg.m_ofn.lpstrFile;
    CString str;
    char *pNames = m_pParMap->GetOrCreateNames();
    for(int i = 0; i < m_pParMap->m_nChans; i++)
    {
      str.Format("Chan%d",i+1);
      GetPrivateProfileString("Labels",str,"",pNames+i*8,7,strFile);
    }

    for(i = 0; i < 8; i++)
    {
      str.Format("Tou%d",i+1);
      GetPrivateProfileString("Labels",str,"",pNames+(i+256)*8,7,strFile);
    }
    m_Map.m_pChNames = pNames;

  }


  return 1;
}
//加入配方按钮的响应函数//
void CNewConfigGraChiDlg::OnBnClickedButton2()
{
    // TODO:  在此添加控件通知处理程序代码
    std::vector<int> vectSelItem;           //暂存LIST1内被选中条目的下标//
    int nNumOfList2Item;                    //目前List2内已有条目的数量//
    CString strItem;                        //列表框2的行号//
    for (int n = 0; n<m_vectList1.size(); n++)                        //获得所有被选中条目的下标//
    {
        if (m_list1.GetCheck(n))
        {
            vectSelItem.push_back(n);
            m_vectList2.push_back(m_vectList1[n]);
            nNumOfList2Item = m_list2.GetItemCount();                //list2内当前已有条目的数量//
            m_list2.InsertItem(nNumOfList2Item, _T(""));
            strItem.Format(_T("%d"), nNumOfList2Item + 1);
            m_list2.SetItemText(nNumOfList2Item, 1, strItem);
            m_list2.SetItemText(nNumOfList2Item, 2, m_vectList1[n].m_strParaName);
            m_list2.SetItemText(nNumOfList2Item, 4, m_vectList1[n].m_strUnit);
        }
    }
    for (int n = vectSelItem.size()-1; n >= 0; n--)
    {
        m_list1.DeleteItem(vectSelItem[n]);                           //从待选列表内删除//
        m_vectList1.erase(m_vectList1.begin() + vectSelItem[n]);      //从m_vectList1删除//
    }
    if (!vectSelItem.empty())                    //如果删除了某些条目,则重写列表框内显示的序号//
        for (int n = 0; n < m_list1.GetItemCount(); n++)
        {
            strItem.Format(_T("%d"), n + 1);
            m_list1.SetItemText(n, 1, strItem);
        }
}
/******************************************************************************
* ++
* Method name : CServerLogView::InsertLogFiletoListView(const vector<CLog*> &lstLog)
* Description : Function create data for listview
* Parameters : vector<CLog*> &lstLog
        
* Return values : NULL
*		
* --
*****************************************************************************/
void CServerLogView::InsertLogFiletoListView(const vector<CLog*> &lstLog)
{
	listctrl.DeleteAllItems();
	Invalidate(0);

	LVITEM lvi;
	CString lpszItem;
	int nCurrent = 0;
	int nSum = 0;

	// Get size of vector listlog
	int nSizeList = lstLog.size();
	for(int i = 0; i < nSizeList; i++)
	{
		CLog* pLog = lstLog[i];
		lvi.mask = LVIF_TEXT;
		int nType = lstLog[i]->GetType();


		// create number
		lpszItem.Format(_T("%d"), ++nCurrent);
		lvi.iItem = nCurrent;
		lvi.iSubItem = 0;
		lvi.pszText = (LPTSTR)(LPCTSTR)(lpszItem);
		listctrl.InsertItem(&lvi);
		// Get sender
		lpszItem.Format(_T("%s"), lstLog[i]->GetSender());
		lvi.pszText = (LPTSTR)(LPCTSTR)(lpszItem);
		listctrl.SetItemText(i + nSum, 1, lpszItem);
		// Get receiver
		lpszItem.Format(_T("%s"), lstLog[i]->GetReceiver());
		lvi.pszText = (LPTSTR)(LPCTSTR)(lpszItem);
		listctrl.SetItemText(i + nSum, 2, lpszItem);
		// Get content
		lpszItem.Format(_T("%s"), lstLog[i]->GetContent());
		lvi.pszText = (LPTSTR)(LPCTSTR)(lpszItem);
		listctrl.SetItemText(i + nSum, 3, lpszItem);
		// Get Datetime
		lpszItem.Format(_T("%s"), lstLog[i]->GetDateTime());
		lvi.pszText = (LPTSTR)(LPCTSTR)(lpszItem);
		listctrl.SetItemText(i + nSum, 4, lpszItem);

		m_ColorREF_Weather = this->m_Color_Weather.GetColor();
		m_ColorREF_Alarm   = this->m_Corlor_Alarm.GetColor();
		
		// create color for listview
		switch(nType)
		{
			case TYPE_ADMIN:
				listctrl.SetRowColor(m_ColorREF_Weather, i + nSum);
				break;
			case TYPE_ALARM:
				listctrl.SetRowColor(m_ColorREF_Alarm, i + nSum);
				break;
			default:
				break;
		};
	}
	nSum += nSizeList;
}
void CManageAccountDlg::OnBnClickedUseprivilegecheck()
{
	_ConnectionPtr m_pConTmp;
	m_pConTmp.CreateInstance("ADODB.Connection");
	m_pConTmp->Open(g_strDatabasefilepath.GetString(),"","",adModeUnknown);
	CString strSql;

	if(m_usePrivilegeCheck.GetCheck()==BST_UNCHECKED)
	{
		 strSql.Format(_T("update Userlogin set USE_PASSWORD = 0"));
	
	}
	else
	{
		 strSql.Format(_T("update Userlogin set USE_PASSWORD = -1"));
	
	}

	try
	{

	m_pConTmp->Execute(strSql.GetString(),NULL,adCmdText);
	if(m_pConTmp->State) 
		m_pConTmp->Close(); 
}
catch(_com_error *e)
{
	AfxMessageBox(e->ErrorMessage());

}
}
Example #19
0
void CZRegHelper::RegisterFileRelation(const wchar_t *ext,const wchar_t *appName,
		const wchar_t *appKey,const wchar_t *defaultIcon,const wchar_t * des)
{
	CString strTemp;
	HKEY hKey;
	int size_wchar =  sizeof(wchar_t);
	RegCreateKey(HKEY_CLASSES_ROOT,ext,&hKey);
	RegSetValue(hKey,L"",REG_SZ,appKey,wcslen(appKey) * size_wchar + 1);
	RegCloseKey(hKey);

	RegCreateKey(HKEY_CLASSES_ROOT,appKey,&hKey);
	RegSetValue(hKey,L"",REG_SZ,des,wcslen(des)*size_wchar + 1);
	RegCloseKey(hKey);

	//sprintf(strTemp,L"%s\\DefaultIcon",strAppKey);
	strTemp.Format(L"%s\\DefaultIcon",appKey);
	RegCreateKey(HKEY_CLASSES_ROOT,strTemp,&hKey);
	RegSetValue(hKey,L"",REG_SZ,defaultIcon,wcslen(defaultIcon)*size_wchar + 1);
	RegCloseKey(hKey);

	//sprintf(strTemp,L"%s\\Shell",strAppKey);
	strTemp.Format(L"%s\\Shell",appKey);
	RegCreateKey(HKEY_CLASSES_ROOT,strTemp,&hKey);
	RegSetValue(hKey,L"",REG_SZ,L"Open",wcslen(L"Open")+1);
	RegCloseKey(hKey);

	//sprintf(strTemp,L"%s\\Shell\\Open\\Command",strAppKey);
	strTemp.Format(L"%s\\Shell\\Open\\Command",appKey);
	RegCreateKey(HKEY_CLASSES_ROOT,strTemp,&hKey);
	//sprintf(strTemp,L"%s \"%%1\"",strAppName);
	strTemp.Format(L"%s \"%%1\"",appName);
	RegSetValue(hKey,L"",REG_SZ,strTemp,strTemp.GetLength()*size_wchar+1);
	RegCloseKey(hKey);
}
Example #20
0
BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
	CRect cr;
	GetClientRect(&cr);
	// TODO: 여기에 특수화된 코드를 추가 및/또는 기본 클래스를 호출합니다.
	if (!m_wndSplitter.CreateStatic(this, 1, 2))
	{
		CString errorStr;
		errorStr.Format(L"화면 분할 실패 - error : %d", GetLastError());
		::AfxMessageBox(errorStr, 0, 0);
		return false;
	}
	
	if (!m_wndSplitter.CreateView(0, 0, RUNTIME_CLASS(CPreCodeView), CSize(cr.Width() / 2, cr.Height()), pContext))
	{
		CString errorStr;
		errorStr.Format(L"리뷰 텍스트 창 생성 실패 - error : %d", GetLastError());
		::AfxMessageBox(errorStr, 0, 0);
		return false;
	}

	if (!m_wndSplitter.CreateView(0, 1, RUNTIME_CLASS(CCommentView), CSize(cr.Width() / 2, cr.Height()), pContext))
	{
		CString errorStr;
		errorStr.Format(L"소스코드 텍스트 창 생성 실패 - error : %d", GetLastError());
		::AfxMessageBox(errorStr, 0, 0);
		return false;
	}
	
	m_ptPreView = (CPreCodeView*)m_wndSplitter.GetPane(0, 0);
	m_ptCmtView = (CCommentView*)m_wndSplitter.GetPane(0, 1);

	return CFrameWnd::OnCreateClient(lpcs, pContext);
}
Example #21
0
void CGPS_Socket::CaptureOnThread()
{
    CString strLog;
    char *pData=NULL;
    while(1)
    {
        LISTITEMINFOEX *pItem = m_pDataList->FetchDataHeadItem();
        if(pItem==NULL)
        {
            Sleep(100);
            continue;
        }
        CString strTemp;
        strLog.Format(_T("%d"),pItem->dwFieldIndex);
        for(int i=0; i<pItem->nBufSizeUsedV0; i++)
        {
            if(pItem->pBufV0[i]==NULL)
                break;
            strTemp.Format(_T("%c"),pItem->pBufV0[i]);
            strLog+= strTemp;
        }
        OutputDebugString(strLog);
        pData = (char*)pItem->pBufV0;
        m_pDataList->AddItem2EmptyTail(pItem);
    }
}
Example #22
0
void CStructureDlg::OnEdit() 
{
	// get selected item
	int nIndex = m_FieldListCtrl.GetNextItem(-1, LVNI_ALL | LVNI_SELECTED); 
	if (nIndex == -1)
		return;

	CAddFieldDlg dlg(this);

	dlg.m_strTitle = _T("Edit Field");

	dlg.m_strName = m_FieldListCtrl.GetItemText(nIndex, 0);

	CString strText = _T("CDNLFM");
	dlg.m_nType = strText.Find(m_FieldListCtrl.GetItemText(nIndex, 1));
	dlg.m_nLength = _ttoi(m_FieldListCtrl.GetItemText(nIndex, 2));
	dlg.m_nDecimals = _ttoi(m_FieldListCtrl.GetItemText(nIndex, 3));

	if (dlg.DoModal() == IDOK)
	{
		// update field data
		m_FieldListCtrl.SetItemText(nIndex, 0, dlg.m_strName);

		const TCHAR * const szTypes[] = {_T("C"), _T("D"), _T("N"), _T("L"), _T("F"), _T("M")};
		m_FieldListCtrl.SetItemText(nIndex, 1, szTypes[dlg.m_nType]);

		strText.Format(_T("%d"), dlg.m_nLength);
		m_FieldListCtrl.SetItemText(nIndex, 2, strText);

		strText.Format(_T("%d"), dlg.m_nDecimals);
		m_FieldListCtrl.SetItemText(nIndex, 3, strText);
		
		m_bModified = TRUE;
	}
}
Example #23
0
void CHvLitenCMD_WriteTestLog(LPCSTR lpszIP,DWORD64 dwTime,DWORD trigerID)
{
	#ifdef OUT_DEBUG_LOG
	CTime testTime((dwTime)/1000);
	CString szTime = testTime.Format("%Y-%m-%d %H:%M:%S");
	CString ttTime;
	ttTime.Format("%s %d",szTime,(dwTime)%1000);
	CString szStr;
	szStr.Format("trigerID:%d ",trigerID);
	szStr+=szTime;

	CTime cTime = CTime::GetCurrentTime();
	char szCurTime[256] = {0};
	char   path[MAX_PATH];   
	GetCurrentDirectory(MAX_PATH,path); 
	CString szPath(path);
	szPath+="\\HvDeviceNewLog.txt";
	FILE* fp = fopen(szPath.GetBuffer(), "a+");
	szPath.ReleaseBuffer();
	if(fp)
	{
		sprintf(szCurTime, "%s  <%s>  ", cTime.Format("%Y-%m-%d %H:%M:%S"), lpszIP);
		fwrite(szCurTime, strlen(szCurTime), 1, fp);
		fwrite(szStr, strlen(szStr), 1, fp);
		fwrite("\n", 1, 1, fp);
		fclose(fp);
	}
	#endif
}
Example #24
0
bool BBVideoDlg::bSetCapture()
{
	CString strTime;
	CString sFile; 
	
	SYSTEMTIME sysTime;
	GetLocalTime(&sysTime);

	// YYYYMMDD_HHMMSS
	strTime.Format(_T("%04d-%02d-%02d-%02dh%02dm%02ds%03d"), sysTime.wYear, sysTime.wMonth, sysTime.wDay,
		sysTime.wHour, sysTime.wMinute, sysTime.wSecond, sysTime.wMilliseconds);
	
		
	CString mFile = m_dlg_control.m_file;
	mFile = mFile.Left(mFile.GetLength()-4); 
	sFile.Format("%s-%s", mFile, strTime);

	m_dlg_control.Pause(); //플레이 중지. 

	CString sConfigFile = sGetCurrentDir() + "\\config.ini";
	CString sCapturePath;
	TCHAR szSpecialPath[MAX_PATH] = {0};
	::SHGetSpecialFolderPath(NULL, szSpecialPath, CSIDL_MYDOCUMENTS, 0);
	sCapturePath = szSpecialPath;

	LPSTR read = (LPSTR)malloc( ( 21504 ) * sizeof( LPSTR) );
	::GetPrivateProfileString("CAPTURE_DIR","PATH",sCapturePath, read, 21504, sConfigFile);
	sCapturePath = read;	
	
	sCapturePath = sCapturePath +  "\\CAM_CAPTURE\\";

	if(!DirectoryExists(sCapturePath)){
		CreateDirectory(sCapturePath,NULL);
	}

	CString sFront = sCapturePath + sFile + "(Track1).bmp";
	if( !m_api.Command(DEC_CMD_DISP_CAPTURE, 0, (DWORD)(LPCSTR)sFront  ) )  //전방
	{
		MessageBox( "Snapshot failed 0", BB_WINDOWS_TEXT );
		return false;
	}
		
	CString sRear = sCapturePath + sFile + "(Track2).bmp";
	if( !m_api.Command(DEC_CMD_DISP_CAPTURE, 1, (DWORD)(LPCSTR)sRear ) ) //후방  
	{
		MessageBox( "Snapshot failed 1", BB_WINDOWS_TEXT );
		return false;
	}

	CString sMsg;
	sMsg.Format("%s 캡쳐 화면이 저장 되었습니다.\n저장된 폴더를 여시겠습니까?", sFront);
	
	if(MessageBox(sMsg, "캡쳐", MB_YESNO)== IDYES)
	{
		//폴더 열자.	
		ShellExecute(NULL, "explore", sCapturePath, NULL, NULL, SW_SHOWNORMAL);
	}
	
	return true;
}
Example #25
0
CString CSecureRule::ToGnucleusString() const
{
	CString strRule;

	if ( m_nType != srAddress ) return strRule;
	if ( m_nAction != srDeny ) return strRule;

	if ( *(DWORD*)m_nMask == 0xFFFFFFFF )
	{
		strRule.Format( L"%lu.%lu.%lu.%lu",
			m_nIP[0], m_nIP[1], m_nIP[2], m_nIP[3] );
	}
	else
	{
		BYTE nFrom[4] = {}, nTo[4] = {};

		for ( int nByte = 0; nByte < 4; nByte++ )
		{
			nFrom[ nByte ]	= m_nIP[ nByte ] & m_nMask[ nByte ];
			nTo[ nByte ]	= m_nIP[ nByte ] | ( ~m_nMask[ nByte ] );
		}

		strRule.Format( L"%lu.%lu.%lu.%lu-%lu.%lu.%lu.%lu",
			nFrom[0], nFrom[1], nFrom[2], nFrom[3],
			nTo[0], nTo[1], nTo[2], nTo[3] );
	}

	strRule += L':';
	strRule += m_sComment;
	strRule += L':';

	return strRule;
}
Example #26
0
void CHistoryCombo::SaveHistory()
{
    if (m_sSection.IsEmpty())
        return;

    //add the current item to the history
    CString sCurItem;
    GetWindowText(sCurItem);
    if (m_bTrim)
        sCurItem.Trim();
    if (!sCurItem.IsEmpty()&&(sCurItem.GetLength() < MAX_PATH))
        AddString(sCurItem, 0);
    //save history to registry/inifile
    int nMax = min(GetCount(), m_nMaxHistoryItems + 1);
    for (int n = 0; n < nMax; n++)
    {
        CString sKey;
        sKey.Format(L"%s\\%s%d", (LPCTSTR)m_sSection, (LPCTSTR)m_sKeyPrefix, n);
        CRegString regkey(sKey);
        regkey = m_arEntries.GetAt(n);
    }
    //remove items exceeding the max number of history items
    for (int n = nMax; ; n++)
    {
        CString sKey;
        sKey.Format(L"%s\\%s%d", (LPCTSTR)m_sSection, (LPCTSTR)m_sKeyPrefix, n);
        CRegString regkey = CRegString(sKey);
        CString sText = regkey;
        if (sText.IsEmpty())
            break;
        regkey.removeValue(); // remove entry
    }
}
Example #27
0
void Rectan::ViewProperties()
{
	CString str;
	CMainFrame *pMainWnd = CMainFrame::GetCMF();
	pMainWnd->RemoveProperties();
	pMainWnd->AddPropertiesCategory();
	pMainWnd->AddPropertiesPanel(_T("Coordinates"));

	//
	CMFCRibbonEdit* EditBox1 = new CMFCRibbonEdit(ID_INFO1, 50,_T("x1"), -1);
	str.Format(_T("%d"), m_x1);
	EditBox1->SetEditText(str);
	pMainWnd->Add(EditBox1, 0);

	CMFCRibbonEdit* EditBox2 = new CMFCRibbonEdit(ID_INFO2, 50,_T("y1"), -1);
	str.Format(_T("%d"), m_y1);
	EditBox2->SetEditText(str);
	pMainWnd->Add(EditBox2, 0);

	CMFCRibbonEdit* EditBox3 = new CMFCRibbonEdit(ID_INFO3, 50,_T("x2"), -1);
	str.Format(_T("%d"), m_x2);
	EditBox3->SetEditText(str);
	pMainWnd->Add(EditBox3, 0);

	CMFCRibbonEdit* EditBox4 = new CMFCRibbonEdit(ID_INFO4, 50,_T("y2"), -1);
	str.Format(_T("%d"), m_y2);
	EditBox4->SetEditText(str);
	pMainWnd->Add(EditBox4, 0);
}
Example #28
0
CString CScormSettings2::GetRepresentation()
{
#ifndef _UNICODE
   will not compile without _UNICODE;
#endif

   CString csFormat;
   csFormat += _T("%S;%S;%S;%d;%d;%d;%s;%s;%d;%d;");

   CString csCatalog = m_tszGnrlCeCatalog;
   MaskCharacters(csCatalog);
   CString csEntry = m_tszGnrlCeEntry;
   MaskCharacters(csEntry);

   CString csReturn;
   csReturn.Format(csFormat, szLanguage, szVersion, szStatus, bFulltextAsKeyword ? 1 : 0,
      bCost ? 1 : 0, bCopyright ? 1 : 0, csCatalog, csEntry, m_nPurposeIndex,
      SCORM_PURPOSE_ARRAY_SIZE); // as some sort of "version" identifier

   for (int i=0; i<SCORM_PURPOSE_ARRAY_SIZE; ++i)
   {
      CString csDescription = m_atszClsfDescription[i];
      MaskCharacters(csDescription);
      CString csKeyword = m_atszClsfKeyword[i];
      MaskCharacters(csKeyword);

      CString csAppend;
      csAppend.Format(_T("%s;%s;"), csDescription, csKeyword);

      csReturn += csAppend;
   }

   return csReturn;
}
// 关闭并结束线程
//************************************
// Method:    OnClose
// FullName:  CThreadManage::OnClose
// Access:    public 
// Returns:   void
// Qualifier:
// Parameter: void
//************************************
void CThreadManage::OnClose(void)
{
	int iResult = 0;
	CString str = _T("");

	m_oHeartBeatThread.OnClose();
	m_oADCDataRecThread.OnClose();
	iResult = WaitForSingleObject(m_oHeartBeatThread.m_hHeartBeatThreadClose, WaitForThreadCloseTime);
	if (iResult != WAIT_OBJECT_0)
	{
		str.Format(_T("心跳线程在%dms内未能正常结束!"), WaitForThreadCloseTime);
		AfxMessageBox(str);
	}

	iResult = WaitForSingleObject(m_oADCDataRecThread.m_hADCDataThreadClose, WaitForThreadCloseTime);
	if (iResult != WAIT_OBJECT_0)
	{
		str.Format(_T("ADC数据接收线程在%dms内未能正常结束!"), WaitForThreadCloseTime);
		AfxMessageBox(str);
	}
	
	m_oHeadFrameSocket.Close();
	m_oIPSetSocket.Close();
	m_oTailFrameSocket.Close();
	m_oTailTimeFrameSocket.Close();
	m_oSysTimeSocket.Close();
	m_oADCSetSocket.Close();
	m_oHeartBeatSocket.Close();
	m_oADCDataSocket.Close();
	m_oInstrumentList.OnClose();
}
Example #30
0
void CRecvM::updateListBox(CListCtrl &m_listCtrl, CString time)
{
	_RecordsetPtr m_pRecordset;
	m_pRecordset.CreateInstance(__uuidof(Recordset));
	try {

		memset(sql, 0, sizeof(sql));
		strcat_s(sql, "select * from RecvInfo where RecvDate=#");
		USES_CONVERSION;
		strcat_s(sql, T2A(time.GetBuffer()));
		strcat_s(sql, "#");
		m_pRecordset->Open(sql, m_pConnection.GetInterfacePtr(), adOpenDynamic, adLockOptimistic, adCmdText);
	} catch(_com_error *e) {
		CString errormessage;
		errormessage.Format(_T("操作数据库失败!\r\n错误信息:%s"), e->ErrorMessage());
		AfxMessageBox(errormessage);
		return;
	}

	showBox.DeleteAllItems();
	  
	try {
		if (!m_pRecordset->BOF)
			m_pRecordset->MoveFirst();
		else {
			return;
		}

		int i = 0;
		while (!m_pRecordset->adoEOF) {
			_variant_t var1, var2, var3, var4, var5, var6, var7;
			var1 = m_pRecordset->GetCollect("ID");
			var2 = m_pRecordset->GetCollect("CorpName");
			var3 = m_pRecordset->GetCollect("RecvDate");
			var4 = m_pRecordset->GetCollect("WaybillNum");
			var5 = m_pRecordset->GetCollect("Consignee");
			var6 = m_pRecordset->GetCollect("Receiver");
			var7 = m_pRecordset->GetCollect("Remark");

			CString p;

			p.Format(_T("%d"), var1.intVal);
			
			showBox.InsertItem(i, p);
			showBox.SetItemText(i, 1, var2.bstrVal);
			showBox.SetItemText(i, 2, CString(var3));
			showBox.SetItemText(i, 3, var4.bstrVal);
			showBox.SetItemText(i, 4, var5.bstrVal);
			showBox.SetItemText(i, 5, var6.bstrVal);
			showBox.SetItemText(i, 6, var7.bstrVal);
			i++;
			m_pRecordset->MoveNext();
		}
		m_pRecordset->Close();
	} catch(_com_error *e) {
		CString errormessage;
		errormessage.Format(_T("数据库操作错误!\r\n错误信息:%s"), e->ErrorMessage());
		AfxMessageBox(errormessage);
	}
}