本文整理汇总了C++中T2A函数的典型用法代码示例。如果您正苦于以下问题:C++ T2A函数的具体用法?C++ T2A怎么用?C++ T2A使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了T2A函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UpdateData
void CRecvM::OnBnClickedButton1()
{
UpdateData(TRUE);
CStringArray ss;
ss.Add(GetWndTextByCString(CmpyNameBox));
ss.Add(GetWndTextByCString(dateBox));
ss.Add(GetWndTextByCString(CourierNumBox));
ss.Add(GetWndTextByCString(CsgBox));
ss.Add(GetWndTextByCString(RecverBox));
ss.Add(GetWndTextByCString(remarkBox));
if (!(ss[0].GetLength() && ss[2].GetLength() && ss[3].GetLength() && ss[4].GetLength() && contain_box.GetItemCount()))
{
AfxMessageBox(_T("请填写完整信息!"));
return;
}
_RecordsetPtr m_pRecordset;
m_pRecordset.CreateInstance(__uuidof(Recordset));
try {
USES_CONVERSION;
memset(sql, 0, sizeof(sql));
strcat_s(sql, "insert into RecvInfo (CorpName, RecvDate, WaybillNum, Consignee, Receiver, Remark) values ('");
for (int i = 0; i < 5; i++)
{
strcat_s(sql, T2A(ss[i].GetBuffer())); strcat_s(sql, "','");
}
strcat_s(sql, T2A(ss[5].GetBuffer())); strcat_s(sql, "')");
AfxMessageBox(CString(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;
}
updateListBox(showBox, ss[1]);
UpdateData(FALSE);
USES_CONVERSION;
for (int i = 0; i < contain_box.GetItemCount(); i++)
{
InsertDetail(atoi(T2A(showBox.GetItemText(showBox.GetItemCount() - 1, 0).GetBuffer())), i);
}
contain_box.DeleteAllItems();
}
示例2: pEnumSrc
CTwainScanistor* CTwainSourceManager::OpenSource( LPCTSTR lpProductName )
{
if(State != DSMOpen || OpenDSM() != 1)
{
return 0;
}
if(!lpProductName || !(*lpProductName))
{
return 0;
}
std::auto_ptr<IEnumerator<TW_IDENTITY>> pEnumSrc(EnumSource());
if(pEnumSrc.get())
{
std::string productName = T2A(lpProductName);
while(pEnumSrc->MoveNext())
{
if(productName == pEnumSrc->Current().ProductName)
{
return OpenSource(pEnumSrc->Current());
}
}
}
return 0;
}
示例3: GetTopLevelFrame
void CBCGPMSOffice2007DemoView::OnFontname()
{
USES_CONVERSION;
CBCGPRibbonBar* pRibbon = ((CMainFrame*) GetTopLevelFrame ())->GetRibbonBar ();
ASSERT_VALID (pRibbon);
CBCGPRibbonFontComboBox* pFontCombo = DYNAMIC_DOWNCAST (
CBCGPRibbonFontComboBox, pRibbon->FindByID (ID_FONT_FONT));
if (pFontCombo == NULL)
{
return;
}
CCharFormat cf;
cf.szFaceName[0] = NULL;
cf.dwMask = CFM_FACE | CFM_CHARSET;
const CBCGPFontDesc* pDesc = pFontCombo->GetFontDesc ();
ASSERT_VALID (pDesc);
ASSERT(pDesc->m_strName.GetLength() < LF_FACESIZE);
#if _MSC_VER >= 1300
lstrcpyn(cf.szFaceName, pDesc->m_strName, LF_FACESIZE);
#else
lstrcpynA(cf.szFaceName,
T2A((LPTSTR) (LPCTSTR) pDesc->m_strName), LF_FACESIZE);
#endif
cf.bCharSet = pDesc->m_nCharSet;
cf.bPitchAndFamily = pDesc->m_nPitchAndFamily;
SetCharFormat (cf);
}
示例4: T2A
/**
* /remarks
*
* /retval - ERROR_SUCCESS (sequencer keeps going)
* - <anything else> (error code for build, sequencer stops)
*
* /details - failaction = ignore
* - return ERROR_SUCCESS
*
* - failaction = retry
* - retry MAX_RETRY_ATTEMPTS times, then return
* success || fail
*
* - failaction = quit
* - return error code directly
*
* /note - modules loaded here are freed when the sequence ends
*
*/
UINT CBldAction::ExecuteDll(void)
{
USES_CONVERSION;
CString sMsg;
UINT uiReturn = IDOK;
LPCSTR szFn = T2A(m_strEntryPoint);
HMODULE hDll = CBldActionDllManager::LoadDll(m_strScript);
if (hDll)
{
ACTION_DLL_RUN pfn = (ACTION_DLL_RUN)::GetProcAddress(hDll, szFn);
if (pfn)
{
uiReturn = pfn(static_cast<LPCTSTR>(m_strName));
sMsg.Format(L"action library: '%s' : attempt : %d",
m_strScript,
m_iRetryAttempts);
WriteToLog(sMsg);
}
}
sMsg.Format(L"return value : %d : %s",
uiReturn,
CRedHelperFn::GetErrorMsg(uiReturn));
WriteToLog(sMsg);
return uiReturn;
} //CBldAction::RunDll()
示例5: _T
//加载文字处理函数
void CRecognitionTextView::OnLoadcharacter()
{
// TODO: 在此添加命令处理程序代码
if (fileCount > 0)
{
static TCHAR BASED_CODE szFilter[] = _T("Map Files (*.dat)|*.dat||"); //进行文件过滤
CFileDialog fileDialog(TRUE,NULL,NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, szFilter, this);
if(fileDialog.DoModal() == IDOK){
CString datFileName;
datFileName = fileDialog.GetPathName();
MessageBox(datFileName);
USES_CONVERSION; //声明标识符
FILE *file = fopen(T2A(datFileName), "rb"); //调用函数库实现CString到const char*转换
if(!file)
{
printf("打开文件失败");
return;
}
for(int i = 0 ;i<7356;i++)
{
//读取字符
fread(words[i], 2, 1, file);
words[i][2] = '\0';
printf("%s\t",words[i]);
}
fclose(file);
}
}
else
{
MessageBox(_T("请先加载图片"));
}
}
示例6: T2A
PixRectArray::PixRectArray(const StringArray &fileNames, StringArray &errors) {
USES_CONVERSION;
m_updateCounter = 0;
for(size_t i = 0; i < fileNames.size(); i++) {
const String &name = fileNames[i];
try {
if(FileNameSplitter(name).getExtension().equalsIgnoreCase(_T(".gif"))) {
int error;
const char *namea = T2A(name.cstr());
GifFileType *gifFile = DGifOpenFileName(namea, &error);
if(gifFile == NULL) {
throwException(_T("%s"), GifErrorString(error));
}
if(DGifSlurp(gifFile) != GIF_OK) {
const String msg = GifErrorString(gifFile->Error);
DGifCloseFile(gifFile, &error);
throwException(_T("%s"), msg.cstr());
}
const int imageCount = gifFile->ImageCount;
for(int k = 0; k < imageCount; k++) {
add(new GifPixRect(gifFile, k));
}
DGifCloseFile(gifFile, &error);
} else {
add(GifPixRect::load(name));
}
} catch(Exception e) {
errors.add(e.what());
}
}
}
示例7: T2A
// Constructor.
DBGSERV_API TraceService::TraceService()
{
try
{
// Read the trace file name and the log enable/disabled flag from the registry.
DWORD dwTraceEnabled = Registry::RegGetDWORDValue(HKEY_CURRENT_USER, REG_TRACE_KEY_NAME, REG_TRACE_FLAG_VALUE_NAME);
m_bLogEnabled = (dwTraceEnabled != 0);
if (m_bLogEnabled)
{
String sLogFile = Registry::RegGetStringValue(HKEY_CURRENT_USER, REG_TRACE_KEY_NAME, REG_TRACE_FILE_NAME);
USES_CONVERSION;
m_sLogFile = T2A(const_cast<TCHAR*>(sLogFile.c_str())); // Log file is always ASCII.
}
}
catch (const RegistryException& regException)
{
#ifdef _DEBUG
::OutputDebugString(_T("Registry exception while initializing the trace system\n"));
::OutputDebugString(regException.ToString().c_str());
::OutputDebugString(_T("\n"));
#else
// Avoid "unreferenced local variable" warning.
regException;
#endif
// The traces are disabled by default.
m_bLogEnabled = FALSE;
}
// Alloc a thread local index.
m_dwTlsIndex = ::TlsAlloc();
}
示例8: SetMargins
void CActionsSampleView::OnInitialUpdate()
{
CRichEditView::OnInitialUpdate();
USES_CONVERSION;
// Set the printing margins (720 twips = 1/2 inch).
SetMargins(CRect(720, 720, 720, 720));
CHARFORMAT cf;
ZeroMemory(&cf, sizeof(CHARFORMAT));
CString strDefFont = _T("Tahoma");
cf.cbSize = sizeof(CHARFORMAT);
cf.dwMask = CFM_BOLD |CFM_ITALIC | CFM_UNDERLINE | CFM_STRIKEOUT | CFM_SIZE |
CFM_COLOR | CFM_OFFSET | CFM_PROTECTED | CFM_FACE;
cf.dwEffects = CFE_AUTOCOLOR;
cf.yHeight = 200; //10pt
cf.bPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE;
#if (_RICHEDIT_VER >= 0x0200)
lstrcpyn(cf.szFaceName, strDefFont, LF_FACESIZE);
#else
lstrcpynA(cf.szFaceName, T2A((LPTSTR) (LPCTSTR) strDefFont), LF_FACESIZE);
#endif
GetRichEditCtrl().SetDefaultCharFormat(cf);
}
示例9: memset
void AppLauncherDlg::OnChooseApp()
{
USES_CONVERSION;
TCHAR szPath[MAX_PATH + 1];
memset(szPath, 0, sizeof(szPath));
TCHAR *lpszFilter =
_T("EXE Files Only (*.exe)\0*.exe\0"
"All Files (*.*)\0*.*\0\0");
OPENFILENAME ofn;
memset(&ofn, 0, sizeof(ofn));
#if _WIN32_WINNT >= 0x0500
ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400;
#else
ofn.lStructSize = sizeof(ofn);
#endif
ofn.Flags = OFN_FILEMUSTEXIST;
ofn.lpstrFilter = lpszFilter;
ofn.lpstrDefExt = _T("exe");
ofn.lpstrFile = szPath;
ofn.nMaxFile = MAX_PATH;
if (GetOpenFileName(&ofn))
{
USES_CONVERSION;
mOpenWith = T2A(szPath);
SetDlgItemText(mHwndDlg, IDC_APPLICATION, szPath);
CheckRadioButton(mHwndDlg, IDC_OPENWITHAPP, IDC_SAVETOFILE, IDC_OPENWITHAPP);
}
}
示例10: strmatch
NiNodeRef Exporter::createNode(INode* maxNode, const string& name)
{
USES_CONVERSION;
bool ismatch = strmatch(T2A(maxNode->GetName()), name);
if (ismatch) {
NodeToNodeMap::iterator itr = mNodeMap.find(maxNode);
if (itr != mNodeMap.end())
return (*itr).second;
}
NiNodeRef node;
if (!findNode(name, node))
{
node = createNode();
BOOL noname = FALSE;
if (!maxNode->GetUserPropBool(NP_NONAME, noname) || !noname)
node->SetName(name);
}
if (wildmatch("noname*", name))
{
maxNode->SetUserPropBool(NP_NONAME, TRUE);
}
mNodeMap[maxNode] = node;
return node;
}
示例11: memset
STDMETHODIMP CoExtender::GetChannelSource( int iChannel, VCACONFIG_CHANNEL_SRC *pSrc)
{
// Tell them about the sources we support
USES_CONVERSION;
memset( pSrc, 0, sizeof( VCACONFIG_CHANNEL_SRC ) );
ASSERT( iChannel == 0 );
pSrc->iChannelId = 0;
if( m_bVideo )
{
// We provide video, so we tell them we'll stream through the IF
pSrc->videoSrcType = VCACONFIG_SRC_IF;
}
else
{
// We want them to provide the video...
switch( m_eVideoType )
{
case VIDEO_DSHOW: pSrc->videoSrcType = VCACONFIG_SRC_DSHOW; break;
case VIDEO_VLC: pSrc->videoSrcType = VCACONFIG_SRC_VLC; break;
default: pSrc->videoSrcType = VCACONFIG_SRC_NULL; break;
}
}
strcpy_s( pSrc->szVideoData, _countof( pSrc->szVideoData ), T2A(m_sVideoData.GetBuffer(0)) );
pSrc->fMediaTypeFlags = (m_bMeta & VCACONFIG_MEDIA_METADATA) | (m_bVideo & VCACONFIG_MEDIA_VIDEO); // Provides just meta
return S_OK;
}
示例12: WriteLog
void WriteLog(LPCTSTR pszLogFileName, LPCTSTR pszLog)
{
#ifdef _UNICODE
USES_CONVERSION;
#endif
HANDLE hLogFile = ::CreateFile(pszLogFileName, GENERIC_WRITE, FILE_SHARE_WRITE, nullptr, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr);
if(hLogFile != INVALID_HANDLE_VALUE)
::SetFilePointer(hLogFile, 0, 0, FILE_END);
else
return;
DWORD dwSize;
SYSTEMTIME st;
GetLocalTime(&st);
CString strLog;
strLog.Format(_T("[%02d-%02d %02d:%02d:%02d.%03d] %s\r\n"), st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond, st.wMilliseconds, pszLog);
#ifdef _UNICODE
LPSTR lpszLog = T2A((LPTSTR)(LPCTSTR)strLog);
::WriteFile(hLogFile, lpszLog, (DWORD)::strlen(lpszLog), &dwSize, nullptr);
#else
::WriteFile(hLogFile, strLog, strLog.GetLength(), &dwSize, nullptr);
#endif
::CloseHandle(hLogFile);
}
示例13: setup_paths
void setup_paths()
{
TCHAR rootpath_buffer[MAX_PATH];
char *rootpath;
get_mame_root(rootpath_buffer, sizeof(rootpath_buffer) / sizeof(rootpath_buffer[0]));
rootpath = (char *) T2A(rootpath_buffer);
#ifdef MESS
set_fileio_opt(rootpath, "biospath", "\\Bios");
set_fileio_opt(rootpath, "cheat_file", "\\cheat.cdb");
set_fileio_opt(rootpath, "softwarepath", "\\Software");
#else
set_fileio_opt(rootpath, "rompath", "\\ROMs");
set_fileio_opt(rootpath, "cheat_file", "\\cheat.dat");
#endif
set_fileio_opt(rootpath, "inipath", "\\Ini");
set_fileio_opt(rootpath, "samplepath", "\\Samples");
set_fileio_opt(rootpath, "cfg_directory", "\\Cfg");
set_fileio_opt(rootpath, "nvram_directory", "\\Nvram");
set_fileio_opt(rootpath, "memcard_directory", "\\Memcard");
set_fileio_opt(rootpath, "input_directory", "\\Inp");
set_fileio_opt(rootpath, "hiscore_directory", "\\Hi");
set_fileio_opt(rootpath, "artwork_directory", "\\Artwork");
set_fileio_opt(rootpath, "snapshot_directory", "\\Snap");
set_fileio_opt(rootpath, "history_file", "\\history.dat");
set_fileio_opt(rootpath, "mameinfo_file", "\\mameinfo.dat");
}
示例14: throwSqlError
void TableInfo::put(RecordType &rec, UINT n, const String &v) const {
if(v.length() > m_columns[n].getMaxStringLen()) {
throwSqlError(SQL_STRING_TOO_LONG,_T("%s:String too long to fit in keyfield[%d]. len=%d. maxlen=%d")
,__TFUNCTION__,n,(UINT)v.length(),m_columns[n].getMaxStringLen());
}
USES_CONVERSION;
switch(getColumn(n).getType()) {
case DBTYPE_CSTRING :
case DBTYPE_CSTRINGN :
{ char tmp[MAXRECSIZE+1];
memset(tmp,0,sizeof(tmp));
strcpy(tmp,T2A((TCHAR*)v.cstr()));
putBytes(rec,n,tmp);
}
break;
case DBTYPE_WSTRING :
case DBTYPE_WSTRINGN :
{ wchar_t tmp[MAXRECSIZE+1];
memset(tmp,0,sizeof(tmp));
wcscpy(tmp,T2W((TCHAR*)v.cstr()));
putBytes(rec,n,tmp);
}
break;
default: THROWFIELDNOTSTRING(n);
}
}
示例15: memset
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);
}
}