int Search(const SStringT & strKey,SStudentSearchAdapter *pSearchAdapter) { if(strKey.IsEmpty()) return 0; for(UINT i=0;i<m_stuCurrent.GetCount();i++) { SStringT str = SStringT().Format(_T("%s(%u)"),m_stuCurrent[i].strNick,m_stuCurrent[i].imid); if(str.Find(strKey)!=-1) { SStudentSearchAdapter::StudentInfo2 info; info.strText = str; info.bExpired = FALSE; info.nPos = i; pSearchAdapter->m_searchResult.Add(info); } } for(UINT i=0;i<m_stuExpired.GetCount();i++) { SStringT str = SStringT().Format(_T("%s(%u)"),m_stuExpired[i].strNick,m_stuExpired[i].imid); if(str.Find(strKey)!=-1) { SStudentSearchAdapter::StudentInfo2 info; info.strText = str; info.bExpired = TRUE; info.nPos = i; pSearchAdapter->m_searchResult.Add(info); } } return pSearchAdapter->m_searchResult.GetCount(); }
virtual void getView(int position, SWindow * pItem, pugi::xml_node xmlTemplate) { int nViewType = getItemViewType(position); if(pItem->GetChildrenCount() == 0) { pugi::xml_node xmlItem; switch(nViewType) { case VT_GROUP: xmlItem = xmlTemplate.child(L"item_group");break; case VT_DATA: xmlItem = xmlTemplate.child(L"item_data");break; } pItem->InitFromXml(xmlItem); } if(nViewType == VT_GROUP) { SToggle * pSwitch=pItem->FindChildByID2<SToggle>(R.id.tgl_tv_expand); pSwitch->SetToggle(position==0?m_bCurrentExpand:m_bExpiredExpand); pSwitch->GetEventSet()->subscribeEvent(EVT_CMD,Subscriber(&CStudentAdapter::OnBtnGroupExpand,this)); pItem->FindChildByID(R.id.txt_group)->SetWindowText(TR(GETSTRING(position==0?R.string.current_student:R.string.expired_student),L"")); pItem->GetEventSet()->subscribeEvent(EVT_ITEMPANEL_DBCLICK,Subscriber(&CStudentAdapter::OnGroupDblClick,this)); SCheckBox *pGroupCheck = pItem->FindChildByID2<SCheckBox>(R.id.chk_select_group); pGroupCheck->GetEventSet()->subscribeEvent(EVT_STATECHANGED,Subscriber(&CStudentAdapter::OnGroupSelectCheckChanged,this)); pGroupCheck->GetEventSet()->setMutedState(true); pGroupCheck->SetCheck(position==0?m_bAllCurrentChecked:m_bAllExpiredChecked); pGroupCheck->GetEventSet()->setMutedState(false); }else { int nBaseCurrent = 1; int nBaseExpired = 1 + (m_bCurrentExpand?m_stuCurrent.GetCount():0) + 1; if(position< nBaseExpired) {//current student StudentInfo & stuInfo = m_stuCurrent[position-nBaseCurrent]; SCheckBox *pCheckBox = pItem->FindChildByID2<SCheckBox>(R.id.txt_nick); pCheckBox->GetEventSet()->subscribeEvent(EVT_STATECHANGED,Subscriber(&CStudentAdapter::OnStudentCheckChanged,this)); pCheckBox->GetEventSet()->setMutedState(true); pCheckBox->SetCheck(stuInfo.bChecked); pCheckBox->GetEventSet()->setMutedState(false); pCheckBox->SetWindowText(SStringT().Format(_T("%s(%u)"),stuInfo.strNick,stuInfo.imid)); pItem->FindChildByID(R.id.txt_loyal_degree)->SetWindowText(SStringT().Format(_T("%d"),stuInfo.nLoyalDegree)); pItem->FindChildByID(R.id.txt_time_span)->SetWindowText(stuInfo.tm1.Format(_T("%Y/%m/%d") + SStringT(_T(" - ")) + stuInfo.tm2.Format(_T("%Y/%m/%d")))); }else {//expired student StudentInfo & stuInfo = m_stuExpired[position-nBaseExpired]; SCheckBox *pCheckBox = pItem->FindChildByID2<SCheckBox>(R.id.txt_nick); pCheckBox->GetEventSet()->subscribeEvent(EVT_STATECHANGED,Subscriber(&CStudentAdapter::OnStudentCheckChanged,this)); pCheckBox->GetEventSet()->setMutedState(true); pCheckBox->SetCheck(stuInfo.bChecked); pCheckBox->GetEventSet()->setMutedState(false); pCheckBox->SetWindowText(SStringT().Format(_T("%s(%u)"),stuInfo.strNick,stuInfo.imid)); pItem->FindChildByID(R.id.txt_loyal_degree)->SetWindowText(SStringT().Format(_T("%d"),stuInfo.nLoyalDegree)); pItem->FindChildByID(R.id.txt_time_span)->SetWindowText(stuInfo.tm1.Format(_T("%Y/%m/%d") + SStringT(_T(" - ")) + stuInfo.tm2.Format(_T("%Y/%m/%d")))); } } }
bool CFolderScanHandler::OnTreeDbclick(EventArgs *pEvt) { EventTCDbClick *pEvt2 = sobj_cast<EventTCDbClick>(pEvt); pEvt2->bCancel = TRUE; HSTREEITEM hItem = pEvt2->hItem; HSTREEITEM hRoot = m_pTreelist->GetFolderTreeCtrl()->GetRootItem(); SStringT strPath; while(hItem != hRoot) { SStringT strItem; m_pTreelist->GetFolderTreeCtrl()->GetItemText(hItem,strItem); strPath = strItem + _T("\\") + strPath; hItem = m_pTreelist->GetFolderTreeCtrl()->GetParentItem(hItem); } SWindow *pEditDir = m_pPageRoot->FindChildByName(L"edit_dir"); SStringT strRoot = pEditDir->GetWindowText(); strPath = strRoot + _T("\\") + strPath; SStringT strCmd = SStringT().Format(_T("/select, %s"),strPath); ShellExecute( NULL, _T("open"), _T("explorer.exe"), strCmd, NULL, SW_SHOWNORMAL ); return true; }
void CStudentSmsDlg::OnSmsInputNotify(EventArgs *e) { EventRENotify *e2 = sobj_cast<EventRENotify>(e); if(e2->iNotify != EN_CHANGE) return; SEdit *pEdit = sobj_cast<SEdit>(e->sender); int nLen = pEdit->GetWindowTextLength(); SWindow *pWordCount = FindChildByID(R.id.txt_wordcount); pWordCount->SetWindowText(SStringT().Format(_T("%d"),nLen)); pWordCount->EnableWindow(nLen<100,TRUE); }
void SMaskEdit::InsertCharAt(int nPos, TCHAR nChar) { ASSERT(PosInRange(nPos)); if (!PosInRange(nPos)) return; SStringT strMaskedText = SStringT(nChar) + GetMaskedText(nPos); SetMaskedText(strMaskedText, nPos, FALSE); }
void SSpinButtonCtrl::OnValueChanged() { SWindow *pBuddy = GetParent()->FindChildByName(m_strBuddy); if(pBuddy) { EventSpinValue2String evt(this); evt.nValue = m_nValue; evt.strValue = SStringT().Format(_T("%d"),m_nValue); FireEvent(evt); pBuddy->SetWindowText(evt.strValue); } }
void SDesktopDock::OnLButtonUp(UINT nFlags, CPoint point) { for (int i=0; i<MAX_COUNT; i++) { if (m_RTRect[i].PtInRect(point)) { SMessageBox(NULL,SStringT().Format(_T("索引===%d号"),i),_T("多点WIFI"),MB_OK); ShellExecute(NULL, _T("open"),adUrls[i], NULL, NULL, SW_SHOWNORMAL); return ; } } }
int SMCTreeCtrl::InsertColumn(int iCol,int nWid) { if(iCol < 0) iCol = m_arrColWidth.GetCount(); m_arrColWidth.InsertAt(iCol,nWid); HSTREEITEM hItem = GetRootItem(); while(hItem) { MCITEM *pMcItem = (MCITEM*)STreeCtrl::GetItemData(hItem); pMcItem->arrText.InsertAt(iCol,SStringT()); hItem = GetNextItem(hItem); } m_nItemWid = -1; CalcItemWidth(0); CSize szView = GetViewSize(); szView.cx = m_nItemWid; SetViewSize(szView); Invalidate(); return iCol; }
void CCodeLineCounterHandler::OnBtnGo() { if(m_strDir.IsEmpty()) { SMessageBox(m_pPageRoot->GetContainer()->GetHostHwnd(),_T("没有指定扫描目录"),_T("错误"),MB_OK|MB_ICONSTOP); return; } SStringT strTypes = m_pPageRoot->FindChildByName(L"edit_filetypes")->GetWindowText(); SStringWList lstTypes; SplitString(S_CT2W(strTypes),L';',lstTypes); CODECFGMAP cfg; for(UINT i=0;i<lstTypes.GetCount();i++) { CODECFGMAP::CPair *pPair = m_mapCodeCfg.Lookup(lstTypes[i]); if(!pPair) continue; cfg[lstTypes[i]] = pPair->m_value; } if(cfg.IsEmpty()) { SMessageBox(m_pPageRoot->GetContainer()->GetHostHwnd(),_T("没有指定文件类型或者类型无效"),_T("错误"),MB_OK|MB_ICONSTOP); return; } //获得文件列表,计每个目标文件的文件大小 HSTREEITEM hRoot = m_pDirTree->GetRootItem(); SList<FILEINFO> lstFileInfo; int nDirs = 1; DWORD szAll = EnumFileInfo(cfg,m_strDir,hRoot,lstFileInfo,nDirs); if(lstFileInfo.GetCount() == 0) { SMessageBox(m_pPageRoot->GetContainer()->GetHostHwnd(),_T("指定的目录下没有找到满足条件的文件类型"),_T("提示"),MB_OK|MB_ICONINFORMATION); return; } //SWindow *pPageResult = m_pPageRoot->FindChildByName(L"page_dir"); SSplitWnd_Row *pSplitTree = m_pPageRoot->FindChildByName2<SSplitWnd_Row>(L"split_tree"); pSplitTree->ShowPane(1); SProgress *pProgBar = pSplitTree->FindChildByName2<SProgress>(L"prog_run"); pProgBar->SetRange(0,szAll); pProgBar->SetValue(0); CLineInfo lineInfoAll; SMap<SStringW,CLineInfo> mapLineInfo; for(UINT i=0;i<lstTypes.GetCount();i++) { mapLineInfo[lstTypes[i]] = CLineInfo(); } //统计代码行 DWORD dwProg = 0; SPOSITION pos = lstFileInfo.GetHeadPosition(); while(pos) { FILEINFO fi = lstFileInfo.GetNext(pos); CLineInfo lineInfo; CountCodeLines(S_CW2T(fi.strFileName),fi.cfg,lineInfo.nCodeLines,lineInfo.nRemarkLines,lineInfo.nBlankLines); lineInfoAll += lineInfo; mapLineInfo[fi.cfg.strExt] += lineInfo; dwProg += fi.dwSize; pProgBar->SetValue(dwProg); pProgBar->UpdateWindow(); } pSplitTree->HidePane(1); STabCtrl *pTab = m_pPageRoot->FindChildByName2<STabCtrl>(L"tab_codeline"); pTab->SetCurSel(1); SWindow *pWndRes = pTab->GetPage(_T("page_result"),FALSE); pWndRes->FindChildByName(L"txt_folders")->SetWindowText(SStringT().Format(_T("%d"),nDirs)); pWndRes->FindChildByName(L"txt_files")->SetWindowText(SStringT().Format(_T("%d"),lstFileInfo.GetCount())); pWndRes->FindChildByName(L"txt_codelines")->SetWindowText(SStringT().Format(_T("%d"),lineInfoAll.nCodeLines)); pWndRes->FindChildByName(L"txt_blanklines")->SetWindowText(SStringT().Format(_T("%d"),lineInfoAll.nBlankLines)); pWndRes->FindChildByName(L"txt_remarklines")->SetWindowText(SStringT().Format(_T("%d"),lineInfoAll.nRemarkLines)); SListCtrl *plstReport = pWndRes->FindChildByName2<SListCtrl>(L"lst_linecounter_report"); plstReport->DeleteAllItems(); for(UINT i=0;i<lstTypes.GetCount();i++) { CCodeConfig codeCfg = cfg[lstTypes[i]]; CLineInfo lineInfo = mapLineInfo[lstTypes[i]]; plstReport->InsertItem(i,S_CW2T(codeCfg.strType)); plstReport->SetSubItemText(i,1,S_CW2T(codeCfg.strExt)); plstReport->SetSubItemText(i,2,SStringT().Format(_T("%d"),lineInfo.nCodeLines)); plstReport->SetSubItemText(i,3,SStringT().Format(_T("%d"),lineInfo.nBlankLines)); plstReport->SetSubItemText(i,4,SStringT().Format(_T("%d"),lineInfo.nRemarkLines)); } }
void CStudentSmsDlg::OnStudentCheckChanged(int nSelCurrent, int nSelExpired) { FindChildByID(R.id.txt_sms_checked_num)->SetWindowText(SStringT().Format(_T("%d"),nSelCurrent + nSelExpired)); }
void CMainDlg::OnFileTypeRadioSwitch(int nID) { SMessageBox(NULL, SStringT().Format(L"Change to %s", ft_str[nID - 20000]), L"File type", MB_OK); }
SStringT SMessageBoxImpl::OnGetButtonText(int nBtnID) const { return SStringT(); }