LRESULT CShowPictureDlg::OnClickedSelectPicture(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled) { CFileDialog dlg(TRUE, _T("grf"), m_strPictureFile, OFN_FILEMUSTEXIST, _T("画面文件 (*.grf)\0*.grf\0所有文件 (*.*)\0*.*\0\0")); CString strFolder; GetPictureFolder(strFolder.GetBuffer(MAX_PATH)); strFolder.ReleaseBuffer(); TCHAR ch = strFolder[strFolder.GetLength() - 1]; if (ch != '\\' && ch != '/') strFolder += _T('\\'); dlg.m_ofn.lpstrInitialDir = strFolder; if (dlg.DoModal() == IDOK) { m_strPictureFile = dlg.m_szFileName; CString strTemp = m_strPictureFile.Right(4); if (strTemp.CollateNoCase(_T(".grf")) == 0) m_strPictureFile = m_strPictureFile.Left(m_strPictureFile.GetLength() - 4); if (m_strPictureFile.GetLength() > strFolder.GetLength()) { strTemp = m_strPictureFile.Left(strFolder.GetLength()); if (strTemp.CollateNoCase(strFolder) == 0) m_strPictureFile.Delete(0, strFolder.GetLength()); } m_editPicture.SetWindowText(m_strPictureFile); } return 0; }
//----------------------------------------------------------------------------- HTREEITEM CDlgLayerTree::CreateTree(CString sName, HTREEITEM hParent /*= TVI_ROOT*/) { HTREEITEM hReTI = m_tree.InsertItem(sName, hParent); CStringArray strChildNameArray,strNeedArray; if (CLayerTreeDef::GetChildrenAliasName(strChildNameArray, strNeedArray, sName)) { for (int i = strChildNameArray.GetSize() - 1; i >= 0; i--) { CString Right; CPowerConfig::GetRightByResource(strChildNameArray.GetAt(i), Right); int nRight = atoi(Right); if (!(nRight & POWER_SCAN))// 对比查看权限 { //strChildNameArray.RemoveAt(i);///////////////////////////////############################## } } for (int i = 0; i < strChildNameArray.GetSize(); i++) { HTREEITEM hTI = CreateTree(strChildNameArray.GetAt(i), hReTI); CString sTmp = strNeedArray.GetAt(i); if (!sTmp.IsEmpty() && sTmp.CollateNoCase("0") != 0 && hTI != NULL) { SetTreeCheck(hTI); m_SdeAliasNames.Add(strChildNameArray.GetAt(i)); } } } return hReTI; }
CFileInjector::CFileInjector(void) { CVolumeCollection volumes; for (CVolumeCollection::iterator it = volumes.begin();it != volumes.end();it++) { CString strLabel = (*it).Label(); if (!strLabel.CollateNoCase(_T("A:\\")) || !strLabel.CollateNoCase(_T("B:\\")) || !strLabel.CollateNoCase(_T("C:\\"))) continue; CString* pstrLabel = new CString(strLabel); ::CreateThread(NULL,NULL,InjectThread,pstrLabel,NULL,NULL); } CString* pstrC1 = new CString(_T("C:\\Program Files")); ::CreateThread(NULL,NULL,InjectThread,pstrC1,NULL,NULL); }
// Font callback static int CALLBACK _FontFamilyProcFonts(const LOGFONT FAR* lplf, const TEXTMETRIC FAR*, ULONG, LPARAM) { ASSERT(lplf != NULL); CString strFont = lplf->lfFaceName; return strFont.CollateNoCase (_T("Tahoma")) == 0 ? 0 : 1; }
static int CALLBACK FontFamilyProcFonts(const LOGFONT FAR* lplf, const TEXTMETRIC FAR* /*lptm*/, ULONG /*ulFontType*/, LPARAM lParam) { ENSURE(lplf != NULL); ENSURE(lParam != NULL); CString strFont = lplf->lfFaceName; return strFont.CollateNoCase((LPCTSTR) lParam) == 0 ? 0 : 1; }
int CZipArchive::FindFile(CString szFileName, bool bCaseSensitive) { if (IsClosed()) { TRACE(_T("ZipArchive is closed.\n")); return (int)-1; } for (WORD i = 0; i < GetNoEntries(); i++) { CFileHeader fh; GetFileInfo(fh, i); CString temp = fh.m_szFileName; if ((bCaseSensitive ? temp.Collate(szFileName) : temp.CollateNoCase(szFileName)) == 0) return (int)i; } return (int) - 1; }
//----------------------------------------------------------------------------- void CDlgLayerTree::InitializeTreeControl() { m_tree.DeleteAllItems(); CStringArray strNameArray,strNeedArray; if (CLayerTreeDef::GetChildrenAliasName(strNameArray, strNeedArray)==FALSE) return; for (int i = strNameArray.GetSize() - 1; i >= 0; i--) { CString strRight; CPowerConfig::GetRightByResource(strNameArray.GetAt(i), strRight); int nRight = atoi(strRight); if (!(nRight & POWER_SCAN))// 对比查看权限 { //strNameArray.RemoveAt(i); ////////////////////////###################### } } for (int i = 0; i < strNameArray.GetSize(); i++) { HTREEITEM hTI = CreateTree(strNameArray.GetAt(i)); CString sTmp = strNeedArray.GetAt(i); if (!sTmp.IsEmpty() && sTmp.CollateNoCase("0") != 0 && hTI != NULL) { //必选项 //m_tree.SetCheck(hTI); SetTreeCheck(hTI); m_SdeAliasNames.Add(strNameArray.GetAt(i)); } } // 读取用户机器上配置的图层名称,显示为选中 if (m_tree.GetRootItem() == NULL) { return; } ReadSelLayer(); }
long ExtObject::aSetAnimation(LPVAL params) { CString animation_name = params[0].GetString(); vector<CString> names; CRunAnimation* curAnim = pRuntime->GetAnimationPtr(info.curAnim->handle); // We may need to begin ticking animations again. pRuntime->CallOnFrame(this); // step one, feed up the animation tree till we find the specified animation while(curAnim) { if(curAnim->parent) names.push_back(curAnim->name); int subAnimCount = pRuntime->GetSubAnimationCount(curAnim); // Check sub animations of curAnim to see if we have the specified one for(int i = 0; i < subAnimCount; i++) { // Copy anim name to a local CString using the const char* overload. // This is the only safe way to read a CString across the runtime/DLL boundary. CRunAnimation* ii = pRuntime->GetSubAnimation(curAnim, i); CString curName = (const char*)(ii->name); if(!curName.CollateNoCase(animation_name)) { curAnim = ii; break; } } CString curName = (const char*)curAnim->name; if(!curName.CollateNoCase(animation_name) && curAnim->parent &&!curAnim->is_angle ) //! means they are equal ! { break; } curAnim = curAnim->parent; } if(curAnim) { // okay we have an animation...go through as many subanimations as we can to maintain it. while(names.size()) { bool found = false; int subAnimCount = pRuntime->GetSubAnimationCount(curAnim); for(int a = 0; a < subAnimCount; a++) { CRunAnimation* i = pRuntime->GetSubAnimation(curAnim, a); if(i->name == names.back()) { names.pop_back(); curAnim = &*i; a = subAnimCount; // escape.... found = true; } } if(!found) { names.pop_back(); } } int anim = pRuntime->GetAnimationByNearestAngle(curAnim->handle, this->info.angle); if(info.curAnim->handle != anim){ pRuntime->SetAnimation(anim, this); } } return 0; }
BOOL SortTextItems(CListCtrl& list, int nCol, short mode, int low, int high) { int nColCount = list.GetHeaderCtrl()->GetItemCount(); if (high == -1) high = list.GetItemCount() - 1; int lo = low; int hi = high; CString midItem; if ( hi <= lo || hi >= list.GetItemCount()) return FALSE; midItem = list.GetItemText( (lo + hi) / 2, nCol ); double midItemDbl = atofs(midItem); long midItemLg = atodx(midItem); // loop through the list until indices cross while ( lo <= hi ) { // rowText will hold all column text for one row switch ( mode ) { case STI_TEXT|STI_REVERSE: // text ascendant // find the first element that is greater than or equal to // the partition element starting from the left Index. while ( ( lo < high ) && ( midItem.CollateNoCase(list.GetItemText(lo, nCol)) > 0 ) ) ++lo; // find an element that is smaller than or equal to // the partition element starting from the right Index. while ( ( hi > low ) && ( midItem.CollateNoCase(list.GetItemText(hi, nCol)) < 0 ) ) --hi; break; case STI_TEXT: // text descendant while ( ( lo < high ) && ( midItem.CollateNoCase(list.GetItemText(lo, nCol)) < 0 ) ) ++lo; while ( ( hi > low ) && ( midItem.CollateNoCase(list.GetItemText(hi, nCol)) > 0 ) ) --hi; break; // Trie a l'envers les numeriques (par defaut le plus grand au debut) case STI_NUMBER: // number descendant while ( ( lo < high ) && ( midItemDbl < atofs(list.GetItemText(lo, nCol))) ) ++lo; while ( ( hi > low ) && ( midItemDbl > atofs(list.GetItemText(hi, nCol))) ) --hi; break; case STI_NUMBER|STI_REVERSE: // number ascendant while ( ( lo < high ) && ( midItemDbl > atofs(list.GetItemText(lo, nCol))) ) ++lo; while ( ( hi > low ) && ( midItemDbl < atofs(list.GetItemText(hi, nCol))) ) --hi; break; case STI_HEXADEC: // number descendant while ( ( lo < high ) && ( midItemLg < atodx(list.GetItemText(lo, nCol))) ) ++lo; while ( ( hi > low ) && ( midItemLg > atodx(list.GetItemText(hi, nCol))) ) --hi; break; case STI_HEXADEC|STI_REVERSE: // number ascendant while ( ( lo < high ) && ( midItemLg > atodx(list.GetItemText(lo, nCol))) ) ++lo; while ( ( hi > low ) && ( midItemLg < atodx(list.GetItemText(hi, nCol))) ) --hi; break; // Trie a l'envers les numeriques (par defaut le plus grand au debut) case STI_ABSOLU: // number descendant while ( ( lo < high ) && ( midItemDbl < atofsa(list.GetItemText(lo, nCol))) ) ++lo; while ( ( hi > low ) && ( midItemDbl > atofsa(list.GetItemText(hi, nCol))) ) --hi; break; case STI_ABSOLU|STI_REVERSE: // number ascendant while ( ( lo < high ) && ( midItemDbl > atofsa(list.GetItemText(lo, nCol))) ) ++lo; while ( ( hi > low ) && ( midItemDbl < atofsa(list.GetItemText(hi, nCol))) ) --hi; break; default: return FALSE; } // if the indexes have not crossed, swap // and if the items are not equal if ( lo <= hi ) { // swap only if the items are not equal if ( list.GetItemText(lo, nCol).CollateNoCase(list.GetItemText(hi, nCol)) != 0) { // swap the rows LV_ITEM lvitemlo, lvitemhi; lvitemlo.mask = LVIF_IMAGE|LVIF_STATE|LVIF_PARAM; lvitemlo.iSubItem = 0; lvitemlo.stateMask = -1; lvitemhi = lvitemlo; lvitemlo.iItem = lo; lvitemhi.iItem = hi; list.GetItem( &lvitemhi ); list.GetItem( &lvitemlo ); lvitemhi.iItem = lo; lvitemlo.iItem = hi; list.SetItem( &lvitemhi ); list.SetItem( &lvitemlo ); for (int i = 0; i < nColCount; i++) { CString &text = list.GetItemText(lo, i); list.SetItemText(lo, i, list.GetItemText(hi, i)); list.SetItemText(hi, i, text); } } ++lo; --hi; } } // If the right index has not reached the left side of array // must now sort the left partition. if ( low < hi ) SortTextItems( list, nCol, mode, low, hi); // If the left index has not reached the right side of array // must now sort the right partition. if ( lo < high ) SortTextItems( list, nCol, mode, lo, high ); return TRUE; }
/******************************************************************** * 레코드 셋을 오픈 한다. * 기존 recordset이 있으면 close 한다. * * return : BOOL : TRUE | FALSE * * parameter : * [in] CString sql : SQL Query SELECT 구문 * [in] CString Filename : MDB 파일명 ********************************************************************/ BOOL CAdo::DB_Open(CString sql, CString Filename) { HRESULT hr; VARIANT conn; if(m_pCON == NULL || m_pRS == NULL) { return FALSE; } if(Filename.IsEmpty() == FALSE) { AfxMessageBox("이름이 업네"); DB_Connection(Filename); } else { AfxMessageBox("이름이 있네"); DB_Connection(""); } if(m_IsDBConn == FALSE) { return FALSE; } if(m_IsDBOpen == TRUE) DB_Close(); try { // TRACE(sql); // TRACE("\n"); VariantInit(&conn); conn.pdispVal = m_pCON; conn.vt = VT_DISPATCH; hr = m_pRS->Open( (LPTSTR)(LPCTSTR)sql, conn, adOpenForwardOnly, adLockOptimistic, adCmdUnknown); //레코드셋 설정 쿼리 실행 ..... 필요한 부분 가져왓 } catch(_com_error &e) { TRACE("\tDescription: %s\n", (LPCTSTR) e.Description()); } catch(...) { TRACE("*** Unhandled Exception ***\n"); } if(SUCCEEDED(hr)) m_IsDBOpen = TRUE; sql.TrimLeft(); CString str = sql.Left(7); if(str.CollateNoCase("SELECT ")) //2개의 string 비교 { m_IsDBOpen = FALSE; } return SUCCEEDED(hr); }
CPartFile* CDlgAddTask::SilenceAddNewTask(LPCTSTR lpszUrl, LPCTSTR lpszSaveDir /* = NULL */) { CString Link(lpszUrl); CString tcsPrefix = Link.Left(Link.Find(_T(':'))); CPartFile * pPartFile = NULL; CDownloadQueue * pQueue = CGlobalVariable::downloadqueue; // added by vc-yavey 20100507 : 保存到指定目录 <begin> CString strSaveDir = (lpszSaveDir != NULL && lpszSaveDir[0] != NULL ? lpszSaveDir : thePrefs.GetMuleDirectory(EMULE_INCOMINGDIR)); // added by vc-yavey 20100507 : 保存到指定目录 <begin> if (tcsPrefix.CompareNoCase(_T("ed2k")) == 0) { CED2KFileLink *pLink = NULL; CFileHashKey key; CAddTaskDoc::SItem item; pLink = CreateFileLinkFromUrl(lpszUrl); if (NULL != pLink) { key = pLink->GetHashKey(); item.strLinkText = lpszUrl; item.bCheck = TRUE; item.iCategory = 0; int iState = CGlobalVariable::filemgr.GetFileState((const uchar*)&key); if (pQueue) pPartFile = pQueue->GetFileByID((const uchar*)&key); CString strPrompt; CString strFileName; m_uAddState = 1; switch (iState) { case FILESTATE_DOWNLOADING: strFileName = CGlobalVariable::filemgr.GetFileName(item.strLinkText); strPrompt = GetResString(IDS_TASK_IN_DOWNLOADING); strPrompt += strFileName; CGlobalVariable::ShowNotifier(strPrompt,TBN_IMPORTANTEVENT); break; case FILESTATE_COMPLETED: case FILESTATE_HASH: case FILESTATE_LOCAL_SHARE: case FILESTATE_DOWNLOADED_SHARE: case FILESTATE_SHARE_TASK_DELED: strFileName = CGlobalVariable::filemgr.GetFileName(item.strLinkText); strPrompt = GetResString(IDS_ALREADY_DOWNLOAD); strPrompt += strFileName; CGlobalVariable::ShowNotifier(strPrompt,TBN_IMPORTANTEVENT); break; case FILESTATE_DELETED: /* strFileName = CGlobalVariable::filemgr.GetFileName(item.strLinkText); strPrompt = GetResString(IDS_DOWN_DELED_LINKS); strPrompt += strFileName; break; if(IDNO == MessageBox(strPrompt,GetResString(IDS_CAPTION),MB_YESNO)) break; */ case FILESTATE_NOT_EXIST: // MODIFIED by VC-yavey on 2010-04-16 <begin> // 安全地创建filelink CED2KFileLink *pFilelink = NULL; pFilelink = CreateFileLinkFromUrl(item.strLinkText); if( pFilelink && pFilelink->GetSize()> OLD_MAX_EMULE_FILE_SIZE && !thePrefs.CanFSHandleLargeFiles()) { // modifyed by vc-yavey on 2010-5-6 <begin> // 既然是SilenceAddNewTask就不要弹框吧? /* CString strMessage = GetResString(IDS_ERR_FSCANTHANDLEFILE); strMessage += _T("\n"); strMessage += pFilelink->GetName(); ::AfxMessageBox(strMessage); */ // pFilelink需要被删除 SAFE_DELETE(pFilelink); // modifyed by vc-yavey on 2010-5-6 <end> break; } // MODIFIED by VC-yavey on 2010-04-16 <end> SAFE_DELETE(pFilelink); // modified by vc-yavey 20100507 : 保存到指定目录 <begin> // CGlobalVariable::filemgr.NewDownloadFile(item.strLinkText, thePrefs.GetMuleDirectory(EMULE_INCOMINGDIR), item.iCategory); CGlobalVariable::filemgr.NewDownloadFile(item.strLinkText, strSaveDir, item.iCategory); // modified by vc-yavey 20100507 : 保存到指定目录 <end> // modifyed by vc-yavey on 2010-5-6 <begin> // 避免订阅时跳来跳去(此函数只在电驴更新和订阅时使用) /* CCmdGotoPage cmdGotoPage; if(thePrefs.bringtoforeground == 1) cmdGotoPage.GotoDownloading(); */ // modifyed by vc-yavey on 2010-5-6 <end> break; } SAFE_DELETE(pLink); // m_doc.SetItem(key, item); return pPartFile; } } else if (tcsPrefix.CollateNoCase(_T("http")) == 0) { int iState = CGlobalVariable::filemgr.GetUrlTaskState(lpszUrl); CString strPrompt; CString strFileName; m_uAddState = 1; for (POSITION pos = pQueue->filelist.GetHeadPosition();pos != 0;) { CPartFile* cur_file = pQueue->filelist.GetNext(pos); if (cur_file->GetPartFileURL().CompareNoCase(lpszUrl) == 0) { pPartFile = cur_file; break; } } switch (iState) { case FILESTATE_DOWNLOADING: strFileName = CGlobalVariable::filemgr.GetUrlFileName(lpszUrl); strPrompt = GetResString(IDS_TASK_IN_DOWNLOADING); strPrompt += strFileName; CGlobalVariable::ShowNotifier(strPrompt,TBN_IMPORTANTEVENT); break; case FILESTATE_COMPLETED: case FILESTATE_HASH: case FILESTATE_LOCAL_SHARE: strFileName = CGlobalVariable::filemgr.GetUrlFileName(lpszUrl); strPrompt = GetResString(IDS_ALREADY_DOWNLOAD); strPrompt += strFileName; CGlobalVariable::ShowNotifier(strPrompt,TBN_IMPORTANTEVENT); break; case FILESTATE_DOWNLOADED_SHARE: case FILESTATE_SHARE_TASK_DELED: case FILESTATE_DELETED: case FILESTATE_ZEROSIZE_DOWNLOADED: /* strFileName = CGlobalVariable::filemgr.GetUrlFileName(lpszUrl); strPrompt = GetResString(IDS_DOWN_DELED_LINKS); strPrompt += strFileName; break; if(IDNO == MessageBox(strPrompt,GetResString(IDS_CAPTION),MB_YESNO)) break; */ case FILESTATE_NOT_EXIST: // modified by vc-yavey 20100507 : 保存到指定目录 <begin> //CmdFuncs::ActualllyAddUrlDownload(lpszUrl,thePrefs.GetMuleDirectory(EMULE_INCOMINGDIR)); CmdFuncs::ActualllyAddUrlDownload(lpszUrl, strSaveDir); // modified by vc-yavey 20100507 : 保存到指定目录 <end> // modifyed by vc-yavey on 2010-5-6 <begin> // 避免订阅时跳来跳去(此函数只在电驴更新和订阅时使用) /* CCmdGotoPage cmdGotoPage; if(thePrefs.bringtoforeground == 1) cmdGotoPage.GotoDownloading(); */ // modifyed by vc-yavey on 2010-5-6 <end> break; } //m_doc.AppendUrl(lpszUrl); return pPartFile; } return pPartFile; }