bool FileMisc::LoadFile(const TCHAR* szPathname, CString& sText) { CStdioFile file; if (file.Open(szPathname, CFile::modeRead | CFile::shareDenyWrite)) { if (file.GetLength()) { // init size CString sTemp(_T('\0'), (int)file.GetLength()); sText = sTemp; CString sLine; int nPos = 0; while (file.ReadString(sLine)) { sText.Insert(nPos, sLine); nPos += sLine.GetLength(); } } return true; } return false; }
int Address::reverseLookup( int iLookupFlags, AWE::Core::String* pHostname, AWE::uint16* pPort ) const { if ( m_pAddrInfo == 0 ) { AWE_THROW( AddressException, "Address not resolved" ); } char pAddressStr[ NI_MAXHOST ]; char pPortStr[ NI_MAXSERV ]; memset( pAddressStr, 0, NI_MAXHOST ); memset( pPortStr, 0, NI_MAXSERV ); // http://www.breakingrobots.net/blog/2005/09/13.html // http://msdn.microsoft.com/en-us/library/ms738532(VS.85).aspx // Setting the NI_NUMERICHOST flag returns the numeric form of the host name instead // of its name, a reverse DNS lookup. The numeric form of the host name is also // returned if the host name cannot be resolved by DNS. // // Setting the NI_NUMERICSERV flag returns the port number of the service instead // of its name. Also, if a host name is not found for an IP address (127.0.0.2, for // example), the hostname is returned as the IP address. int iResult( ::getnameinfo( m_pAddrInfo->ai_addr, static_cast< socklen_t >( m_pAddrInfo->ai_addrlen ), pAddressStr, NI_MAXHOST, pPortStr, NI_MAXSERV, iLookupFlags // the flags ) ); if ( iResult != 0 ) { return iResult; } if ( pHostname != 0 ) { *pHostname = pAddressStr; } if ( pPort != 0 ) { AWE::Core::String sTemp( pPortStr ); AWE::Core::TypeConversion::fromString< AWE::uint16 >( sTemp, *pPort, std::ios_base::dec ); } return iResult; }
HTREEITEM CFileAndFolder::InsertFileItem(const CString& sFile, const CString& sPath, HTREEITEM hParent) { //Retreive the icon indexes for the specified file/folder int nIconIndex = GetIconIndex(sPath); int nSelIconIndex = GetSelIconIndex(sPath); if (nIconIndex == -1 || nSelIconIndex == -1) { TRACE(_T("Failed in call to SHGetFileInfo for %s, GetLastError:%d\n"), sPath, ::GetLastError()); return NULL; } //Add the actual item CString sTemp(sFile); TV_INSERTSTRUCT tvis; ZeroMemory(&tvis, sizeof(TV_INSERTSTRUCT)); tvis.hParent = hParent; tvis.hInsertAfter = TVI_LAST; tvis.item.mask = TVIF_CHILDREN | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_TEXT; tvis.item.pszText = sTemp.GetBuffer(sTemp.GetLength()); tvis.item.cchTextMax = sTemp.GetLength(); tvis.item.iImage = nIconIndex; tvis.item.iSelectedImage = nSelIconIndex; tvis.item.cChildren = HasGotSubEntries(sPath); HTREEITEM hItem = m_Tree.InsertItem(&tvis); sTemp.ReleaseBuffer(); return hItem; }
void CurlCore::ParseJsonData(string &sMsg, vector<string>& sParsedvalue) { sParsedvalue.clear(); int iCount = 0; for(char *p = strtok((char *)sMsg.c_str(), ","); p; p = strtok(NULL, ",")){ string sTemp(p); int sPos = sTemp.find(":"); int lPos = sTemp.size(); string sAttr = sTemp.substr(0, sPos); if(sTemp[sPos + 1] == '"') { sPos += 1; lPos -= 1; } sTemp = sTemp.substr(sPos+1, lPos - sPos - 1); ShowInfo(sAttr, sTemp, iCount); sParsedvalue.push_back(sTemp); } iCount = 0; }
//-------------------------------------------------------------------------------- void CSystemMonitorHandlerThread::DoPause() { CString sTemp("This command does nothing - surprised?\r\n"); m_socket.Send(sTemp, sTemp.GetLength(), CSmallSocket::WAITFORWOULDBLOCK); // GetSystem()->SetState(STATE_PAUSE); // GetSystem()->WaitForStateSync(); }
bool CScriptSystem::ExecuteFile(const char* sFileName, bool forceReload) { if (strlen(sFileName) <= 0) { return false; } CPathID sTemp(sFileName); ScriptFileListItor itor = this->findFile(sTemp); if (itor == m_dqLoadedFiles.end() || forceReload) { char sRealFileName[MAX_PATH]; string_sprintf(sRealFileName, "%s_compiled", sFileName); if (!_ExecuteFile(sFileName)) { return false; } if (itor == m_dqLoadedFiles.end()) { m_dqLoadedFiles.push_back(sTemp); } } return true; }
BOOL CNTScmService::ChangeDescription(const CNTServiceString& sDescription) { //Validate our parameters ATLASSERT(m_hService != NULL); //Check to see if the function pointer is available if (m_lpfnChangeServiceConfig2 == NULL) { ATLTRACE(_T("CNTScmService::ChangeDescription, ChangeServiceConfig2 function is not supported on this OS. You need to be running at least Windows 2000 to use this function\n")); SetLastError(ERROR_CALL_NOT_IMPLEMENTED); return FALSE; } //Call through the function pointer SERVICE_DESCRIPTION sd; CNTServiceString sTemp(sDescription); #ifdef CNTSERVICE_MFC_EXTENSIONS sd.lpDescription = sTemp.GetBuffer(sTemp.GetLength()); #else sd.lpDescription = &(sTemp[0]); #endif BOOL bSuccess = m_lpfnChangeServiceConfig2(m_hService, SERVICE_CONFIG_DESCRIPTION, &sd); #ifdef CNTSERVICE_MFC_EXTENSIONS sTemp.ReleaseBuffer(); #endif return bSuccess; }
//-------------------------------------------------------------------------------- void CSystemMonitorHandlerThread::DoContinue() { CString sTemp("Is pause does nothing, what makes you think this command would do something?\r\n"); m_socket.Send(sTemp, sTemp.GetLength(), CSmallSocket::WAITFORWOULDBLOCK); // GetSystem()->SetState(STATE_RUN); // GetSystem()->WaitForStateSync(); }
// frame constructor MyFrame::MyFrame(const wxString& title, const wxSize& size) : wxFrame(NULL, wxID_ANY, title, wxDefaultPosition, size) , m_splitter(NULL) , m_showMsgIcon(false) , m_taskBarIcon(NULL) { wxString sTemp(gAppPath); sTemp.Append(wxT("/res/mainframe.ico")); wxIcon icon(sTemp, wxBITMAP_TYPE_ICO); // set the frame icon SetIcon(icon); #if wxUSE_MENUS // create a menu bar wxMenu *fileMenu = new wxMenu; // the "About" item should be in the help menu wxMenu *helpMenu = new wxMenu; fileMenu->Append(ID_Menu_ChangeAccount, gLangText.menuChangeAccText(), gLangText.menuChangeAccHelp()); fileMenu->AppendSeparator(); fileMenu->Append(ID_Menu_InforSetting, gLangText.menuInforSettingText(), gLangText.menuInforSettingHelp()); fileMenu->AppendSeparator(); fileMenu->Append(wxID_EXIT, gLangText.menuExitText(), gLangText.menuExitHelp()); helpMenu->Append(wxID_ABOUT, gLangText.menuAboutText(), gLangText.menuAboutHelp()); // now append the freshly created menu to the menu bar... wxMenuBar *menuBar = new wxMenuBar(); menuBar->Append(fileMenu, gLangText.menuFile()); menuBar->Append(helpMenu, gLangText.menuHelp()); // ... and attach this menu bar to the frame SetMenuBar(menuBar); #endif // wxUSE_MENUS #if wxUSE_STATUSBAR // create a status bar just for fun (by default with 1 pane only) CreateStatusBar(2); SetStatusText(gLangText.textWelcome()); #endif // wxUSE_STATUSBAR m_splitter = new wxSplitterWindow(this, wxID_ANY, wxDefaultPosition, GetClientSize(), wxSP_NOBORDER); //m_left = new LeftWindow(m_splitter); RelationshipWindow * relationship = new RelationshipWindow(m_splitter); RightWindow * right = new RightWindow(m_splitter); right->SetBackgroundColour(*wxWHITE); m_splitter->SetMinimumPaneSize(60); m_splitter->SplitVertically(relationship, right, 180); //m_richTextCtrl = new wxRichTextCtrl(m_splitter, ID_RICHTEXT_CTRL, wxEmptyString, wxDefaultPosition, wxSize(200, 200), wxVSCROLL|wxHSCROLL|wxNO_BORDER|wxWANTS_CHARS); //m_splitter->SplitVertically(m_left, m_richTextCtrl, 200); m_timer.SetOwner(this); //m_timer.Start(1000); m_splitter->UpdateSize(); theFrame = this; }
//-------------------------------------------------------------------------------- void CSystemMonitorHandlerThread::DoRevoke() { int nIndex = m_sCurCmd.ReverseFind(' '); if(nIndex == -1) return; if(nIndex == (m_sCurCmd.GetLength() - 1)) return; CString sTemp(m_sCurCmd.Mid(nIndex + 1)); if(sTemp == "all") { DoRevokeAll(); return; } if(sTemp.Find('.') != -1) { DoRevokeByIP(sTemp); return; } DWORD nId = (DWORD) atol(sTemp); if(! GetSystem()->GetDBSubSystem()->ReleaseCertificate(nId)) sTemp.Format("certificate %d not found\n\r", nId); else sTemp.Format("certificate %d revoked\r\n", nId); m_socket.Send(sTemp, sTemp.GetLength(), CSmallSocket::WAITFORWOULDBLOCK); }
TSet TSet::operator+(const int Elem) // объединение с элементом { if (Elem > BitField.GetLength()) throw "Out of memory"; TBitField bTemp(MaxPower); bTemp.SetBit(Elem); TSet sTemp(BitField | bTemp); return sTemp; }
CSize CEnString::Draw(CDC* pDC, LPRECT lpRect, int nStyle) { // we must do the format independently of DrawText because we override it CEnString sTemp(*this); sTemp.FormatDC(pDC, lpRect->right - lpRect->left, nStyle); pDC->DrawText(sTemp, lpRect, DT_SINGLELINE); return pDC->GetTextExtent(sTemp); }
TSet TSet::operator-(const int Elem) // разность с элементом { if (Elem > BitField.GetLength()) throw "Out of memory"; TBitField bTemp(MaxPower); bTemp.SetBit(Elem); TSet sTemp(BitField & bTemp); return sTemp; }
//-------------------------------------------------------------------------------- void CSystemMonitorHandlerThread::DoLoad(LPCTSTR pFilename) { CString sTemp(pFilename); if(! sTemp.IsEmpty()) GetSystem()->SetLicenseFilename(sTemp); if(GetSystem()->GetDBSubSystem()->LoadFromFile()) sTemp = "file loaded ok\r\n"; else sTemp = "error while loading file\r\n"; m_socket.Send(sTemp, sTemp.GetLength(), CSmallSocket::WAITFORWOULDBLOCK); }
//-------------------------------------------------------------------------------- void CSystemMonitorHandlerThread::DoConfigDump() { CString sTemp("Configuration:\r\n"); if(! m_socket.Send(sTemp, CSmallSocket::WAITFORWOULDBLOCK)) return; CStringArray sArray; GetSystem()->GetSystemConfigStringMessage(sArray); for(int i = 0; i < sArray.GetSize(); i++) if(! m_socket.Send(sArray[i] + "\r\n", CSmallSocket::WAITFORWOULDBLOCK)) return; }
String String::operator+( String &rhs ) { char *pNewData = new char[m_size+rhs.m_size+1]; memcpy( pNewData, m_pData, m_size ); memcpy( pNewData+m_size, rhs.m_pData, rhs.m_size ); pNewData[m_size+rhs.m_size] = '\0'; String sTemp(pNewData); delete pNewData; return sTemp; }
void UserListModule_Impl::_newUserListInfoResponse(CImPdu* pdu) { CImPduClientUserInfoResponse* pUserInfoResp = (CImPduClientUserInfoResponse*)pdu; client_user_info_t* pUserInfoList = pUserInfoResp->GetUserInfoList(); for (UInt32 i = 0; i < pUserInfoResp->GetUserCnt(); ++i) { client_user_info_t& info = pUserInfoList[i]; std::string sId(info.id_url, info.id_len); module::UserInfoEntity userInfo; BOOL bAddNewUser = FALSE; if (!getUserInfoBySId(sId, userInfo)) bAddNewUser = TRUE; if (info.name_len) { std::string sTemp(info.name, info.name_len); userInfo.csName = util::stringToCString(sTemp); } if (info.nick_name_len) { std::string sTemp(info.nick_name, info.nick_name_len); userInfo.csNickName = util::stringToCString(sTemp); } userInfo.avatarUrl = string(info.avatar_url, info.avatar_len); userInfo.sId = sId; userInfo.dId = string(info.depart_id_url, info.depart_id_len); if (bAddNewUser) { tcpGetUserOnlieStatus(sId);//请求该用户的在线状态 //对号入座部门信息 _pushUserIdToDepartment(sId, userInfo.dId); util::TTAutoLock lock(&m_lock); m_mapUsers[sId] = userInfo; logic::GetLogic()->asynNotifyObserver(module::KEY_USERLIST_UPDATE_NEWUSESADDED); } } }
void CAniClientConnection::OnUserInfoReceived( bool bSuccess, int iUserSocket, LPCSTR lpszUserInfo, LPCSTR lpszErrorMessage ) { bool bNew = false; CDlgUserInfo* pInfo = STATIC_DOWNCAST( CDlgUserInfo, m_pDialog->GetPageForUser( iUserSocket ) ); if ( !pInfo ) { pInfo = new CDlgUserInfo; pInfo->m_iUserSocket = iUserSocket; bNew = true; } CHotlineUser User; if ( !GetUserInfoBySocket( iUserSocket, User ) ) { pInfo->m_sUserIcon = "<unknown>"; pInfo->m_sUserName = "******"; } else { CHotlineIcon* pIcon = NULL; if ( m_pDialog->m_pMainDialog->GetHotlineDat( ) ) pIcon = m_pDialog->m_pMainDialog->GetHotlineDat( )->GetHotlineIcon( User.GetIconNumber( ) ); if ( !pIcon || ( !pIcon->m_sName ) ) pInfo->m_sUserIcon.Format( "%d", User.GetIconNumber( ) ); else { CString sTemp( pIcon->m_sName ); FixNameForDisplay( sTemp ); pInfo->m_sUserIcon.Format( "%s [%d]", ( LPCSTR )sTemp, pIcon->m_iNumber ); } pInfo->m_sUserName = User.GetName( ); } if ( bSuccess ) pInfo->m_sFromHL = lpszUserInfo; else pInfo->m_sFromHL = lpszErrorMessage; ConvertFromHL( pInfo->m_sFromHL ); if ( bNew ) m_pDialog->AddPropertyPage( pInfo, true ); m_pDialog->SetPageCaption( pInfo, pInfo->m_sUserName ); }
DECLDIR int Upload(char* path, char* URL, int check ,double check2, char* Type) { int Message = 11111111; std::string Path(path); Path = Path + "\\YiWeather.exe"; std::fstream _File; _File.open(Path, std::ios::in); if (!_File) { MessageBox(NULL, L"缺少主程序", L"提示", MB_OK); } else { //包类型判断 SM sm; char* BagType; std::string sTemp(URL); size_t len = sTemp.find_first_of('Q', 0); if (len != sTemp.npos) { sTemp = sTemp.replace(len, sTemp.length()-len, ""); BagType = "1"; URL = (char*)sTemp.c_str(); } else { BagType = "0"; } if (check2 == 0.618) { sm.ReadDataFromComputer(sm, BagType); if (sm.ReadDataFromIni(path, sm)) { std::string _Message = sm.DataHanding(sm, URL, Type); if (!strcmp(_Message.c_str(),"")) { Message = atoi(_Message.c_str()); } } } } return Message; }
void MyFrame::changeTaskBarIcon(const wxString & iconfilename, const wxString & tooltip) { if (m_taskBarIcon != NULL) { wxString sTooltip = tooltip.empty() ? m_taskBarTooltip : tooltip; wxString sTemp(gAppPath.c_str()); sTemp.Append(wxT("/res/")); sTemp.Append(iconfilename); wxIcon iconTaskBar(sTemp, wxBITMAP_TYPE_ICO); if (!m_taskBarIcon->SetIcon(iconTaskBar, sTooltip)) { wxMessageBox(wxT("Could not set icon.")); } } }
void CScriptSystem::UnloadScript(const char* sFileName) { if (strlen(sFileName) <= 0) { return; } CPathID sTemp(sFileName); ScriptFileListItor itor = this->findFile(sTemp); if (itor != m_dqLoadedFiles.end()) { #ifdef DEBUG_RESID BEHAVIAC_LOGINFO("ERASE :%s\n", sTemp.GetFileName()); #endif m_dqLoadedFiles.erase(itor); } }
// ----------------------------------------------------------------------------- // CATBase::GetStringUntilMainId // Function returns string from begin of given string until next atool's main id <AT>, // characters until next main id are removed from sInput string. // ----------------------------------------------------------------------------- string CATBase::GetStringUntilMainId( string& sInput, bool bEraseFromInput ) { LOG_LOW_FUNC_ENTRY("CATBase::GetStringUntilMainId"); string sTemp( sInput ); size_t iSize = sTemp.find(MAIN_ID); if( iSize != string::npos ) { sTemp.resize( iSize ); if( bEraseFromInput ) sInput.erase( 0, (iSize) ); } else { if ( bEraseFromInput ) sInput.clear(); } return sTemp; }
// ----------------------------------------------------------------------------- // CATBase::GetStringUntilNextSpace // Function returns string from begin of given string until next space, // characters until next space are removed from sInput string. // ----------------------------------------------------------------------------- string CATBase::GetStringUntilNextSpace( string& sInput, bool bEraseFromInput ) { LOG_LOW_FUNC_ENTRY("CATBase::GetStringUntilNextSpace"); string sTemp( sInput ); size_t iSize = sTemp.find_first_of(' '); if( iSize != string::npos ) { sTemp.resize( iSize ); if( bEraseFromInput ) sInput.erase( 0, (iSize+1) ); } else { if ( bEraseFromInput ) sInput.clear(); } return sTemp; }
// ----------------------------------------------------------------------------- // CATBase::SearchFileWithExtension // Searches files with given extension from path. // ----------------------------------------------------------------------------- bool CATBase::SearchFileWithExtension( const char* pPathAndExt, bool bPrintErrors, string& sErrorLog ) { LOG_FUNC_ENTRY("CATBase::SearchFileWithExtension"); WIN32_FIND_DATA FindFileData; HANDLE hFind; string sTemp( pPathAndExt ); //Find file hFind = FindFirstFile( sTemp.c_str(), &FindFileData ); if (hFind == INVALID_HANDLE_VALUE) { string sErrorString( "No " ); //Get extension string sExt( pPathAndExt ); sExt.erase( 0, sExt.find_last_of( "." ) ); sErrorString.append( sExt ); sErrorString.append( " files in directory: " ); string sWithoutExt( pPathAndExt ); sWithoutExt.erase( sWithoutExt.find_last_of( "." )-1, string::npos ); sErrorString.append( sWithoutExt ); if( bPrintErrors ) { //string sTemp( pPathAndExt ); //printf( "Can not find: %s.\n", pPathAndExt ); printf( sErrorString.c_str() ); } else { //Add line change if sErrorString not empty if( !sErrorLog.empty() ) sErrorString.insert( 0, "\n" ); sErrorLog.append( sErrorString ); } return false; } else { FindClose(hFind); return true; } }
CDlgAddUser::CDlgAddUser(wxWindow *parent) : wxDialog(parent, wxID_ANY, gLangText.dlgAddUserTitle()) { BOOST_ASSERT (gMyAccount.get() != NULL); wxString sTemp(gAppPath); sTemp.Append(wxT("/res/mainframe.ico")); wxIcon icon(sTemp, wxBITMAP_TYPE_ICO); // set the frame icon SetIcon(icon); wxBoxSizer *sizerTop = new wxBoxSizer(wxVERTICAL); wxBoxSizer * sizerChoose = new wxBoxSizer(wxHORIZONTAL); wxSizer * sizerChooseLeft = new wxStaticBoxSizer(new wxStaticBox(this, wxID_ANY, gLangText.dlgStaticChooseFrom()), wxVERTICAL); wxSizer * sizerChooseRight = new wxStaticBoxSizer(new wxStaticBox(this, wxID_ANY, gLangText.dlgStaticChooseTo()), wxVERTICAL); m_searchTextCtrl = new wxTextCtrl(this, Ctrl_SearchText, "", wxDefaultPosition, wxSize(180, 22)); m_searchTextCtrl->SetToolTip(gLangText.textSearchTip()); m_listboxChooseFrom = new wxListBox(this, Ctrl_ChooseFrom, wxDefaultPosition, wxSize(180, 280)); m_listboxChooseTo = new wxListBox(this, Ctrl_ChooseTo, wxDefaultPosition, wxSize(180, 280)); sizerChooseLeft->Add(m_searchTextCtrl, 0, wxALL|wxALIGN_CENTER, 5); sizerChooseLeft->Add(m_listboxChooseFrom, 1, wxGROW | wxALL, 5); sizerChooseRight->Add(m_listboxChooseTo, 1, wxGROW | wxALL, 5); sizerChoose->Add(sizerChooseLeft, 1, wxGROW|wxALL, 5 ); sizerChoose->Add(sizerChooseRight, 1, wxGROW|wxALL, 5 ); sizerTop->Add(sizerChoose, 1, wxEXPAND | wxLEFT|wxRIGHT, 5 ); wxSizer *buttonSizer = CreateSeparatedButtonSizer(wxOK | wxCANCEL); if ( buttonSizer ) { this->GetWindowChild(wxID_OK)->SetLabel(gLangText.btnAddUserText()); this->GetWindowChild(wxID_OK)->SetToolTip(gLangText.btnAddUserHelp()); this->GetWindowChild(wxID_OK)->Disable(); this->GetWindowChild(wxID_CANCEL)->SetLabel(gLangText.btnCancelText()); this->GetWindowChild(wxID_CANCEL)->SetToolTip(gLangText.btnCancelHelp()); sizerTop->Add(buttonSizer, wxSizerFlags().Expand().DoubleBorder()); } SetSizer(sizerTop); sizerTop->SetSizeHints(this); sizerTop->Fit(this); }
void MyFrame::setTaskBarIcon(const wxString & iconfilename, const wxString & tooltip) { wxString sTemp(gAppPath.c_str()); sTemp.Append(wxT("/res/")); sTemp.Append(iconfilename); wxIcon iconTaskBar(sTemp, wxBITMAP_TYPE_ICO); m_taskBarTooltip = tooltip; if (m_taskBarIcon == NULL) { m_taskBarIcon = new MyTaskBarIcon(this); } if (!m_taskBarIcon->SetIcon(iconTaskBar, m_taskBarTooltip)) { wxMessageBox(wxT("Could not set icon.")); } }
/** * Display error message text. * Format a HRESULT as an error message prompt. */ HRESULT DoDisplayErrorMessage(HWND hWnd, UINT nTitle, HRESULT Hr) { HRESULT HrOrig = Hr; if( HRESULT_FACILITY(Hr) == FACILITY_WINDOWS ) Hr = HRESULT_CODE(Hr); if( HRESULT_FACILITY(Hr) == FACILITY_WIN32 ) Hr = HRESULT_CODE(Hr); // Format error message; try various sources LPTSTR pstr = NULL; if( pstr == NULL ) ::FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_FROM_SYSTEM, NULL, Hr, 0, (LPTSTR) &pstr, 0, NULL); static LPCTSTR s_ppstrModules[] = { _T("winhttp"), _T("mswsock"), _T("netmsg"), _T("crypt32") }; for( int i = 0; pstr == NULL && i < lengthof(s_ppstrModules); i++ ) { ::FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_FROM_HMODULE, ::GetModuleHandle(s_ppstrModules[i]), Hr, 0, (LPTSTR) &pstr, 0, NULL); } bool bReleaseStr = (pstr != NULL); CString sTemp(MAKEINTRESOURCE(IDS_ERR_GENERIC)); CComBSTR bstrErr; CComPtr<IErrorInfo> spErrInfo; ::GetErrorInfo(0, &spErrInfo); if( spErrInfo != NULL ) spErrInfo->GetDescription(&bstrErr); if( pstr == NULL ) pstr = bstrErr.m_str; if( pstr == NULL ) pstr = const_cast<LPTSTR>(static_cast<LPCTSTR>(sTemp)); if( pstr[0] != '\0' && pstr[ _tcslen(pstr) - 1 ] == '\n' ) pstr[ _tcslen(pstr) - 1 ] = '\0'; if( pstr[0] != '\0' && pstr[ _tcslen(pstr) - 1 ] == '\r' ) pstr[ _tcslen(pstr) - 1 ] = '\0'; // Display message as a TaskDialog prompt CString sMessage, sFooter, sExtra; if( Hr >= WINHTTP_ERROR_BASE && Hr <= WINHTTP_ERROR_LAST ) sExtra.LoadString(IDS_ERR_WINHTTP); if( Hr == ERROR_BAD_USER_PROFILE ) sExtra.LoadString(IDS_ERR_NSID); sMessage.Format(IDS_ERRMSG_DESCRIPTION, pstr, sExtra); sFooter.Format(IDS_ERRMSG_HRESULT, HrOrig, bstrErr); if( bReleaseStr ) ::LocalFree(pstr); TASKDIALOGCONFIG tdc = { 0 }; tdc.cbSize = sizeof(TASKDIALOGCONFIG); tdc.hInstance = _pModule->GetResourceInstance(); tdc.hwndParent = hWnd; tdc.pszMainIcon = TD_ERROR_ICON; tdc.dwFlags = TDF_ALLOW_DIALOG_CANCELLATION | TDF_POSITION_RELATIVE_TO_WINDOW; tdc.dwCommonButtons = TDCBF_OK_BUTTON; tdc.pszWindowTitle = MAKEINTRESOURCE(IDS_CAPTION_ERROR); tdc.pszMainInstruction = MAKEINTRESOURCE(nTitle); tdc.pszContent = sMessage; tdc.pszFooter = sFooter; ::TaskDialogIndirect(&tdc, NULL, NULL, NULL); return HrOrig; }
CString CTimeHelper::FormatTime(double dTime, int nUnits, int nDecPlaces) const { // sanity check if (nUnits && !IsValidUnit(nUnits)) { ASSERT(0); return _T(""); } CString sTime = Misc::Format(dTime, nDecPlaces); TCHAR cUnits; if (nUnits && MAPUNIT2CH.Lookup(nUnits, cUnits)) { CString sTemp(sTime); sTime.Format(_T("%s %c"), sTemp, cUnits); } return sTime; }
void GroupListModule_Impl::_groupuserlistResponse(CImPdu* pdu) { CImPduClientGroupUserListResponse* pduData = (CImPduClientGroupUserListResponse*)pdu; std::string groupid(pduData->GetGroupId(), pduData->GetGroupIdLen()); std::string groupSid = _MakeGroupSID(groupid); util::TTAutoLock lock(&m_lock); module::GroupInfoEntity groupInfo; if (getGroupInfoBySId(groupid, groupInfo)) { APP_LOG(LOG_ERROR, _T("获取的是已知群的信息")); } else//保存这个讨论组信息 { groupInfo.gId = groupid;//ID user_id_t* pUserInfo = pduData->GetUserList();//群成员 if (NULL != pUserInfo) { for (UInt32 i = 0; i < pduData->GetUserCnt(); ++i) { std::string Sid; Sid.assign(pUserInfo[i].id_url, pUserInfo[i].id_len); groupInfo.groupMemeberList.push_back(Sid); } } if (NULL != pduData->GetGroupAvatar())//头像 { groupInfo.avatarLocalPath.assign(pduData->GetGroupAvatar(), pduData->GetGroupAvatarLen()); } if (NULL != pduData->GetGroupName())//名字 { std::string sTemp(pduData->GetGroupName(), pduData->GetGroupNameLen()); groupInfo.csName = util::stringToCString(sTemp, CP_UTF8); } groupInfo.type = pduData->GetGroupType(); m_mapGroups.insert(std::make_pair(groupid, groupInfo)); } logic::GetLogic()->asynNotifyObserver(module::KEY_GROUPLIST_UPDATE_NEWGROUPADDED, groupSid);//通知UI新增加了一个讨论组 }
bool CursorTrail::ComputePer(const Vec2s & p1, const Vec2s & p2, TexturedVertex * v1, TexturedVertex * v2, float size) { Vec2f sTemp((float)(p2.x - p1.x), (float)(p2.y - p1.y)); float fTemp = sTemp.x; sTemp.x = -sTemp.y; sTemp.y = fTemp; float fMag = glm::length(sTemp); if(fMag < std::numeric_limits<float>::epsilon()) { return false; } fMag = size / fMag; v1->p.x = sTemp.x * fMag; v1->p.y = sTemp.y * fMag; v2->p.x = ((float)p1.x) - v1->p.x; v2->p.y = ((float)p1.y) - v1->p.y; v1->p.x += (float)p1.x; v1->p.y += (float)p1.y; return true; }