CString CFGFilterLAV::GetVersion(LAVFILTER_TYPE filterType /*= INVALID*/) { CStringList paths; if (filterType == INVALID) { paths.AddTail(GetFilterPath(SPLITTER)); paths.AddTail(GetFilterPath(VIDEO_DECODER)); paths.AddTail(GetFilterPath(AUDIO_DECODER)); } else { paths.AddTail(GetFilterPath(filterType)); } QWORD uiVersionMin = UINT64_MAX; QWORD uiVersionMax = 0ui64; CString strVersionMin, strVersionMax; POSITION pos = paths.GetHeadPosition(); while (pos) { CString& path = paths.GetNext(pos); QWORD version = CFileVersionInfo::GetFileVersionNum(path); if (version) { if (version < uiVersionMin) { uiVersionMin = version; strVersionMin = CFileVersionInfo::GetFileVersionStr(path); } if (version > uiVersionMax) { uiVersionMax = version; strVersionMax = CFileVersionInfo::GetFileVersionStr(path); } } } CString version; if (uiVersionMin != UINT64_MAX) { version = strVersionMin; if (uiVersionMax != uiVersionMin) { version.AppendFormat(_T(" - %s"), strVersionMax); } } return version; }
CString GetValueFromList(const CString strName,CStringList& strList) { POSITION pos=NULL; pos=strList.GetHeadPosition(); int nIndex=0; CString strItem=_T(""); CString strValue=_T(""); while(pos!=NULL) { strItem=strList.GetNext(pos); nIndex=strItem.Find("="); strValue=strItem.Left(nIndex); if (strValue==strName) { strValue=strItem.Right(strItem.GetLength()-nIndex-1); return strValue; } } return ""; }
// String matching static CString FindUniqueSubstring(const CStringList &list, const CString &value, bool initial = false, bool exact = false) { // Compare lower case strings for case insensitivity CString substring = value; substring.MakeLower(); CString match; for (POSITION pos = list.GetHeadPosition(); pos;) { CString entry = list.GetNext(pos); entry.MakeLower(); int found = entry.Find(substring); if ((initial ? found == 0 : 0 <= found) && (!exact || (entry.GetLength() == substring.GetLength()))) { if (!match.IsEmpty()) return _T(""); match = entry; } } return match; }
//Parse script into commands and parameters void CScriptParser::ParseScript(CString &script) { //Strip off Windows return characters script.Remove('\r'); //Separate script into separate lines in a list CStringList commandLineList; CScriptParser::StringSplit(commandLineList, script, CString('\n')); //For each command line, split out keyword and parameters POSITION pos; for(pos = commandLineList.GetHeadPosition(); pos != NULL;) { CommandLine command; CString line = commandLineList.GetNext(pos); int firstSpacePos = line.Find(' '); if(firstSpacePos != -1 && firstSpacePos != 0) { command.keyword = line.Left(firstSpacePos); command.params = line.Right(line.GetLength() - firstSpacePos - 1); } else { command.keyword = line; command.params.Empty(); } m_CommandLines.AddTail(command); } // Debug /* for( pos = m_CommandLines.GetHeadPosition(); pos != NULL; ) { CommandLine cmdLine = m_CommandLines.GetNext( pos ); CString str = CString("keyword: \"") + cmdLine.keyword + CString("\""); str = str + CString("\nparams: \"") + cmdLine.params + CString("\""); AfxMessageBox(str); } */ }
bool CSharedDirsTreeCtrl::FilterTreeIsSubDirectory(CString strDir, CString strRoot, CStringList& liDirs){ POSITION pos = liDirs.GetHeadPosition(); strRoot.MakeLower(); strDir.MakeLower(); if (strDir.Right(1) != _T("\\")){ strDir += _T("\\"); } if (strRoot.Right(1) != _T("\\")){ strRoot += _T("\\"); } while (pos){ CString strCurrent = thePrefs.shareddir_list.GetNext(pos); strCurrent.MakeLower(); if (strCurrent.Right(1) != _T("\\")){ strCurrent += _T("\\"); } if (strRoot.Find(strCurrent, 0) != 0 && strDir.Find(strCurrent, 0) == 0 && strCurrent != strRoot && strCurrent != strDir) return true; } return false; }
BOOL CWizWelcomePage::OnInitDialog() { CNGWizardPage::OnInitDialog(); VERIFY(font1.CreateFont( 24, // nHeight 0, // nWidth 0, // nEscapement 0, // nOrientation FW_BOLD, // nWeight FALSE, // bItalic FALSE, // bUnderline 0, // cStrikeOut ANSI_CHARSET, // nCharSet OUT_DEFAULT_PRECIS, // nOutPrecision CLIP_DEFAULT_PRECIS, // nClipPrecision ANTIALIASED_QUALITY, // nQuality DEFAULT_PITCH | FF_SWISS, // nPitchAndFamily _T("Arial"))); // lpszFacename m_wndTitle.SetFont(&font1); CStringList languages; GetLanguageFiles(languages); for(POSITION pos=languages.GetHeadPosition();pos!=NULL;) m_wndLanguage.AddString(languages.GetNext(pos)); if(!m_szLanguage.IsEmpty()) m_wndLanguage.SelectString(-1, m_szLanguage); else m_wndLanguage.SetCurSel(0); m_wndLanguage.EnableWindow(m_bLanguage); TRANSLATE(*this, IDD); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }
BOOL CBCGPMenuPage::OnInitDialog() { { CBCGPLocalResource locaRes; CPropertyPage::OnInitDialog(); } if (m_iMenuAnimationType == (int) CBCGPPopupMenu::SYSTEM_DEFAULT_ANIMATION) { m_iMenuAnimationType = m_wndMenuAnimations.GetCount () - 1; UpdateData (FALSE); } POSITION pos = NULL; //---------------------------------------------------------- // Find application Menu Bar object (assume that only one): //--------------------------------------------------------- for (pos = gAllToolbars.GetHeadPosition (); m_pMenuBar == NULL && pos != NULL;) { CBCGPToolBar* pToolBar = (CBCGPToolBar*) gAllToolbars.GetNext (pos); ASSERT (pToolBar != NULL); if (CWnd::FromHandlePermanent (pToolBar->m_hWnd) != NULL) { ASSERT_VALID(pToolBar); m_pMenuBar = DYNAMIC_DOWNCAST (CBCGPMenuBar, pToolBar); } } if (m_pMenuBar != NULL) { m_pMenuBar->m_pMenuPage = this; int iCurrMenu = -1; //--------------------------- // Save MenuBar current menu: //--------------------------- m_hmenuCurr = m_pMenuBar->GetHMenu (); m_pMenuBar->OnChangeHot (-1); g_menuHash.SaveMenuBar (m_hmenuCurr, m_pMenuBar); //------------------------------------------------------------------- // Find all application document templates and fill menues combobox // by document template data: //------------------------------------------------------------------ CDocManager* pDocManager = AfxGetApp ()->m_pDocManager; if (m_bAutoSet && pDocManager != NULL) { POSITION pos = NULL; //--------------------------------------- // Walk all templates in the application: //--------------------------------------- for (pos = pDocManager->GetFirstDocTemplatePosition (); pos != NULL;) { CBCGPMultiDocTemplate* pTemplate = (CBCGPMultiDocTemplate*) pDocManager->GetNextDocTemplate (pos); ASSERT_VALID (pTemplate); ASSERT_KINDOF (CDocTemplate, pTemplate); //----------------------------------------------------- // We are interessing CMultiDocTemplate objects with // the shared menu only.... //----------------------------------------------------- if (!pTemplate->IsKindOf (RUNTIME_CLASS (CMultiDocTemplate)) || pTemplate->m_hMenuShared == NULL) { continue; } //---------------------------------------------------- // Maybe, the template with same ID is already exist? //---------------------------------------------------- BOOL bIsAlreadyExist = FALSE; for (int i = 0; !bIsAlreadyExist && i < m_wndMenuesList.GetCount (); i++) { CBCGPMultiDocTemplate* pListTemplate = (CBCGPMultiDocTemplate*) m_wndMenuesList.GetItemData (i); bIsAlreadyExist = pListTemplate != NULL && pListTemplate->GetResId () == pTemplate->GetResId (); } if (!bIsAlreadyExist) { CString strName; pTemplate->GetDocString (strName, CDocTemplate::fileNewName); int iIndex = m_wndMenuesList.AddString (strName); m_wndMenuesList.SetItemData (iIndex, (DWORD_PTR) pTemplate); if (pTemplate->m_hMenuShared == m_hmenuCurr) { iCurrMenu = iIndex; } } } } //-------------------------- // Add a default frame menu: //-------------------------- CString strName; { CBCGPLocalResource locaRes; strName.LoadString (IDS_BCGBARRES_DEFUALT_MENU); } int iIndex = m_wndMenuesList.AddString (strName); m_wndMenuesList.SetItemData (iIndex, (DWORD_PTR) NULL); if (iCurrMenu == -1) { m_bIsDefaultMDIMenu = TRUE; iCurrMenu = iIndex; } m_hmenuSelected = m_hmenuCurr; m_wndMenuesList.SetCurSel (iCurrMenu); UpdateData (FALSE); OnSelchangeMenuList (); } else { //------------------------------------------------- // No menubar found, disable menu selecting engine: //------------------------------------------------- m_wndMenuesList.EnableWindow (FALSE); GetDlgItem(IDC_BCGBARRES_RESET_FRAME_MENU)->EnableWindow(FALSE); CBCGPLocalResource locaRes; m_strMenuDescr.LoadString (IDS_BCGBARRES_NO_MENUBAR); UpdateData (FALSE); } //-------------------------- // Initialize context menus: //-------------------------- { CBCGPLocalResource locaRes; CString strNoContextMenu; strNoContextMenu.LoadString (IDS_BCGBARRES_NO_CONTEXT); m_wndContextMenus.AddString (strNoContextMenu); m_wndContextMenus.SetCurSel (0); } if (g_pContextMenuManager != NULL) { CStringList listOfNames; g_pContextMenuManager->GetMenuNames (listOfNames); for (pos = listOfNames.GetHeadPosition (); pos != NULL;) { CString strName = listOfNames.GetNext (pos); m_wndContextMenus.AddString (strName); } m_wndContextMenuCaption.EnableWindow (m_wndContextMenus.GetCount () > 1); m_wndContextMenus.EnableWindow (m_wndContextMenus.GetCount () > 1); } else { //------------------------------- // Hide all context menus fields: //------------------------------- m_wndContextMenuCaption.ShowWindow (SW_HIDE); m_wndContextMenus.ShowWindow (SW_HIDE); m_wndContextHint.ShowWindow (SW_HIDE); m_wndContextFrame.ShowWindow (SW_HIDE); m_wndResetMenuButton.ShowWindow (SW_HIDE); } CBCGPToolbarCustomize* pWndParent = DYNAMIC_DOWNCAST (CBCGPToolbarCustomize, GetParent ()); ASSERT (pWndParent != NULL); if ((pWndParent->GetFlags () & BCGCUSTOMIZE_MENU_SHADOWS) == 0) { m_wndMenuShadows.ShowWindow (SW_HIDE); } if ((pWndParent->GetFlags () & BCGCUSTOMIZE_MENU_ANIMATIONS) == 0) { m_wndMenuAnimationsLabel.ShowWindow (SW_HIDE); m_wndMenuAnimations.ShowWindow (SW_HIDE); } return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }
BOOL CVersionInfo::FromFile(const CString &strModulePath, LPCTSTR lpszResourceId, WORD wLangId) { CVersionInfoBuffer viLoadBuf; m_wLangId = wLangId; m_lpszResourceId = (LPTSTR)lpszResourceId; //LoadVersionInfoResource will update member variables m_wLangId, m_lpszResourceId, which is awkward, need to change this flow if (!LoadVersionInfoResource(strModulePath, viLoadBuf, lpszResourceId, wLangId)) return FALSE; m_strModulePath = strModulePath; DWORD dwSize = viLoadBuf.GetPosition(); VERSION_INFO_HEADER* pVI = (VERSION_INFO_HEADER*) viLoadBuf.GetData(); ASSERT(!wcscmp(pVI->szKey, L"VS_VERSION_INFO")); VS_FIXEDFILEINFO* pFixedInfo = (VS_FIXEDFILEINFO*)DWORDALIGN(&pVI->szKey[wcslen(pVI->szKey)+1]); memcpy(&m_vsFixedFileInfo, pFixedInfo, sizeof(VS_FIXEDFILEINFO)); // Iterate children StringFileInfo or VarFileInfo BaseFileInfo *pChild = (BaseFileInfo*) DWORDALIGN((DWORD)pFixedInfo + pVI->wValueLength); BOOL bHasVar = FALSE; BOOL bHasStrings = FALSE; BOOL bBlockOrderKnown = FALSE; CStringList lstTranslations; while ((DWORD)pChild < ((DWORD)(pVI) + pVI->wLength)) { if (!wcscmp(pChild->szKey, L"StringFileInfo")) { //It is a StringFileInfo //ASSERT(1 == pChild->wType); //如果类型是0表示二进制内容,类型为1时才包含字符串内容 if (1 != pChild->wType) { //pChild = (BaseFileInfo*)DWORDALIGN((DWORD)pChild + pChild->wLength); //continue; } StringFileInfo* pStringFI = (StringFileInfo*)pChild; ASSERT(!pStringFI->wValueLength); //MSDN says: Specifies an array of zero or one StringFileInfo structures. So there should be only one StringFileInfo at most ASSERT(m_stringFileInfo.IsEmpty()); m_stringFileInfo.FromStringFileInfo(pStringFI); bHasStrings = TRUE; } else { VarFileInfo* pVarInfo = (VarFileInfo*)pChild; //ASSERT(1 == pVarInfo->wType); //如果类型是0表示二进制内容,类型为1时才包含字符串内容 if (1 != pChild->wType) { //pChild = (BaseFileInfo*)DWORDALIGN((DWORD)pChild + pChild->wLength); //continue; } ASSERT(!wcscmp(pVarInfo->szKey, L"VarFileInfo")); ASSERT(!pVarInfo->wValueLength); //Iterate Var elements //There really must be only one Var* pVar = (Var*) DWORDALIGN(&pVarInfo->szKey[wcslen(pVarInfo->szKey)+1]); while ((DWORD)pVar < ((DWORD) pVarInfo + pVarInfo->wLength)) { ASSERT(!bHasVar && "Multiple Vars in VarFileInfo"); ASSERT(!wcscmp(pVar->szKey, L"Translation")); ASSERT(pVar->wValueLength); DWORD *pValue = (DWORD*) DWORDALIGN(&pVar->szKey[wcslen(pVar->szKey)+1]); DWORD *pdwTranslation = pValue; while ((LPBYTE)pdwTranslation < (LPBYTE)pValue + pVar->wValueLength) { CString strStringTableKey; strStringTableKey.Format(_T("%04x%04x"), LOWORD(*pdwTranslation), HIWORD(*pdwTranslation)); lstTranslations.AddTail(strStringTableKey); pdwTranslation++; } bHasVar = TRUE; pVar = (Var*) DWORDALIGN((DWORD)pVar + pVar->wLength); } ASSERT(bHasVar && "No Var in VarFileInfo"); } if (!bBlockOrderKnown) { bBlockOrderKnown = TRUE; m_bRegularInfoOrder = bHasStrings; } pChild = (BaseFileInfo*) DWORDALIGN((DWORD)pChild + pChild->wLength); } #ifdef _DEBUG ASSERT((DWORD)lstTranslations.GetCount() == m_stringFileInfo.GetStringTableCount()); CString strKey = m_stringFileInfo.GetFirstStringTable().GetKey(); POSITION posTranslation = lstTranslations.GetHeadPosition(); while (posTranslation) { CString strTranslation = lstTranslations.GetNext(posTranslation); CString strTranslationUpper (strTranslation); strTranslation.MakeUpper(); ASSERT(m_stringFileInfo.HasStringTable(strTranslation) || m_stringFileInfo.HasStringTable(strTranslationUpper)); } //Verify Write CVersionInfoBuffer viSaveBuf; Write(viSaveBuf); ASSERT(viSaveBuf.GetPosition() == viLoadBuf.GetPosition()); ASSERT(!memcmp(viSaveBuf.GetData(), viLoadBuf.GetData(), viSaveBuf.GetPosition())); CFile fOriginal(_T("f1.res"), CFile::modeCreate | CFile::modeWrite); fOriginal.Write(viLoadBuf.GetData(), viLoadBuf.GetPosition()); fOriginal.Close(); CFile fSaved(_T("f2.res"), CFile::modeCreate | CFile::modeWrite); fSaved.Write(viSaveBuf.GetData(), viSaveBuf.GetPosition()); fSaved.Close(); #endif return TRUE; }
void CMusikSourcesCtrl::DoDrag( CMusikPropTreeItem* pItem ) { if ( !pItem ) return; COleDataSource datasrc; HGLOBAL hgDrop; DROPFILES* pDrop; CStringList lsDraggedFiles; POSITION pos; CString sFile; UINT uBuffSize = 0; TCHAR* pszBuff; FORMATETC etc = { CF_HDROP, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL }; // get a list of filenames with the currently // selected items... CStdStringArray files; int nMode = pItem->GetPlaylistType(); // standard playlist dragged if ( nMode == MUSIK_PLAYLIST_TYPE_STANDARD ) m_Library->GetStdPlaylistFns( pItem->GetPlaylistID(), files, false ); // now playing dragged.. else if ( nMode == MUSIK_SOURCES_TYPE_NOWPLAYING ) { if ( m_Player->GetPlaylist() ) { m_Library->BeginTransaction(); for ( size_t i = 0; i < m_Player->GetPlaylist()->GetCount(); i++ ) files.push_back( m_Player->GetPlaylist()->GetField( i, MUSIK_LIBRARY_TYPE_FILENAME ) ); m_Library->EndTransaction(); } } // library playlist dragged else if ( nMode == MUSIK_SOURCES_TYPE_LIBRARY ) { CMainFrame* pMain = (CMainFrame*)m_Parent; if ( pMain->m_LibPlaylist ) { m_Library->BeginTransaction(); for ( size_t i = 0; i < pMain->m_LibPlaylist->GetCount(); i++ ) files.push_back( pMain->m_LibPlaylist->GetField( i, MUSIK_LIBRARY_TYPE_FILENAME ) ); m_Library->EndTransaction(); } } else if ( nMode == MUSIK_PLAYLIST_TYPE_DYNAMIC ) MessageBox( "This operation is not supported yet.", "Musik", MB_ICONINFORMATION | MB_OK ); if ( !files.size() ) return; // CStringList containing files for ( size_t i = 0; i < files.size(); i++ ) { lsDraggedFiles.AddTail( files.at( i ) ); uBuffSize += files.at( i ).GetLength() + 1; } files.clear(); // Add 1 extra for the final null char, and the size of the DROPFILES struct. uBuffSize = sizeof(DROPFILES) + sizeof(TCHAR) * (uBuffSize + 1); // Allocate memory from the heap for the DROPFILES struct. hgDrop = GlobalAlloc ( GHND | GMEM_SHARE, uBuffSize ); if ( !hgDrop ) return; pDrop = (DROPFILES*) GlobalLock ( hgDrop ); if ( !pDrop ) { GlobalFree ( hgDrop ); return; } // Fill in the DROPFILES struct. pDrop->pFiles = sizeof(DROPFILES); // If we're compiling for Unicode, set the Unicode flag in the struct to // indicate it contains Unicode strings. #ifdef _UNICODE pDrop->fWide = TRUE; #endif; // Copy all the filenames into memory after the end of the DROPFILES struct. pos = lsDraggedFiles.GetHeadPosition(); pszBuff = (TCHAR*) (LPBYTE(pDrop) + sizeof(DROPFILES)); while ( pos ) { lstrcpy ( pszBuff, (LPCTSTR) lsDraggedFiles.GetNext ( pos ) ); pszBuff = 1 + _tcschr ( pszBuff, '\0' ); } GlobalUnlock ( hgDrop ); // Put the data in the data source. datasrc.CacheGlobalData ( CF_HDROP, hgDrop, &etc ); // Add in our own custom data, so we know that the drag originated from our // window. CMyDropTarget::DragEnter() checks for this custom format, and // doesn't allow the drop if it's present. This is how we prevent the user // from dragging and then dropping in our own window. // The data will just be a dummy bool. HGLOBAL hgBool; hgBool = GlobalAlloc ( GHND | GMEM_SHARE, sizeof(bool) ); if ( NULL == hgBool ) { GlobalFree ( hgDrop ); return; } // Put the data in the data source. etc.cfFormat = m_DropID; datasrc.CacheGlobalData ( m_DropID, hgBool, &etc ); // Start the drag 'n' drop! DROPEFFECT dwEffect = datasrc.DoDragDrop ( DROPEFFECT_COPY | DROPEFFECT_MOVE ); // If the DnD completed OK, we remove all of the dragged items from our // list. switch ( dwEffect ) { case DROPEFFECT_COPY: case DROPEFFECT_MOVE: { // the copy completed successfully // do whatever we need to do here TRACE0( "DND from playlist completed successfully. The data has a new owner.\n" ); } break; case DROPEFFECT_NONE: { // This needs special handling, because on NT, DROPEFFECT_NONE // is returned for move operations, instead of DROPEFFECT_MOVE. // See Q182219 for the details. // So if we're on NT, we check each selected item, and if the // file no longer exists, it was moved successfully and we can // remove it from the list. if ( m_IsWinNT ) { // the copy completed successfully // on a windows nt machine. // do whatever we need to do here bool bDeletedAnything = false; if ( ! bDeletedAnything ) { // The DnD operation wasn't accepted, or was canceled, so we // should call GlobalFree() to clean up. GlobalFree ( hgDrop ); GlobalFree ( hgBool ); TRACE0( "DND had a problem. We had to manually free the data.\n" ); } } // not windows NT else { // We're on 9x, and a return of DROPEFFECT_NONE always means // that the DnD operation was aborted. We need to free the // allocated memory. GlobalFree ( hgDrop ); GlobalFree ( hgBool ); TRACE0( "DND had a problem. We had to manually free the data.\n" ); } } break; } }
LONG CuDlgReplicationStaticPageActivity::OnLoad (WPARAM wParam, LPARAM lParam) { LPCTSTR pClass = (LPCTSTR)wParam; ASSERT (lstrcmp (pClass, _T("CaReplicationStaticDataPageActivity")) == 0); CaReplicationStaticDataPageActivity* pData = (CaReplicationStaticDataPageActivity*)lParam; if (!pData) return 0L; POSITION p, pos = NULL; CStringList* pObj = NULL; try { m_strInputQueue = pData->m_strInputQueue; m_strDistributionQueue = pData->m_strDistributionQueue; m_strStartingTime = pData->m_strStartingTime; UpdateData (FALSE); // // Summary: // // For each column: const int LAYOUT_NUMBER = 6; for (int i=0; i<LAYOUT_NUMBER; i++) m_cListCtrl.SetColumnWidth(i, pData->m_cxSummary.GetAt(i)); int nCount = 0; pos = pData->m_listSummary.GetHeadPosition(); while (pos != NULL) { pObj = pData->m_listSummary.GetNext (pos); ASSERT (pObj); ASSERT (pObj->GetCount() == 6); nCount = m_cListCtrl.GetItemCount(); p = pObj->GetHeadPosition(); m_cListCtrl.InsertItem (nCount, (LPCTSTR)pObj->GetNext(p)); m_cListCtrl.SetItemText (nCount, 1, (LPCTSTR)pObj->GetNext(p)); m_cListCtrl.SetItemText (nCount, 2, (LPCTSTR)pObj->GetNext(p)); m_cListCtrl.SetItemText (nCount, 3, (LPCTSTR)pObj->GetNext(p)); m_cListCtrl.SetItemText (nCount, 4, (LPCTSTR)pObj->GetNext(p)); m_cListCtrl.SetItemText (nCount, 5, (LPCTSTR)pObj->GetNext(p)); } m_cListCtrl.SetScrollPos (SB_HORZ, pData->m_scrollSummary.cx); m_cListCtrl.SetScrollPos (SB_VERT, pData->m_scrollSummary.cy); CuListCtrl* pList = NULL; // // Per database (Outgoing): m_pDatabaseOutgoing->SetAllColumnWidth (pData->m_cxDatabaseOutgoing); pList = &(m_pDatabaseOutgoing->m_cListCtrl); pos = pData->m_listDatabaseOutgoing.GetHeadPosition(); while (pos != NULL) { pObj = pData->m_listDatabaseOutgoing.GetNext (pos); ASSERT (pObj); ASSERT (pObj->GetCount() == 6); nCount = pList->GetItemCount(); p = pObj->GetHeadPosition(); pList->InsertItem (nCount, (LPCTSTR)pObj->GetNext(p)); pList->SetItemText (nCount, 1, (LPCTSTR)pObj->GetNext(p)); pList->SetItemText (nCount, 2, (LPCTSTR)pObj->GetNext(p)); pList->SetItemText (nCount, 3, (LPCTSTR)pObj->GetNext(p)); pList->SetItemText (nCount, 4, (LPCTSTR)pObj->GetNext(p)); pList->SetItemText (nCount, 5, (LPCTSTR)pObj->GetNext(p)); } m_pDatabaseOutgoing->SetScrollPosListCtrl (pData->m_scrollDatabaseOutgoing); // // Per database (Incoming): m_pDatabaseIncoming->SetAllColumnWidth (pData->m_cxDatabaseIncoming); pList = &(m_pDatabaseIncoming->m_cListCtrl); pos = pData->m_listDatabaseIncoming.GetHeadPosition(); while (pos != NULL) { pObj = pData->m_listDatabaseIncoming.GetNext (pos); ASSERT (pObj); ASSERT (pObj->GetCount() == 6); nCount = pList->GetItemCount(); p = pObj->GetHeadPosition(); pList->InsertItem (nCount, (LPCTSTR)pObj->GetNext(p)); pList->SetItemText (nCount, 1, (LPCTSTR)pObj->GetNext(p)); pList->SetItemText (nCount, 2, (LPCTSTR)pObj->GetNext(p)); pList->SetItemText (nCount, 3, (LPCTSTR)pObj->GetNext(p)); pList->SetItemText (nCount, 4, (LPCTSTR)pObj->GetNext(p)); pList->SetItemText (nCount, 5, (LPCTSTR)pObj->GetNext(p)); } m_pDatabaseIncoming->SetScrollPosListCtrl (pData->m_scrollDatabaseIncoming); // // Per database (Total): m_pDatabaseTotal->SetAllColumnWidth (pData->m_cxDatabaseTotal); pList = &(m_pDatabaseTotal->m_cListCtrl); pos = pData->m_listDatabaseTotal.GetHeadPosition(); while (pos != NULL) { pObj = pData->m_listDatabaseTotal.GetNext (pos); ASSERT (pObj); ASSERT (pObj->GetCount() == 6); nCount = pList->GetItemCount(); p = pObj->GetHeadPosition(); pList->InsertItem (nCount, (LPCTSTR)pObj->GetNext(p)); pList->SetItemText (nCount, 1, (LPCTSTR)pObj->GetNext(p)); pList->SetItemText (nCount, 2, (LPCTSTR)pObj->GetNext(p)); pList->SetItemText (nCount, 3, (LPCTSTR)pObj->GetNext(p)); pList->SetItemText (nCount, 4, (LPCTSTR)pObj->GetNext(p)); pList->SetItemText (nCount, 5, (LPCTSTR)pObj->GetNext(p)); } m_pDatabaseTotal->SetScrollPosListCtrl (pData->m_scrollDatabaseTotal); // // Per table (Outgoing): m_pTableOutgoing->SetAllColumnWidth (pData->m_cxTableOutgoing); pList = &(m_pTableOutgoing->m_cListCtrl); pos = pData->m_listTableOutgoing.GetHeadPosition(); while (pos != NULL) { pObj = pData->m_listTableOutgoing.GetNext (pos); ASSERT (pObj); ASSERT (pObj->GetCount() == 6); nCount = pList->GetItemCount(); p = pObj->GetHeadPosition(); pList->InsertItem (nCount, (LPCTSTR)pObj->GetNext(p)); pList->SetItemText (nCount, 1, (LPCTSTR)pObj->GetNext(p)); pList->SetItemText (nCount, 2, (LPCTSTR)pObj->GetNext(p)); pList->SetItemText (nCount, 3, (LPCTSTR)pObj->GetNext(p)); pList->SetItemText (nCount, 4, (LPCTSTR)pObj->GetNext(p)); pList->SetItemText (nCount, 5, (LPCTSTR)pObj->GetNext(p)); } m_pTableOutgoing->SetScrollPosListCtrl (pData->m_scrollTableOutgoing); // // Per table (Incoming): m_pTableIncoming->SetAllColumnWidth (pData->m_cxTableIncoming); pList = &(m_pTableIncoming->m_cListCtrl); pos = pData->m_listTableIncoming.GetHeadPosition(); while (pos != NULL) { pObj = pData->m_listTableIncoming.GetNext (pos); ASSERT (pObj); ASSERT (pObj->GetCount() == 6); nCount = pList->GetItemCount(); p = pObj->GetHeadPosition(); pList->InsertItem (nCount, (LPCTSTR)pObj->GetNext(p)); pList->SetItemText (nCount, 1, (LPCTSTR)pObj->GetNext(p)); pList->SetItemText (nCount, 2, (LPCTSTR)pObj->GetNext(p)); pList->SetItemText (nCount, 3, (LPCTSTR)pObj->GetNext(p)); pList->SetItemText (nCount, 4, (LPCTSTR)pObj->GetNext(p)); pList->SetItemText (nCount, 5, (LPCTSTR)pObj->GetNext(p)); } m_pTableIncoming->SetScrollPosListCtrl (pData->m_scrollTableIncoming); // // Per table (Total): m_pTableTotal->SetAllColumnWidth (pData->m_cxTableTotal); pList = &(m_pTableTotal->m_cListCtrl); pos = pData->m_listTableTotal.GetHeadPosition(); while (pos != NULL) { pObj = pData->m_listTableTotal.GetNext (pos); ASSERT (pObj); ASSERT (pObj->GetCount() == 6); nCount = pList->GetItemCount(); p = pObj->GetHeadPosition(); pList->InsertItem (nCount, (LPCTSTR)pObj->GetNext(p)); pList->SetItemText (nCount, 1, (LPCTSTR)pObj->GetNext(p)); pList->SetItemText (nCount, 2, (LPCTSTR)pObj->GetNext(p)); pList->SetItemText (nCount, 3, (LPCTSTR)pObj->GetNext(p)); pList->SetItemText (nCount, 4, (LPCTSTR)pObj->GetNext(p)); pList->SetItemText (nCount, 5, (LPCTSTR)pObj->GetNext(p)); } m_pTableTotal->SetScrollPosListCtrl (pData->m_scrollTableTotal); DisplayPage (pData->m_nCurrentPage); } catch (CMemoryException* e) { theApp.OutOfMemoryMessage(); e->Delete(); } return 0L; }
BOOL CWizSoundSysPage::OnInitDialog() { CNGWizardPage::OnInitDialog(); TRANSLATE(*this, IDD); //fill output switch(m_nSoundSystem) { case SOUNDSYSTEM_WINMM : m_WinButton.SetCheck(BST_CHECKED); OnBnClickedRadioWinaudio(); break; case SOUNDSYSTEM_DSOUND : default : m_DxButton.SetCheck(BST_CHECKED); OnBnClickedRadioDirectsound(); break; } if(m_nOutputDevice == -1) { m_OutputDriversCombo.SetCurSel(0); m_nOutputDevice = int(m_OutputDriversCombo.GetItemData(m_OutputDriversCombo.GetCurSel())); } if(m_nInputDevice == -1) { m_InputDriversCombo.SetCurSel(0); m_nInputDevice = int(m_InputDriversCombo.GetItemData(m_InputDriversCombo.GetCurSel())); } OnCbnSelchangeComboOutputdriver(); OnCbnSelchangeComboInputdriver(); //find select mixer device CStringList list; int count = TT_Mixer_GetWaveInControlCount(0); int nSelectedIndex = -1; for(int i=0;i<count;i++) { TCHAR buff[TT_STRLEN] = {}; TT_Mixer_GetWaveInControlName(0, i, buff); list.AddTail(buff); if(TT_Mixer_GetWaveInControlSelected(0, i)) nSelectedIndex = i; } if(list.GetCount()) { for(POSITION pos=list.GetHeadPosition(); pos!= NULL;) m_wndMixerCombo.AddString(list.GetNext(pos)); m_wndMixerCombo.SetCurSel(nSelectedIndex); } else { m_wndMixerCombo.EnableWindow(FALSE); } return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }
//////////////////////////////////////////// // OnExecute // Demonstrate: // IDirectorySearch::ExecuteSearch // IDirectorySearch::GetNextRow // IDirectorySearch::GetColumn // IDirectorySearch::SetSearchPreference // ///////////////////////////////////////////// void CDlgIDirectorySearch::OnExecute() { ASSERT( m_pSearch ); CWaitCursor wait; UpdateData(TRUE); // Get data from the Dialog Box HRESULT hr; ADS_SEARCH_HANDLE hSearch; ADS_SEARCH_COLUMN col; CString s; int idx=0; int nCount; LPWSTR *pszAttr=NULL; POSITION pos; USES_CONVERSION; ///////////////////////////////// // Reset the Total Number ////////////////////////////////// SetDlgItemText( IDC_TOTAL, _T("")); ///////////////////////////////////////////// // Get the attribute list, and preparing.. /////////////////////////////////////////// CStringList sAttrList; m_cListView.DeleteAllItems(); // Reset the UI while( m_cListView.DeleteColumn(0)) { ; } ////////////////////////////////////////////////// // Preparing for attribute list // and columns to display CString sTemp; m_cAttrList.GetWindowText(s); // we need to add adspath, so that we can refer to this object later when user dblclk the item if ( !s.IsEmpty() ) { sTemp = s; sTemp.MakeLower(); if ( s.Find(_T("adspath"),0) == -1 ) { s += _T(",ADsPath"); } } // convert to string list for easy manipulation StringToStringList( s, sAttrList ); nCount = sAttrList.GetCount(); idx=0; if ( nCount ) { pszAttr = (LPWSTR*) AllocADsMem( nCount * sizeof(LPWSTR)); pos = sAttrList.GetHeadPosition(); while ( pos != NULL ) { s = sAttrList.GetAt(pos); pszAttr[idx] = T2OLE(s); sAttrList.GetNext(pos ); idx++; } } else { nCount = -1; } ///////////////////////////////////////// // BEGIN Set the preferences /////////////////////////////////////// DWORD dwCountPref = 0; ADS_SEARCHPREF_INFO prefInfo[ MAX_SEARCH_PREF ]; ADS_SORTKEY *pSortKey = NULL; if ( m_bEnableFilter == FALSE ) { // Reset the preference m_pSearch->SetSearchPreference( prefInfo, dwCountPref ); } else // Preferences are specified { //////////////////////// // Timeout Pref //////////////////////////// if ( m_nTimeOut != 0 ) { prefInfo[dwCountPref].dwSearchPref = ADS_SEARCHPREF_TIMEOUT; prefInfo[dwCountPref].vValue.dwType = ADSTYPE_INTEGER; prefInfo[dwCountPref].vValue.Integer = m_nTimeOut; dwCountPref++; } ////////////////////////////// // Search Scope ///////////////////////////// idx = m_CADsSearchScope.GetCurSel(); if ( idx != CB_ERR ) { prefInfo[dwCountPref].dwSearchPref = ADS_SEARCHPREF_SEARCH_SCOPE; prefInfo[dwCountPref].vValue.dwType = ADSTYPE_INTEGER; prefInfo[dwCountPref].vValue.Integer = idx; dwCountPref++; } /////////////////////////////////////////////////// // Cache Result. The default is to cache the result ///////////////////////////////////////////////// if ( !m_bCacheResult ) { prefInfo[dwCountPref].dwSearchPref = ADS_SEARCHPREF_SEARCH_SCOPE; prefInfo[dwCountPref].vValue.dwType = ADSTYPE_BOOLEAN; prefInfo[dwCountPref].vValue.Boolean = FALSE; dwCountPref++; } ////////////////////////////////////////////////// // Page Size /////////////////////////////////////////////////// if ( m_nPageSize > 0 ) { prefInfo[dwCountPref].dwSearchPref = ADS_SEARCHPREF_PAGESIZE; prefInfo[dwCountPref].vValue.dwType = ADSTYPE_INTEGER;; prefInfo[dwCountPref].vValue.Integer = m_nPageSize; dwCountPref++; } //////////////////////////////////////////////// // Chase Referrals /////////////////////////////////////////////// idx = m_cChaseReferrals.GetCurSel(); if ( idx != CB_ERR ) { prefInfo[dwCountPref].dwSearchPref = ADS_SEARCHPREF_CHASE_REFERRALS; prefInfo[dwCountPref].vValue.dwType = ADSTYPE_INTEGER; switch( idx ) { case 0: prefInfo[dwCountPref].vValue.Integer = ADS_CHASE_REFERRALS_NEVER; break; case 1: prefInfo[dwCountPref].vValue.Integer = ADS_CHASE_REFERRALS_SUBORDINATE; break; case 2: prefInfo[dwCountPref].vValue.Integer = ADS_CHASE_REFERRALS_EXTERNAL; break; default: prefInfo[dwCountPref].vValue.Integer = ADS_CHASE_REFERRALS_EXTERNAL; } dwCountPref++; } /////////////////////////////////////////////// // Sort On //////////////////////////////////////////////// if ( !m_sSortOn.IsEmpty() ) { CStringList sList; UINT nCount; prefInfo[dwCountPref].dwSearchPref = ADS_SEARCHPREF_SORT_ON; prefInfo[dwCountPref].vValue.dwType = ADSTYPE_PROV_SPECIFIC; StringToStringList( m_sSortOn, sList ); nCount = sList.GetCount(); if ( nCount > 0 ) { POSITION pos; pos= sList.GetHeadPosition(); pSortKey = (ADS_SORTKEY *) LocalAlloc( LMEM_FIXED | LMEM_ZEROINIT, sizeof(ADS_SORTKEY) * nCount ); idx = 0; while( pos != NULL ) { pSortKey[idx].pszAttrType = T2OLE(sList.GetAt(pos)); pSortKey[idx].pszReserved = NULL; pSortKey[idx].fReverseorder =0; // Next idx++; sList.GetNext( pos ); } prefInfo[dwCountPref].vValue.ProviderSpecific.dwLength = sizeof(ADS_SORTKEY) * nCount; prefInfo[dwCountPref].vValue.ProviderSpecific.lpValue = (LPBYTE) pSortKey; dwCountPref++; } } ////////////////////////////////////////////// // Size Limit ////////////////////////////////////////////// if ( m_nSizeLimit > 0 ) { prefInfo[dwCountPref].dwSearchPref = ADS_SEARCHPREF_SIZE_LIMIT; prefInfo[dwCountPref].vValue.dwType = ADSTYPE_INTEGER; prefInfo[dwCountPref].vValue.Integer = m_nSizeLimit; dwCountPref++; } ////////////////////////////////////////////////// // A Synchronous /////////////////////////////////////////////////// if ( m_bAsynch ) { prefInfo[dwCountPref].dwSearchPref = ADS_SEARCHPREF_ASYNCHRONOUS; prefInfo[dwCountPref].vValue.dwType = ADSTYPE_BOOLEAN; prefInfo[dwCountPref].vValue.Integer = TRUE; dwCountPref++; } ///////////////////////////////////////////////////// // Attribute Type Only ////////////////////////////////////////////////////// if ( m_bAttrib ) { prefInfo[dwCountPref].dwSearchPref = ADS_SEARCHPREF_ATTRIBTYPES_ONLY; prefInfo[dwCountPref].vValue.dwType = ADSTYPE_BOOLEAN; prefInfo[dwCountPref].vValue.Integer = TRUE; dwCountPref++; } ///////////////////////////////////////////////////// // Derefence Alias ////////////////////////////////////////////////////// if ( m_nDeref != CB_ERR ) { prefInfo[dwCountPref].dwSearchPref = ADS_SEARCHPREF_DEREF_ALIASES; prefInfo[dwCountPref].vValue.dwType = ADSTYPE_INTEGER; prefInfo[dwCountPref].vValue.Integer = m_nDeref; dwCountPref++; } /////////////////////////////////////////////// // Now Set the selected preferences ////////////////////////////////////////////// hr = m_pSearch->SetSearchPreference( prefInfo, dwCountPref ); } ///////////////////////////////////////// // END Set the preferences /////////////////////////////////////// //////////////////////////////////////// // Execute the Search ////////////////////////////////////// DWORD dwCount=0; hr = m_pSearch->ExecuteSearch(T2OLE(m_sFilter), pszAttr, nCount, &hSearch ); //////////////////////////////// //// cleanup //////////////////////////////// if ( pszAttr ) { FreeADsMem( pszAttr ); } if ( pSortKey ) { LocalFree( pSortKey ); } if ( !SUCCEEDED(hr) ) { AfxMessageBox(GetErrorMessage(hr)); return; } //////////////////////////////////////////////////////// // Enumerate the rows //////////////////////////////////////////////////////// sAttrList.RemoveAll(); ///////////////////////////////////////////////////////// // Retrieve the column names returned from the server /////////////////////////////////////////////////////////// LPWSTR pszColumn; hr = m_pSearch->GetFirstRow( hSearch ); if ( !SUCCEEDED(hr) ) { return; } idx=0; while( (hr=m_pSearch->GetNextColumnName( hSearch, &pszColumn )) != S_ADS_NOMORE_COLUMNS ) { s = OLE2T( pszColumn ); m_cListView.InsertColumn(idx, s, LVCFMT_LEFT, 150 ); // adding columns to the UI sAttrList.AddTail(s); FreeADsMem( pszColumn ); idx++; } ///////////////////////////////////////////// // Start iterating the result set //////////////////////////////////////////// int nCol; CStringList sValueList; do { nCol=0; pos = sAttrList.GetHeadPosition(); while( pos != NULL ) { s = sAttrList.GetAt(pos); //column name // Get the Name and display it in the list hr = m_pSearch->GetColumn( hSearch, T2OLE(s), &col ); if ( SUCCEEDED(hr) ) { s =_T(""); if ( col.dwADsType != ADSTYPE_INVALID ) // if we request for attrib only, no value will be returned { ADsToStringList(col.pADsValues, col.dwNumValues, sValueList ); StringListToString( sValueList, s ); } if ( nCol ) { m_cListView.SetItemText(0,nCol, s); } else { m_cListView.InsertItem(0, s); } m_pSearch->FreeColumn( &col ); } nCol++; sAttrList.GetNext(pos); } dwCount++; ///////////////////////////// //Display the total so far //////////////////////////////// s.Format("%ld object(s)", dwCount ); SetDlgItemText( IDC_TOTAL, s ); } while( (hr=m_pSearch->GetNextRow( hSearch)) != S_ADS_NOMORE_ROWS ); m_pSearch->CloseSearchHandle( hSearch ); }
BOOL CMsgSgTreeView::bPopulateTree() { // Insert the database filename as the root item // CMainFrame* pMainFrm = (CMainFrame*)AfxGetApp()->m_pMainWnd; BOOL bReturnValue = TRUE; CMsgSignal* pTempMsgSg = NULL; pTempMsgSg = *((CMsgSignal**)m_sDbParams.m_ppvActiveDB); // Get reference to the tree control CTreeCtrl& om_tree = GetTreeCtrl(); // om_tree.DeleteAllItems(); om_tree.SetTextColor( BLUE_COLOR ); CString omStrDatabaseFilename = m_omCurrDbName; if ( omStrDatabaseFilename.IsEmpty() ) { bReturnValue = FALSE; AfxMessageBox(MSG_DB_NOT_FOUND, MB_OK); } else { // om_tree.DeleteAllItems(); // Insert database filename HTREEITEM hRootItem = om_tree.InsertItem( omStrDatabaseFilename ); om_tree.SetItemImage(hRootItem, 0, 0); CStringList omMessageNames; // Clean the list omMessageNames.RemoveAll(); // Get all the database message names pTempMsgSg->omStrListGetMessageNamesInactive(omMessageNames); POSITION pos = omMessageNames.GetHeadPosition(); BOOL bSelFirstChild = FALSE; // Insert all message names while ( pos != NULL ) { CString omStrMsgName = omMessageNames.GetNext(pos); HTREEITEM hMsg = om_tree.InsertItem( omStrMsgName, hRootItem ); if(bSelFirstChild != TRUE ) { om_tree.SelectItem( hMsg ); bSelFirstChild = TRUE; } om_tree.SetItemImage(hMsg, 1, 1); } // Expand the root om_tree.Expand( hRootItem, TVE_EXPAND ); if(bSelFirstChild != TRUE ) { // Select the root item om_tree.SelectItem( hRootItem ); } } return (bReturnValue); }
BOOL WebLogic(const char * strParas, char * szReturn, int& nSize) //(CStringList ¶mList, char *szReturn) { AFX_MANAGE_STATE(AfxGetStaticModuleState()); //参数解析: CString strServIp = _T(""), strServPort = _T(""), strUserName = _T(""), strUserPwd = _T(""), strTaskType = _T(""), strTaskParam = _T(""); CString strProxyServ = _T(""), strProxyUser = _T(""); int nServerPort = 21; int nTimeout = 60; BOOL bRet = FALSE; // Check Content Change CStringList paramList; MakeStringListByChar(paramList,strParas); POSITION pos = paramList.GetHeadPosition(); while(pos) { CString strTemp = paramList.GetNext(pos); if(strTemp.Find(__USERNAME__, 0) == 0) { strUserName = strTemp.Right(strTemp.GetLength() - strlen(__USERNAME__)); } else if(strTemp.Find(__PASSWORD__, 0) == 0) { strUserPwd = strTemp.Right(strTemp.GetLength() - strlen(__PASSWORD__)); } else if(strTemp.Find(__TIMEOUT__, 0) == 0) { nTimeout = atoi(strTemp.Right(strTemp.GetLength() - strlen(__TIMEOUT__))); } else if(strTemp.Find(__SERVERIP__, 0) == 0) { strServIp = strTemp.Right(strTemp.GetLength() - strlen(__SERVERIP__)); } else if(strTemp.Find(__SERVERPORT__, 0) == 0) { strServPort = strTemp.Right(strTemp.GetLength() - strlen(__SERVERPORT__)); } else if(strTemp.Find(__TASKTYPE__, 0) == 0) { strTaskType = strTemp.Right(strTemp.GetLength() - strlen(__TASKTYPE__)); } else if(strTemp.Find(__TASKPARAM__, 0) == 0) { strTaskParam = strTemp.Right(strTemp.GetLength() - strlen(__TASKPARAM__)); } else { } } if(strUserName.IsEmpty()) { sprintf(szReturn, "error=%s", FuncGetStringFromIDS("IDS_Poor_UserName"));//"缺少用户姓名!");//<%IDS_Monitor_40%>"缺少FTP服务器地址" return FALSE; } if(strUserPwd.IsEmpty()) { sprintf(szReturn, "error=%s", FuncGetStringFromIDS("IDS_Poor_Password"));//"缺少用户密码!");//<%IDS_Monitor_40%> return FALSE; } if(strServIp.IsEmpty()) { sprintf(szReturn, "error=%s", FuncGetStringFromIDS("IDS_Poor_ServerAddress"));//"缺少服务器地址!");//<%IDS_Monitor_40%>"缺少FTP服务器地址" return FALSE; } if(strServPort.IsEmpty()) { sprintf(szReturn, "error=%s", FuncGetStringFromIDS("IDS_Poor_ServerPort"));//"缺少服务器端口地址!");//<%IDS_Monitor_40%>"缺少FTP服务器地址" return FALSE; } if(strTaskType.IsEmpty()) { sprintf(szReturn, "error=%s", FuncGetStringFromIDS("IDS_Poor_TaskType"));//"缺少任务类型!");//<%IDS_Monitor_40%>"缺少FTP服务器地址" return FALSE; } if(strTaskParam.IsEmpty()) { strTaskParam = "null"; } if(nTimeout <= 0) { sprintf(szReturn, "error=%s", FuncGetStringFromIDS("IDS_TimeoutParamError"));//"超时参数有错误!");//<%IDS_Monitor_40%>"缺少FTP服务器地址" return FALSE; } //取数据的实现 CString strCustomerPath = _T(""); strCustomerPath.Format("%s\\fcgi-bin", FuncGetInstallRootPath()); //CString strCmdLine = "CMD /C " + strCustomerPath + "\\MonitorManager\\WeblogicMonitor.bat \""; CString strCmdLine = "CMD /C \"" + strCustomerPath + "\\WeblogicMonitor.bat\" "; strCmdLine += strUserName + " "; strCmdLine += strUserPwd + " "; strCmdLine += "t3://" + strServIp + ":" + strServPort; strCmdLine += " " + strTaskType; strCmdLine += " " + strTaskParam; SECURITY_ATTRIBUTES sa; sa.nLength = sizeof(SECURITY_ATTRIBUTES); sa.bInheritHandle = TRUE; sa.lpSecurityDescriptor = NULL; HANDLE hRead, hWrite; long retval = CreatePipe(&hRead, &hWrite, &sa, 12000) ; if(retval == 0) { return false; } else { STARTUPINFO si; memset(&si, 0, sizeof(STARTUPINFO)); si.cb = sizeof(STARTUPINFO); si.dwFlags = STARTF_USESTDHANDLES|STARTF_USESHOWWINDOW; si.hStdOutput = hWrite; si.hStdError = hWrite; // si.wShowWindow =SW_HIDE; PROCESS_INFORMATION pi; memset(&pi, 0, sizeof(PROCESS_INFORMATION)); puts(strCmdLine); if (CreateProcess(NULL, strCmdLine.GetBuffer(strCmdLine.GetLength()), &sa, &sa, TRUE, CREATE_NEW_CONSOLE/*CREATE_NO_WINDOW*/, NULL, NULL, &si, &pi)) { bRet = TRUE; DWORD dwResult = WaitForSingleObject(pi.hProcess, 6000*1000); if (dwResult == WAIT_OBJECT_0) { DWORD dwExitCode = 0; if (GetExitCodeProcess(pi.hProcess, &dwExitCode)) { //if (dwExitCode == 0) { // CFile* pFile = NULL; int nFileLength = 0; TRY { pFile = new CFile(hRead); nFileLength = pFile->GetLength(); } CATCH(CFileException, pEx) { // Do Nothing. } END_CATCH char * buffer = NULL; buffer = (char*)malloc(nFileLength+1); // pFile->Read(buffer, nFileLength); CString strSource = _T(""); strSource.Format("%s", buffer); //WeblogicMonitor(去掉call setWLSEnv.cmd所生成的输出) int nOrder = strSource.Find("FileSplitFlag"); nOrder += 13; strSource = strSource.Mid(nOrder); // nOrder = strSource.Find("EndSplitFlag"); //nOrder += 13; strSource = strSource.Left(nOrder); strSource.Replace("WaitingForConnectionCurrentCount","WaitConnetCurCount"); strSource.Replace( "Error=","error=" ); //生成正确格式的输出串 strcpy(szReturn, strSource); //sprintf(szReturn, "error=%s",buffer); // free(buffer); if (pFile != NULL) { pFile->Close(); delete pFile; } } //else { } }
BOOL ModifyIDThree::OnInitDialog() { CDialog::OnInitDialog(); // TODO: Add extra initialization here m_Year.EnableWindow(FALSE); m_Track.EnableWindow(FALSE); m_Title.EnableWindow(FALSE); m_Genre.EnableWindow(FALSE); m_Artist.EnableWindow(FALSE); m_Album.EnableWindow(FALSE); // CString genre = id3_GetGenre(mID3_Tag); CString oldgenre = m_Song->getId3(CS("TCON")); oldgenre = Genre_normalize((LPCTSTR)oldgenre); CString oldartist = m_Song->getId3(CS("TPE1")); CString oldalbum = m_Song->getId3(CS("TALB")); CString oldtitle = m_Song->getId3(CS("TIT2")); CString oldtrack = m_Song->getId3(CS("TRCK")); CString oldyear = m_Song->getId3(CS("TYER")); CString file = m_Song->getId3("FILE"); m_File.SetWindowText(file); CString newgenre, newartist, newalbum, newtitle, newtrack, newyear; newgenre = oldgenre; newartist = oldartist; newalbum = oldalbum; newtitle = oldtitle; newtrack = oldtrack; newyear = oldyear; // oldgenre = "\"" + oldgenre + "\""; // oldartist = "\"" + oldartist + "\""; // oldalbum = "\"" + oldalbum + "\""; // oldtitle = "\"" + oldtitle + "\""; // oldtrack = "\"" + oldtrack + "\""; // oldyear = "\"" + oldyear + "\""; if (MBALL == newartist) { newartist = ""; } if (MBALL == newalbum) { newalbum = ""; } if (MBALL == newgenre) { newgenre = ""; } m_OldGenre.SetWindowText(oldgenre); int pos; CString tmpGenre; for (pos = 0 ; pos < mGenreList->GetSize(); pos++) { tmpGenre = mGenreList->GetAt(pos); m_Genre.AddString(tmpGenre); } m_Genre.SelectString(0, newgenre ); int x = m_Genre.GetCount(); if (mWindowFlag >= 1 /*&& genre != MBALL */) { m_Genre.EnableWindow(TRUE); } if (mWindowFlag >= 2) { m_Artist.EnableWindow(TRUE); m_Artist.SetWindowText(newartist); m_OldArtist.SetWindowText(oldartist); // if (artist == MBALL) // m_Artist.EnableWindow(FALSE); } if (mWindowFlag >= 3) { m_Album.EnableWindow(TRUE); m_Year.EnableWindow(TRUE); m_Album.SetWindowText(newalbum); m_OldAlbum.SetWindowText(oldalbum); m_Year.SetWindowText(newyear); m_OldYear.SetWindowText(oldyear); // if (album == MBALL) { // m_Album.EnableWindow(FALSE); // } } m_TagData.ShowWindow(FALSE); m_File.ShowWindow(FALSE); if (mWindowFlag >= 4) { m_Title.EnableWindow(TRUE); m_Track.EnableWindow(TRUE); m_Title.SetWindowText(newtitle); m_OldTitle.SetWindowText(oldtitle); m_Track.SetWindowText(newtrack); m_OldTrack.SetWindowText(oldtrack); m_TagData.ShowWindow(TRUE); m_File.ShowWindow(TRUE); MBTag tag; CStringList list; tag.getInfo(file,list); for(POSITION pos = list.GetHeadPosition();pos!=NULL;list.GetNext(pos)) { m_TagData.AddString(list.GetAt(pos)); } m_OldValsLabel.SetWindowText("Old value"); } return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }
void OnDsp2H(CStringList& strFileList, CString strSrcDir, CString strDstDir, BOOL bForce) { CString strSrcFile, strDstFile, strTemp, strVal, strOut;; CStdioFile out; CFileStatus status; POSITION pos; int iDot, iOffset, iPage, iLength; strDstFile = strDstDir + strFileList.RemoveTail(); if (!PromptOverwriteFile(strDstFile, bForce)) return; #ifndef __GNUC__ CFile::GetStatus(strDstFile, status); #else stat(strDstFile.c_str(),&status); #endif iOffset = 0; iPage = 0; strOut = _T(""); #ifndef __GNUC__ for (pos = strFileList.GetHeadPosition(); pos != NULL; ) #else for (pos = strFileList.begin(); pos != strFileList.end(); ++pos) #endif { strTemp = strFileList.GetNext(pos); strSrcFile = strSrcDir + strTemp; #ifndef __GNUC__ if (!CFile::GetStatus(strSrcFile, status)) { wprintf(_T("Source file %s doesn't exist"), strSrcFile); #else if (stat(strSrcFile.c_str(),&status)) { printf("Source file %s doesn't exist", strSrcFile.c_str()); #endif return; } iLength = (int)status.m_size; iDot = strTemp.Find(_T('.')); strTemp = strTemp.Left(iDot); strTemp.MakeUpper(); #ifndef __GNUC__ strVal.Format(_T("#define SYSTEM_%s_PAGE\t\t(SYSTEM_DSP_PAGE + %d)\n"), strTemp, iPage); #else { char buff[511]; sprintf(buff, _T("#define SYSTEM_%s_PAGE\t\t(SYSTEM_DSP_PAGE + %d)\n"), strTemp.c_str(), iPage); strVal = buff; } #endif strOut += strVal; #ifndef __GNUC__ strVal.Format(_T("#define SYSTEM_%s_OFFSET\t\t0x%x\n"), strTemp, iOffset); #else { char buff[511]; sprintf(buff, _T("#define SYSTEM_%s_OFFSET\t\t0x%x\n"), strTemp.c_str(), iOffset); strVal = buff; } #endif strOut += strVal; iOffset += iLength; while (iOffset >= FILE_FLAG_PAGE_SIZE) { iOffset -= FILE_FLAG_PAGE_SIZE; iPage ++; if (iPage >= SYSTEM_DSP_PAGE_NUM) { printf("DSP dat files too large!"); return; } } } if (!out.Open(strDstFile, CFile::modeCreate|CFile::modeWrite|CFile::typeText)) { #ifndef __GNUC__ wprintf(_T("Can not create destination file %s"), strDstFile); #else printf("Can not create destination file %s", strDstFile.c_str()); #endif return; } out.WriteString(strOut); out.Close(); }
LRESULT CP4EditBox::OnDropTarget(WPARAM wParam, LPARAM lParam) { // m_DropTargetPt.x = LOWORD(lParam); // m_DropTargetPt.y = HIWORD(lParam); CStringList *filelist = (CStringList *)wParam; CString txt; CString filename; CString localname; BOOL b = GET_P4REGPTR()->UseDepotInClientView(); int i; GetWindowText(txt); txt.TrimRight(); if (txt.Find(_T("\r\n\r\n")) == -1) txt += _T("\r\n\r\n"); else txt += _T("\r\n"); for(POSITION pos = filelist->GetHeadPosition(); pos != NULL; ) { filename = filelist->GetNext( pos ); switch(m_SpecType) { case 0: // Single filename only SetWindowText(filename); return 0; case P4LABEL_SPEC: case P4USER_SPEC: if (filename.Find(_T(' ')) != -1) filename = _T('\"') + filename + _T('\"'); break; case P4CLIENT_SPEC: if ((i = filename.Find(_T("<contains no files or folders>"))) != -1) filename = filename.Left(i-1) + _T("/..."); localname = CString ( _T("//") ) + GET_P4REGPTR()->GetP4Client(); if (!b && ((i = filename.Find(_T('/'), 2)) > 2)) localname += filename.Right(filename.GetLength() - i); else localname += filename.Right(filename.GetLength() - 1); if (filename.Find(_T(' '))) filename = _T('\"') + filename + _T('\"'); if (localname.Find(_T(' '))) localname = _T('\"') + localname + _T('\"'); filename = filename + _T(' ') + localname; break; default: ASSERT(0); return 0; } txt += filename + _T("\r\n"); } SetWindowText(txt); // Set caret at end of view/review and scroll into view. int s, e; SetSel(0, -1); GetSel(s, e); SetSel(e, e, TRUE); return 0; }
/*************************************************** StartDropList This internal function is used to parse out the label string, which contains the items to show in the list. Also this function will show the list box in the proper location on the screen. Params: <none> Return: UG_ERROR - the list is already visible. UG_SUCCESS - everything went smoothly, the drop list was shown ***************************************************/ int CUGDropListType::StartDropList() { RECT rect; RECT clientRect; int dif,len,pos,startpos; CFont * font = NULL; LOGFONT lf; CFont * cfont; CStringList list; //lists of strings for the list are assembed here CString * items; //points to the string used to assemble the list //return false if it is already up if( m_listBox->m_HasFocus) return UG_ERROR; CUGCell cell; m_ctrl->GetCellIndirect(m_btnCol,m_btnRow,&cell); // make sure that the read only cells do not show droplist if ( cell.GetReadOnly() == TRUE ) return UG_SUCCESS; //get the current row and col m_btnCol = m_ctrl->GetCurrentCol(); m_btnRow = m_ctrl->GetCurrentRow(); //add the strings to the CStringList CString string; cell.GetLabelText(&string); items = &string; len = items->GetLength(); pos =0; startpos =0; while(pos <len){ if(items->GetAt(pos)== _T('\n')){ list.AddTail(items->Mid(startpos,pos-startpos)); startpos = pos+1; } pos++; } //notify the user of the list, so it can be modified if needed if ( OnCellTypeNotify(m_ID,m_btnCol,m_btnRow,UGCT_DROPLISTSTART,(LONG_PTR)&list) == FALSE ) // if FALSE was returned from OnCellTypeNotify call, than the developer does not // wish to show the drop list at the moment. return UG_ERROR; // set default font height lf.lfHeight = 12; //get the font if(cell.IsPropertySet(UGCELL_FONT_SET)) font = cell.GetFont(); else if(m_ctrl->m_GI->m_defFont != NULL) font = m_ctrl->m_GI->m_defFont; if(font == NULL) font = CFont::FromHandle((HFONT)GetStockObject(SYSTEM_FONT)); if(font != NULL) { //find the height of the font cfont = font; cfont->GetLogFont(&lf); // lf.lfHeight if( lf.lfHeight < 0 ){ HDC hDC = CreateCompatibleDC(NULL); lf.lfHeight = -MulDiv(lf.lfHeight, GetDeviceCaps(hDC, LOGPIXELSY), 72); DeleteDC(hDC); } } //get the rectangle for the listbox m_ctrl->GetCellRect(m_btnCol,m_btnRow,&rect); rect.top = rect.bottom; rect.left+=10; rect.right+=10; len = (int)list.GetCount(); if(len >15) len = 15; rect.bottom += lf.lfHeight * len + 6; m_ctrl->m_CUGGrid->GetClientRect(&clientRect); if(rect.bottom > clientRect.bottom){ dif = rect.bottom - clientRect.bottom; rect.bottom -= dif; rect.top -= dif; if(rect.top <0) rect.top = 0; } if(rect.right > clientRect.right){ dif = rect.right - clientRect.right; rect.right -= dif; rect.left -= dif; if(rect.left <0) rect.left = 0; } //create the CListBox m_listBox->m_ctrl = m_ctrl; m_listBox->m_cellType = this; m_listBox->m_cellTypeId = m_ID; m_listBox->Create(WS_CHILD|WS_BORDER|WS_VSCROLL,rect,m_ctrl->m_CUGGrid,123); //set up the font if(font != NULL) m_listBox->SetFont(font); // v7.2 - update 03 - this works to eliminate blank lines that // can occur with odd sized fonts/number of items. Fix courtesy Gerbrand // .start int itHeight = m_listBox->GetItemHeight(0); if (len > 15) len = 15; rect.bottom = rect.top + len * itHeight + 6; if(rect.bottom > clientRect.bottom){ dif = rect.bottom - clientRect.bottom; rect.bottom -= dif; rect.top -= dif; if(rect.top <0) rect.top = 0; } // v7.2 - update 03 - Adjust the rect width to accomodate the largest string // Allen Shiels dif = GetMaxStringWidth(list) - (rect.right-rect.left); if (dif > 0) { if (len >= 15) // add a scroll bar width if max items in list dif += GetSystemMetrics(SM_CXVSCROLL); rect.right += dif; } if(rect.right > clientRect.right){ dif = rect.right - clientRect.right; rect.right -= dif; rect.left -= dif; if(rect.left <0) rect.left = 0; } // .end //resize the window again since a new font is being used m_listBox->MoveWindow(&rect,FALSE); //add the items to the list len = (int)list.GetCount(); POSITION position = list.GetHeadPosition(); pos =0; while(pos < len){ m_listBox->AddString(list.GetAt(position)); pos++; if(pos < len) list.GetNext(position); } //give the list box pointers to the cell m_listBox->m_col = &m_btnCol; m_listBox->m_row = &m_btnRow; m_listBox->ShowWindow(SW_SHOW); m_listBox->SetFocus(); m_btnDown = FALSE; m_ctrl->RedrawCell(m_btnCol,m_btnRow); return UG_SUCCESS; }
// do the action required to open a single atomic tag (iAction) void CMUSHclientDoc::MXP_OpenAtomicTag (const CString strTag, int iAction, CStyle * pStyle, CString & strAction, // new action CString & strHint, // new hint CString & strVariable, // new variable CArgumentList & ArgumentList) { CString strArgument; CString strArgumentName; bool bIgnoreUnusedArgs = false; // cut down on some spam by setting this COLORREF colour1, colour2; unsigned short iFlags = pStyle->iFlags; COLORREF iForeColour = pStyle->iForeColour; COLORREF iBackColour = pStyle->iBackColour; // call script if required if (m_dispidOnMXP_OpenTag != DISPID_UNKNOWN || m_bPluginProcessesOpenTag) { // dummy-up an argument list CString strArgument; CArgument * pArgument; POSITION pos; // put the arguments into the array for (pos = ArgumentList.GetHeadPosition (); pos; ) { pArgument = ArgumentList.GetNext (pos); // empty ones we will put there by position if (pArgument->strName.IsEmpty ()) strArgument += CFormat ("'%s'", (LPCTSTR) pArgument->strValue); else strArgument += CFormat ("%s='%s'", (LPCTSTR) pArgument->strName, (LPCTSTR) pArgument->strValue); if (pos) strArgument += " "; } // end of looping through each argument bool bNotWanted = MXP_StartTagScript (strTag, strArgument, ArgumentList); // re-get current style in case the script did a world.note pStyle = m_pCurrentLine->styleList.GetTail (); // put things backt to how they were pStyle->iFlags = iFlags; pStyle->iForeColour = iForeColour; pStyle->iBackColour = iBackColour; if (bNotWanted) return; // they didn't want to go ahead with this tag } // find current foreground and background RGB values GetStyleRGB (pStyle, colour1, colour2); // special processing for Pueblo // a tag like this: <A XCH_CMD="examine #1"> // will convert to a SEND tag if (iAction == MXP_ACTION_HYPERLINK && PUEBLO_ACTIVE) { strArgument = GetArgument (ArgumentList, "xch_cmd", 0, true); if (!strArgument.IsEmpty ()) { m_bPuebloActive = true; // for correct newline processing iAction = MXP_ACTION_SEND; } } // now take the action switch (iAction) { // temporarily make headlines the same as bold case MXP_ACTION_H1: case MXP_ACTION_H2: case MXP_ACTION_H3: case MXP_ACTION_H4: case MXP_ACTION_H5: case MXP_ACTION_H6: case MXP_ACTION_BOLD: pStyle->iFlags |= HILITE; break; case MXP_ACTION_UNDERLINE: pStyle->iFlags |= UNDERLINE; break; case MXP_ACTION_ITALIC: pStyle->iFlags |= BLINK; break; case MXP_ACTION_COLOR: { pStyle->iForeColour = colour1; pStyle->iBackColour = colour2; // convert to RGB colour to start with in case only FORE or BACK supplied pStyle->iFlags &= ~COLOURTYPE; // clear bits, eg. custom pStyle->iFlags |= COLOUR_RGB; // foreground colour strArgument = GetArgument (ArgumentList, "fore", 1, true); // get foreground colour if (!m_bIgnoreMXPcolourChanges) if (SetColour (strArgument, pStyle->iForeColour)) MXP_error (DBG_ERROR, errMXP_UnknownColour, TFormat ("Unknown colour: \"%s\"" , (LPCTSTR) strArgument)); // background colour strArgument = GetArgument (ArgumentList, "back", 2, true); // get background colour if (!m_bIgnoreMXPcolourChanges) if (SetColour (strArgument, pStyle->iBackColour)) MXP_error (DBG_ERROR, errMXP_UnknownColour, TFormat ("Unknown colour: \"%s\"" , (LPCTSTR) strArgument)); } break; // end of COLOR case MXP_ACTION_HIGH: { CColor clr; pStyle->iForeColour = colour1; pStyle->iBackColour = colour2; // convert to RGB colour to start with pStyle->iFlags &= ~COLOURTYPE; // clear bits, eg. custom pStyle->iFlags |= COLOUR_RGB; clr.SetColor (colour1); float lum = clr.GetLuminance (); lum += 0.15f; if (lum > 1.0f) lum = 1.0f; clr.SetLuminance (lum); pStyle->iForeColour = clr; } break; // end of COLOR case MXP_ACTION_SEND: // send to mud hyperlink pStyle->iFlags &= ~ACTIONTYPE; // cancel old actions if (GetKeyword (ArgumentList, "prompt")) pStyle->iFlags |= ACTION_PROMPT; // prompt action else pStyle->iFlags |= ACTION_SEND; // send-to action if (m_bUnderlineHyperlinks) pStyle->iFlags |= UNDERLINE; // underline it if (m_bUseCustomLinkColour) { // find current background RGB value pStyle->iForeColour = m_iHyperlinkColour; // use hyperlink colour pStyle->iBackColour = colour2; pStyle->iFlags &= ~COLOURTYPE; // clear bits, eg. custom pStyle->iFlags |= COLOUR_RGB; } strArgument = GetArgument (ArgumentList,"href", 1, false); // get link if (strArgument.IsEmpty ()) strArgument = GetArgument (ArgumentList,"xch_cmd", 1, false); // get link strAction = strArgument; // hyperlink strArgument = GetArgument (ArgumentList, "hint", 2, false); // get hints if (strArgument.IsEmpty ()) strArgument = GetArgument (ArgumentList,"xch_hint", 2, false); // get hint strHint = strArgument; // hints break; // end of MXP_ACTION_SEND case MXP_ACTION_HYPERLINK: // hyperlink strArgument = GetArgument (ArgumentList,"href", 1, false); // get link strAction = strArgument; // hyperlink pStyle->iFlags &= ~ACTIONTYPE; // cancel old actions pStyle->iFlags |= ACTION_HYPERLINK | UNDERLINE; // send-to action if (m_bUseCustomLinkColour) { pStyle->iForeColour = m_iHyperlinkColour; // use hyperlink colour pStyle->iBackColour = colour2; pStyle->iFlags &= ~COLOURTYPE; // clear bits, eg. custom pStyle->iFlags |= COLOUR_RGB; } break; // end of MXP_ACTION_HYPERLINK case MXP_ACTION_FONT: { pStyle->iForeColour = colour1; pStyle->iBackColour = colour2; // convert to RGB colour to start with in case only FORE or BACK supplied pStyle->iFlags &= ~COLOURTYPE; // clear bits, eg. custom pStyle->iFlags |= COLOUR_RGB; // eg. <FONT COLOR=Red,Blink> CStringList list; strArgument = GetArgument (ArgumentList,"color", 1, true); // get color etc. if (strArgument.IsEmpty () && PUEBLO_ACTIVE) strArgument = GetArgument (ArgumentList,"fgcolor", 1, true); // get color StringToList (strArgument, ",", list); // break into components for (POSITION pos = list.GetHeadPosition (); pos; ) { CString strItem = list.GetNext (pos); // get action item if (strItem == "blink") pStyle->iFlags |= BLINK; else if (strItem == "italic") pStyle->iFlags |= BLINK; else if (strItem == "underline") pStyle->iFlags |= UNDERLINE; else if (strItem == "bold") pStyle->iFlags |= HILITE; else if (strItem == "inverse") pStyle->iFlags |= INVERSE; else { // must be colour name, yes? // foreground colour if (!m_bIgnoreMXPcolourChanges) if (SetColour (strItem, pStyle->iForeColour)) MXP_error (DBG_ERROR, errMXP_UnknownColour, TFormat ("Unknown colour: \"%s\"" , (LPCTSTR) strItem)); } // end of colour } // end of handling each item in the list strArgument = GetArgument (ArgumentList,"back", 2, true); // get back color if (strArgument.IsEmpty () && PUEBLO_ACTIVE) strArgument = GetArgument (ArgumentList,"bgcolor", 2, true); // get back color // background colour if (!m_bIgnoreMXPcolourChanges) if (SetColour (strArgument, pStyle->iBackColour)) MXP_error (DBG_ERROR, errMXP_UnknownColour, TFormat ("Unknown colour: \"%s\"" , (LPCTSTR) strArgument)); // get font size argument to avoid warnings about unused arguments strArgument = GetArgument (ArgumentList,"size", 0, true); // get font size } break; // end of FONT case MXP_ACTION_VERSION: { CString strVersion = CFormat ("\x1B[1z<VERSION MXP=\"%s\" CLIENT=MUSHclient " "VERSION=\"%s\" REGISTERED=YES>%s", MXP_VERSION, MUSHCLIENT_VERSION, ENDLINE ); SendPacket (strVersion, strVersion.GetLength ()); // send version info back MXP_error (DBG_INFO, infoMXP_VersionSent, TFormat ("Sent version response: %s" , (LPCTSTR) strVersion.Mid (4))); } break; // end of VERSION case MXP_ACTION_AFK: if (m_bSendMXP_AFK_Response) // if player wants us to { strArgument = GetArgument (ArgumentList,"challenge", 1, false); // get challenge // find time since last player input CTimeSpan ts = CTime::GetCurrentTime() - m_tLastPlayerInput; CString strAFK = CFormat ("\x1B[1z<AFK %ld %s>%s", ts.GetTotalSeconds (), (LPCTSTR) strArgument, ENDLINE ); SendPacket (strAFK, strAFK.GetLength ()); // send AFK info back MXP_error (DBG_INFO, infoMXP_AFKSent, TFormat ("Sent AFK response: %s" , (LPCTSTR) strAFK.Mid (4))); } // end of AFK break; case MXP_ACTION_SUPPORT: { CString strSupports; CAtomicElement * pElement; CStringList list; CString strName; if (ArgumentList.IsEmpty ()) { for (POSITION pos = App.m_ElementMap.GetStartPosition(); pos; ) { App.m_ElementMap.GetNextAssoc (pos, strName, pElement); if ((pElement->iFlags & TAG_NOT_IMP) == 0) { strSupports += "+"; strSupports += pElement->strName; strSupports += " "; // now list the sub-items it supports StringToList (pElement->strArgs, ",", list); // break into components for (POSITION argpos = list.GetHeadPosition (); argpos; ) { CString strItem = list.GetNext (argpos); // get argument item strSupports += "+"; strSupports += pElement->strName; strSupports += "."; strSupports += strItem; strSupports += " "; } // end of doing each sub-item } // end of being implemented } // end of looping through all atomic elements } // end of wanting complete list else { for (POSITION pos = ArgumentList.GetHeadPosition (); pos; ) { CArgument * pArgument = ArgumentList.GetNext (pos); CStringList questionlist; StringToList (pArgument->strValue, ".", questionlist); // break into components // should be one or two words, eg. send.prompt or color if (questionlist.GetCount () > 2) { MXP_error (DBG_ERROR, errMXP_InvalidSupportArgument, TFormat ("Invalid <support> argument: %s" , (LPCTSTR) pArgument->strValue)); return; } CString strTag = questionlist.RemoveHead (); strTag.MakeLower (); // check valid name requested if (!IsValidName (strTag)) { MXP_error (DBG_ERROR, errMXP_InvalidSupportArgument, TFormat ("Invalid <support> argument: %s" , (LPCTSTR) strTag)); return; } // look up main element name if (!App.m_ElementMap.Lookup (strTag, pElement) || (pElement->iFlags & TAG_NOT_IMP) != 0) { // not supported strSupports += "-"; strSupports += strTag; strSupports += " "; continue; // all done for this argument } // only one word - they aren't looking for a suboption if (questionlist.IsEmpty ()) { // supported strSupports += "+"; strSupports += strTag; strSupports += " "; continue; // all done for this argument } CString strSubtag = questionlist.RemoveHead (); strSubtag.MakeLower (); if (strSubtag == "*") { // they want list of options for this tag // now list the sub-items it supports StringToList (pElement->strArgs, ",", list); // break into components for (POSITION argpos = list.GetHeadPosition (); argpos; ) { CString strItem = list.GetNext (argpos); // get argument item strSupports += "+"; strSupports += pElement->strName; strSupports += "."; strSupports += strItem; strSupports += " "; } // end of doing each sub-item } // end of wildcard else { // not wildcard - must be name // check valid name requested if (!IsValidName (strSubtag)) { MXP_error (DBG_ERROR, errMXP_InvalidSupportArgument, TFormat ("Invalid <support> argument: %s" , (LPCTSTR) strSubtag)); return; } // so, see if that word is in our arguments list StringToList (pElement->strArgs, ",", list); // break into components if (list.Find (strSubtag)) { strSupports += "+"; strSupports += pArgument->strValue; strSupports += " "; } else { strSupports += "-"; strSupports += pArgument->strValue; strSupports += " "; } } // end of not looking for wildcard } // end of doing each argument } // find individual items CString strMessage = CFormat ("\x1B[1z<SUPPORTS %s>%s", (LPCTSTR) strSupports, ENDLINE); SendPacket (strMessage, strMessage.GetLength ()); // send version info back MXP_error (DBG_INFO, infoMXP_SupportsSent, TFormat ("Sent supports response: %s" , (LPCTSTR) strMessage.Mid (4))); } bIgnoreUnusedArgs = true; break; // end of MXP_ACTION_SUPPORT case MXP_ACTION_OPTION: { CString strOptions; CStringList list; CString strName; if (ArgumentList.IsEmpty ()) { for (long i = 0; OptionsTable [i].pName; i++) { char * pName = OptionsTable [i].pName; strOptions += CFormat ("%s=%ld ", pName, (LPCTSTR) GetOptionItem (i)); } } // end of wanting complete list else { for (POSITION pos = ArgumentList.GetHeadPosition (); pos; ) { CArgument * pArgument = ArgumentList.GetNext (pos); strOptions += CFormat ("%s=%ld", (LPCTSTR) pArgument->strValue, (LPCTSTR) GetOption (pArgument->strValue)); } // end of doing each argument } // find individual items CString strMessage = CFormat ("\x1B[1z<OPTIONS %s>%s", (LPCTSTR) strOptions, ENDLINE); SendPacket (strMessage, strMessage.GetLength ()); // send version info back MXP_error (DBG_INFO, infoMXP_OptionsSent, TFormat ("Sent options response: %s" , (LPCTSTR) strMessage.Mid (4))); } bIgnoreUnusedArgs = true; break; // end of MXP_ACTION_OPTION case MXP_ACTION_RECOMMEND_OPTION: if (m_bMudCanChangeOptions) { CString strOptions; CStringList list; CString strName; for (POSITION pos = ArgumentList.GetHeadPosition (); pos; ) { CArgument * pArgument = ArgumentList.GetNext (pos); int iItem; int iResult = FindBaseOption (pArgument->strName, OptionsTable, iItem); if (iResult != eOK) MXP_error (DBG_ERROR, errMXP_InvalidOptionArgument, TFormat ("Option named '%s' not known.", (LPCTSTR) pArgument->strName)); else if (!(OptionsTable [iItem].iFlags & OPT_SERVER_CAN_WRITE)) MXP_error (DBG_ERROR, errMXP_CannotChangeOption, TFormat ("Option named '%s' cannot be changed.", (LPCTSTR) pArgument->strName)); else { iResult = SetOptionItem (iItem, atol (pArgument->strValue), true, false); if (iResult == eOK) MXP_error (DBG_INFO, infoMXP_OptionChanged, TFormat ("Option named '%s' changed to '%s'.", (LPCTSTR) pArgument->strName, (LPCTSTR) pArgument->strValue)); else MXP_error (DBG_ERROR, errMXP_OptionOutOfRange, TFormat ("Option named '%s' could not be changed to '%s' (out of range).", (LPCTSTR) pArgument->strName, (LPCTSTR) pArgument->strValue)); } } // end of doing each argument } bIgnoreUnusedArgs = true; break; // end of MXP_ACTION_RECOMMEND_OPTION case MXP_ACTION_USER: if (!m_name.IsEmpty () && m_connect_now == eConnectMXP) { CString strPacket = m_name + ENDLINE; SendPacket (strPacket, strPacket.GetLength ()); // send name to MUD MXP_error (DBG_INFO, infoMXP_CharacterNameSent, TFormat ("Sent character name: %s" , (LPCTSTR) m_name)); } else if (m_connect_now != eConnectMXP) MXP_error (DBG_WARNING, wrnMXP_CharacterNameRequestedButNotDefined, Translate ("Character name requested but auto-connect not set to MXP.")); else MXP_error (DBG_WARNING, wrnMXP_CharacterNameRequestedButNotDefined, Translate ("Character name requested but none defined.")); break; // end of USER case MXP_ACTION_PASSWORD: if (m_nTotalLinesSent > 10) // security check MXP_error (DBG_WARNING, wrnMXP_PasswordNotSent, "Too many lines sent to MUD - password not sent."); else if (!m_password.IsEmpty () && m_connect_now == eConnectMXP) { CString strPacket = m_password + ENDLINE; SendPacket (strPacket, strPacket.GetLength ()); // send password to MUD MXP_error (DBG_INFO, infoMXP_PasswordSent, "Sent password to world."); } else if (m_connect_now != eConnectMXP) MXP_error (DBG_WARNING, wrnMXP_PasswordRequestedButNotDefined, "Password requested but auto-connect not set to MXP."); else MXP_error (DBG_WARNING, wrnMXP_PasswordRequestedButNotDefined, "Password requested but none defined."); break; // end of PASSWORD // new para case MXP_ACTION_P: // experimental m_cLastChar = 0; m_bInParagraph = true; break; // end of MXP_ACTION_P // new line case MXP_ACTION_BR: bIgnoreUnusedArgs = true; // don't worry about args for now :) StartNewLine (true, 0); SetNewLineColour (0); break; // end of MXP_ACTION_BR // reset case MXP_ACTION_RESET: MXP_Off (); break; // end of MXP_ACTION_RESET // MXP options (MXP OFF, MXP DEFAULT_OPEN, MXP DEFAULT_SECURE etc. case MXP_ACTION_MXP: if (GetKeyword (ArgumentList, "off")) MXP_Off (true); /* if (GetKeyword (ArgumentList, "default_open")) { MXP_error (DBG_INFO, "MXP default mode now OPEN."); m_iMXP_defaultMode = eMXP_open; } // end of DEFAULT_OPEN if (GetKeyword (ArgumentList, "default_secure")) { MXP_error (DBG_INFO, "MXP default mode now SECURE."); m_iMXP_defaultMode = eMXP_secure; } // end of DEFAULT_SECURE if (GetKeyword (ArgumentList, "default_locked")) { MXP_error (DBG_INFO, "MXP default mode now LOCKED."); m_iMXP_defaultMode = eMXP_locked; } // end of DEFAULT_LOCKED if (GetKeyword (ArgumentList, "use_newlines")) { MXP_error (DBG_INFO, "Now interpreting newlines as normal."); m_bInParagraph = false; } // end of USE_NEWLINES if (GetKeyword (ArgumentList, "ignore_newlines")) { MXP_error (DBG_INFO, "Now ignoring newlines."); m_bInParagraph = true; } // end of IGNORE_NEWLINES */ break; // end of MXP_ACTION_MXP case MXP_ACTION_SCRIPT: MXP_error (DBG_INFO, infoMXP_ScriptCollectionStarted, "Script collection mode entered (discarding script)."); m_bMXP_script = true; break; // end of MXP_ACTION_SCRIPT case MXP_ACTION_HR: { // wrap up previous line if necessary if (m_pCurrentLine->len > 0) StartNewLine (true, 0); /* CString strLine; char * p = strLine.GetBuffer (m_nWrapColumn); memset (p, 175, m_nWrapColumn); strLine.ReleaseBuffer (m_nWrapColumn); AddToLine (strLine, 0); */ // mark line as HR line m_pCurrentLine->flags = HORIZ_RULE; StartNewLine (true, 0); // now finish this line } break; // end of MXP_ACTION_HR case MXP_ACTION_PRE: m_bPreMode = true; break; // end of MXP_ACTION_PRE case MXP_ACTION_UL: m_iListMode = eUnorderedList; m_iListCount = 0; break; // end of MXP_ACTION_UL case MXP_ACTION_OL: m_iListMode = eOrderedList; m_iListCount = 0; break; // end of MXP_ACTION_OL case MXP_ACTION_LI: { // wrap up previous line if necessary if (m_pCurrentLine->len > 0) StartNewLine (true, 0); CString strListItem = " * "; if (m_iListMode == eOrderedList) strListItem.Format (" %i. ", ++m_iListCount); AddToLine (strListItem, 0); } break; // end of MXP_ACTION_LI // pueblo tags we put here so we don't get warnings case MXP_ACTION_BODY : bIgnoreUnusedArgs = true; break; // just ignore it case MXP_ACTION_HEAD : bIgnoreUnusedArgs = true; break; // just ignore it case MXP_ACTION_HTML : bIgnoreUnusedArgs = true; break; // just ignore it case MXP_ACTION_TITLE: bIgnoreUnusedArgs = true; break; // just ignore it case MXP_ACTION_SAMP : bIgnoreUnusedArgs = true; break; // just ignore it case MXP_ACTION_CENTER : bIgnoreUnusedArgs = true; break; // just ignore it case MXP_ACTION_XCH_PANE : bIgnoreUnusedArgs = true; break; // just ignore it case MXP_ACTION_IMG : case MXP_ACTION_IMAGE: { GetKeyword (ArgumentList, "ismap"); // make sure we realise it is a keyword // detect newline treatment strArgument = GetArgument (ArgumentList,"xch_mode", 0, false); // get mode if (!strArgument.IsEmpty ()) { m_bPuebloActive = true; // for correct newline processing if (strArgument.CompareNoCase ("purehtml") == 0) m_bSuppressNewline = true; else if (strArgument.CompareNoCase ("html") == 0) m_bSuppressNewline = false; } // end of some sort of Pueblo strArgument = GetArgument (ArgumentList,"url", 0, false); // get link if (strArgument.IsEmpty () && PUEBLO_ACTIVE) strArgument = GetArgument (ArgumentList,"src", 0, false); // get link CString strFilename = GetArgument (ArgumentList,"fname", 0, false); // and file name if (!strArgument.IsEmpty ()) { CString strOldAction = strAction; int iFlags = pStyle->iFlags; COLORREF iForeColour = pStyle->iForeColour; COLORREF iBackColour = pStyle->iBackColour; // ensure on new line if (m_pCurrentLine->len > 0) StartNewLine (true, 0); // starting a new line may have deleted pStyle pStyle = m_pCurrentLine->styleList.GetTail (); if (m_bUseCustomLinkColour) { pStyle->iForeColour = m_iHyperlinkColour; // use hyperlink colour pStyle->iBackColour = colour2; pStyle->iFlags &= ~COLOURTYPE; // clear bits, eg. custom pStyle->iFlags |= COLOUR_RGB; } strArgument += strFilename; // append filename to URL strAction = strArgument; // hyperlink pStyle->iFlags &= ~ACTIONTYPE; // cancel old actions pStyle->iFlags |= ACTION_HYPERLINK; // send-to action if (m_bUnderlineHyperlinks) pStyle->iFlags |= UNDERLINE; // send-to action AddToLine ("[", 0); AddToLine (strArgument, 0); AddToLine ("]", 0); // have to add the action now, before we start a new line pStyle->pAction = GetAction (strAction, strHint, strVariable); strAction.Empty (); StartNewLine (true, 0); // new line after image tag // go back to old style (ie. lose the underlining) AddStyle (iFlags, iForeColour, iBackColour, 0, strOldAction); } } break; // end of MXP_ACTION_IMG case MXP_ACTION_XCH_PAGE: bIgnoreUnusedArgs = true; m_bPuebloActive = true; // for correct newline processing MXP_Off (); // same as <reset>? break; // end of MXP_ACTION_XCH_PAGE case MXP_ACTION_VAR: // set variable strVariable = GetArgument (ArgumentList,"", 1, false); // get name // case insensitive strVariable.MakeLower (); if (!IsValidName (strVariable)) { MXP_error (DBG_ERROR, errMXP_InvalidDefinition, TFormat ("Invalid MXP entity name: <!%s>", (LPCTSTR) strVariable)); strVariable.Empty (); return; } { // protect local variable CString strEntityContents; if (App.m_EntityMap.Lookup (strVariable, strEntityContents)) { MXP_error (DBG_ERROR, errMXP_CannotRedefineEntity, TFormat ("Cannot redefine entity: &%s;", (LPCTSTR) strVariable)); strVariable.Empty (); return; } } break; // end of MXP_ACTION_VAR default: { // warn them it is not implemented MXP_error (DBG_WARNING, wrnMXP_TagNotImplemented, TFormat ("MXP tag <%s> is not implemented" , (LPCTSTR) strTag)); } // end of default } // end of switch on iAction if (!bIgnoreUnusedArgs) CheckArgumentsUsed (strTag, ArgumentList); } // end of CMUSHclientDoc::MXP_OpenAtomicTag
BOOL IJA_llQueryTableTransaction ( CaQueryTransactionInfo* pQueryInfo, CTypedPtrList<CObList, CaColumn*>* pListColumn, CTypedPtrList < CObList, CaTableTransactionItemData* >& listTransaction) { CString strDatabase; CString strDatabaseOwner; CString strTable; CString strTableOwner; CString strStatement; pQueryInfo->GetDatabase (strDatabase, strDatabaseOwner); pQueryInfo->GetTable (strTable, strTableOwner); // // Open the session: CaTemporarySession session (pQueryInfo->GetNode(), strDatabase); if (!session.IsConnected()) { // // Failedto get Session. CString strMsg; strMsg.LoadString (IDS_FAIL_TO_GETSESSION); AfxMessageBox (strMsg); return FALSE; } CString strTempTable = _T(""); CString csGranteeList = _T(""); /* no grantee list required here */ BOOL bOK = IJA_TableAuditdbOutput (pQueryInfo, &session, strTempTable, pListColumn, csGranteeList); if (!bOK) { session.Release(SESSION_ROLLBACK); return FALSE; } BOOL bOnLocal = session.IsLocalNode(); // // STEP 1: Select row that are INSERT, DELETE, REPOLD, REPNEW // Select the rows (table transactions) from the newly created Table: CString strSessionPrefix = _T(""); if (bOnLocal) strSessionPrefix = _T("session."); strStatement.Format ( _T("select * from %s%s where operation in ('repold', 'repnew', 'append', 'insert', 'delete')"), (LPCTSTR)strSessionPrefix, (LPCTSTR)strTempTable); CaIjaCursor cursor(1, strStatement); if (cursor.Open()) { int nCount = 0; CStringList listData; CString strItem1; CString strItem2; while (cursor.Fetch(listData, nCount)) { CaTableTransactionItemData* pTran = new CaTableTransactionItemData(); POSITION pos = listData.GetHeadPosition(); ASSERT (listData.GetCount() >= 10); // At least 10 columns; if (listData.GetCount() < 10) { delete pTran; return FALSE; } pTran->SetTable (strTable); pTran->SetTableOwner (strTableOwner); if (pos != NULL) { // LSN: strItem1 = listData.GetNext (pos); strItem2 = listData.GetNext (pos); pTran->SetLsn (_ttoul(strItem1), _ttoul(strItem2)); // TID: strItem1 = listData.GetNext (pos); pTran->SetTid(_ttol(strItem1)); // Date: strItem1 = listData.GetNext (pos); pTran->SetDate(strItem1); // User Name: strItem1 = listData.GetNext (pos); pTran->SetUser (strItem1); // Operation: strItem1 = listData.GetNext (pos); if (strItem1.CompareNoCase (_T("insert")) == 0 || strItem1.CompareNoCase (_T("append")) == 0) pTran->SetOperation (T_INSERT); else if (strItem1.CompareNoCase (_T("delete")) == 0) pTran->SetOperation (T_DELETE); else if (strItem1.CompareNoCase (_T("repold")) == 0) pTran->SetOperation (T_BEFOREUPDATE); else if (strItem1.CompareNoCase (_T("repnew")) == 0) pTran->SetOperation (T_AFTERUPDATE); else { ASSERT (FALSE); pTran->SetOperation (T_UNKNOWN); } // Transaction: strItem1 = listData.GetNext (pos); strItem2 = listData.GetNext (pos); pTran->SetTransactionID (_ttoul(strItem1), _ttoul(strItem2)); // Ignore: strItem1 = listData.GetNext (pos); strItem2 = listData.GetNext (pos); } pTran->SetCommit (TRUE); pTran->SetJournal (TRUE); CStringList& listAuditedData = pTran->GetListData(); while (pos != NULL) { strItem1 = listData.GetNext (pos); listAuditedData.AddTail(strItem1); } listTransaction.AddTail (pTran); listData.RemoveAll(); } cursor.Close(); } // // STEP 2: Select rows that are COMMIT, ABORT, COMMITNJ, ABORTNJ // to update the previous select result if the rows are commit, abort, ... // Select the rows (table transactions) from the newly created Table: strStatement.Format ( _T("select * from %s%s where operation in ('commit', 'abort', 'commitnj', 'abortnj')"), (LPCTSTR)strSessionPrefix, (LPCTSTR)strTempTable); CaIjaCursor cursor2(2, strStatement); if (cursor2.Open()) { CaTableTransactionItemData* pFound = NULL; int nCount = 0; CStringList listData; CString strItem1; CString strItem2; CString strOperation; while (cursor2.Fetch(listData, nCount)) { POSITION pos = listData.GetHeadPosition(); ASSERT (listData.GetCount() >= 10); // At least 10 columns; if (listData.GetCount() < 10) return FALSE; if (pos != NULL) { // LSN: strItem1 = listData.GetNext (pos); strItem2 = listData.GetNext (pos); // Ignore: strItem1 = listData.GetNext (pos); // Date: strItem1 = listData.GetNext (pos); // User Name: strItem1 = listData.GetNext (pos); // Operation: strOperation = listData.GetNext (pos); // Transaction: strItem1 = listData.GetNext (pos); strItem2 = listData.GetNext (pos); TRANSACTION_ChangeState (_ttoul(strItem1), _ttoul(strItem2), strOperation, listTransaction); // Ignore: strItem1 = listData.GetNext (pos); strItem2 = listData.GetNext (pos); } listData.RemoveAll(); } cursor2.Close(); } // // Make sure that the temporary table has been destroyed: if (!bOnLocal && bOK && !strTempTable.IsEmpty()) { strStatement.Format ( _T("drop table %s"), (LPCTSTR)strTempTable); CaLowlevelAddAlterDrop param (pQueryInfo->GetNode(), strDatabase, strStatement); param.NeedSession(FALSE); // Use the current open session. param.SetStatement(strStatement); if (!param.ExecuteStatement(NULL)) { CString strMsg; strMsg.LoadString(IDS_FAIL_DROP_TEMP_TABLE); AfxMessageBox(strMsg); } } session.Release(); // Release session and commit. return TRUE; }
void CHomeSearchCtrl::Search(bool bAutostart) { CString strText, strURI, strEntry, strClear; m_wndText.GetWindowText( strText ); strText.TrimLeft(); strText.TrimRight(); LoadString( strClear, IDS_SEARCH_PAD_CLEAR_HISTORY ); if ( _tcscmp ( strClear , strText ) == 0 ) return; // Check if user mistakenly pasted download link to search input box if (theApp.OpenURL( strText, TRUE, TRUE ) ) { m_wndText.SetWindowText( _T("") ); return; } CSchemaPtr pSchema = m_wndSchema.GetSelected(); if ( pSchema != NULL ) strURI = pSchema->GetURI(); Settings.Search.LastSchemaURI = strURI; CQuerySearchPtr pSearch = new CQuerySearch(); pSearch->m_bAutostart = bAutostart; pSearch->m_sSearch = strText; pSearch->m_pSchema = pSchema; BOOL bValid = pSearch->CheckValid( false ); if ( ! bValid && bAutostart ) { // Invalid search, open help window CQuerySearch::SearchHelp(); } else if ( AdultFilter.IsSearchFiltered( pSearch->m_sSearch ) && bAutostart ) { // Adult search blocked, open help window CHelpDlg::Show( _T("SearchHelp.AdultSearch") ); } else { if ( bValid ) { // Load all CStringList oList; for ( int i = 0; ; i++ ) { strEntry.Format( _T("Search.%.2i"), i + 1 ); CString strValue( theApp.GetProfileString( _T("Search"), strEntry ) ); if ( strValue.IsEmpty() ) break; int lf = strValue.Find( _T('\n') ); if ( strText.CompareNoCase( ( lf != -1 ) ? strValue.Left( lf ) : strValue ) ) oList.AddTail( strValue ); } // Cut to 200 items while ( oList.GetCount() >= 200 ) oList.RemoveTail(); // New one (at top) oList.AddHead( strURI.IsEmpty() ? strText : ( strText + _T('\n') + strURI ) ); // Save list POSITION pos = oList.GetHeadPosition(); for ( int i = 0; pos; ++i ) { strEntry.Format( _T("Search.%.2i"), i + 1 ); theApp.WriteProfileString( _T("Search"), strEntry, oList.GetNext( pos ) ); } FillHistory(); } new CSearchWnd( pSearch ); } m_wndText.SetWindowText( _T("") ); }
BOOL CSetSavedDataPage::OnInitDialog() { ISettingsPropPage::OnInitDialog(); // find out how many log messages and URLs we've stored int nLogHistWC = 0; INT_PTR nLogHistMsg = 0; int nUrlHistWC = 0; INT_PTR nUrlHistItems = 0; int nLogHistRepo = 0; CRegistryKey regloghist(_T("Software\\TortoiseGit\\History")); CStringList loghistlist; regloghist.getSubKeys(loghistlist); for (POSITION pos = loghistlist.GetHeadPosition(); pos != NULL; ) { CString sHistName = loghistlist.GetNext(pos); if (sHistName.Left(6).CompareNoCase(_T("commit"))==0) { nLogHistWC++; CRegistryKey regloghistwc(_T("Software\\TortoiseGit\\History\\")+sHistName); CStringList loghistlistwc; regloghistwc.getValues(loghistlistwc); nLogHistMsg += loghistlistwc.GetCount(); } else { // repoURLs CStringList urlhistlistmain; CStringList urlhistlistmainvalues; CRegistryKey regurlhistlist(_T("Software\\TortoiseGit\\History\\repoURLS")); regurlhistlist.getSubKeys(urlhistlistmain); regurlhistlist.getValues(urlhistlistmainvalues); nUrlHistItems += urlhistlistmainvalues.GetCount(); for (POSITION urlpos = urlhistlistmain.GetHeadPosition(); urlpos != NULL; ) { CString sWCUID = urlhistlistmain.GetNext(urlpos); nUrlHistWC++; CStringList urlhistlistwc; CRegistryKey regurlhistlistwc(_T("Software\\TortoiseGit\\History\\repoURLS\\")+sWCUID); regurlhistlistwc.getValues(urlhistlistwc); nUrlHistItems += urlhistlistwc.GetCount(); } } } // find out how many dialog sizes / positions we've stored INT_PTR nResizableDialogs = 0; CRegistryKey regResizable(_T("Software\\TortoiseGit\\TortoiseProc\\ResizableState")); CStringList resizablelist; regResizable.getValues(resizablelist); nResizableDialogs += resizablelist.GetCount(); // find out how many auth data we've stored int nSimple = 0; int nSSL = 0; int nUsername = 0; CString sFile; bool bIsDir = false; TCHAR pathbuf[MAX_PATH] = {0}; if (SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, SHGFP_TYPE_CURRENT, pathbuf)==S_OK) { _tcscat_s(pathbuf, MAX_PATH, _T("\\Subversion\\auth\\")); CString sSimple = CString(pathbuf) + _T("svn.simple"); CString sSSL = CString(pathbuf) + _T("svn.ssl.server"); CString sUsername = CString(pathbuf) + _T("svn.username"); CDirFileEnum simpleenum(sSimple); while (simpleenum.NextFile(sFile, &bIsDir)) nSimple++; CDirFileEnum sslenum(sSSL); while (sslenum.NextFile(sFile, &bIsDir)) nSSL++; CDirFileEnum userenum(sUsername); while (userenum.NextFile(sFile, &bIsDir)) nUsername++; } CDirFileEnum logenum(CPathUtils::GetAppDataDirectory()+_T("logcache")); while (logenum.NextFile(sFile, &bIsDir)) nLogHistRepo++; // the "Repositories.dat" is not a cache file nLogHistRepo--; BOOL bActionLog = PathFileExists(CPathUtils::GetAppDataDirectory() + _T("logfile.txt")); m_btnLogHistClear.EnableWindow(nLogHistMsg || nLogHistWC); m_btnUrlHistClear.EnableWindow(nUrlHistItems || nUrlHistWC); m_btnResizableHistClear.EnableWindow(nResizableDialogs > 0); m_btnAuthHistClear.EnableWindow(nSimple || nSSL || nUsername); m_btnRepoLogClear.EnableWindow(nLogHistRepo >= 0); m_btnActionLogClear.EnableWindow(bActionLog); m_btnActionLogShow.EnableWindow(bActionLog); EnableToolTips(); m_tooltips.Create(this); CString sTT; sTT.Format(IDS_SETTINGS_SAVEDDATA_LOGHIST_TT, nLogHistMsg, nLogHistWC); m_tooltips.AddTool(IDC_LOGHISTORY, sTT); m_tooltips.AddTool(IDC_LOGHISTCLEAR, sTT); sTT.Format(IDS_SETTINGS_SAVEDDATA_URLHIST_TT, nUrlHistItems, nUrlHistWC); m_tooltips.AddTool(IDC_URLHISTORY, sTT); m_tooltips.AddTool(IDC_URLHISTCLEAR, sTT); sTT.Format(IDS_SETTINGS_SAVEDDATA_RESIZABLE_TT, nResizableDialogs); m_tooltips.AddTool(IDC_RESIZABLEHISTORY, sTT); m_tooltips.AddTool(IDC_RESIZABLEHISTCLEAR, sTT); sTT.Format(IDS_SETTINGS_SAVEDDATA_AUTH_TT, nSimple, nSSL, nUsername); m_tooltips.AddTool(IDC_AUTHHISTORY, sTT); m_tooltips.AddTool(IDC_AUTHHISTCLEAR, sTT); sTT.Format(IDS_SETTINGS_SAVEDDATA_REPOLOGHIST_TT, nLogHistRepo); m_tooltips.AddTool(IDC_REPOLOG, sTT); m_tooltips.AddTool(IDC_REPOLOGCLEAR, sTT); sTT.LoadString(IDS_SETTINGS_SHOWACTIONLOG_TT); m_tooltips.AddTool(IDC_ACTIONLOGSHOW, sTT); sTT.LoadString(IDS_SETTINGS_MAXACTIONLOGLINES_TT); m_tooltips.AddTool(IDC_MAXLINES, sTT); sTT.LoadString(IDS_SETTINGS_CLEARACTIONLOG_TT); m_tooltips.AddTool(IDC_ACTIONLOGCLEAR, sTT); return TRUE; }
BOOL CCoolServApp::AddResources(CStringList& collRezFiles) { // Specify the main resources... ServerInterface* pServerMgr = GetServerInterface(); if (!pServerMgr) return(FALSE); char sTemps[128][128]; char* sGame[128]; int i = 0; char* sGameRez = GetGameRezFile(); char* sSoundRez = GetSoundRezFile(); sGame[i++] = sGameRez; if (sSoundRez && sSoundRez[0] != '\0') sGame[i++] = sSoundRez; sGame[i++] = "custom"; // Specify the patch, test, and language resources... char sGameRezBase[64] = { "" }; LoadString(g_hInst, IDS_REZBASE, sGameRezBase, 60); ADDREZ(sGameRezBase, "P"); ADDREZ(sGameRezBase, "P2"); ADDREZ(sGameRezBase, "P3"); ADDREZ(sGameRezBase, "P4"); ADDREZ(sGameRezBase, "P5"); ADDREZ(sGameRezBase, "P6"); ADDREZ(sGameRezBase, "P7"); ADDREZ(sGameRezBase, "P8"); ADDREZ(sGameRezBase, "P9"); ADDREZ(sGameRezBase, "T"); ADDREZ(sGameRezBase, "L"); // Specify the custom resources... POSITION pos = collRezFiles.GetHeadPosition(); while (pos) { CString sRezFile = collRezFiles.GetNext(pos); strcpy(sTemps[i], sRezFile); sGame[i] = sTemps[i]; i++; } // Add the resources... char** sResources = sGame; DBOOL db; { CWaitCursor wc; db = pServerMgr->AddResources(sResources, i); } if (db != DTRUE) { AfxMessageBox(IDS_ERROR_LOADREZ); return(FALSE); } // All done... return(TRUE); }
// 把英文名代入替换规则获取新的英文名 int CTyBase::GetEname_From_ReplacRule(CString vDotName,CString& vDstDotName, CStringList& ruleList) { vDstDotName = vDotName; int ret = -1; char srcStr[17],dstStr[17]; char * token; char seps[] = ","; int len; BOOL bFind = false; POSITION pos = ruleList.GetHeadPosition(); CString str; char buf[256]; memset(buf,0,sizeof(char)*256); while (pos != NULL) { memset(srcStr,0,sizeof(char)*17); memset(dstStr,0,sizeof(char)*17); str = ruleList.GetNext(pos); if (strlen(str) <= 0) continue; strcpy(buf,str); switch (str[0]) { case '1': { token = strtok( buf, seps ); token = strtok( NULL, seps ); ASSERT(strlen(token) < 16); len = min(16,strlen(token)); strncpy(srcStr,token,len); token = strtok( NULL, seps ); ASSERT(strlen(token) < 16); len = min(16,strlen(token)); strncpy(dstStr,token,len); if (_strnicmp(vDotName,srcStr,strlen(srcStr)) == 0) { bFind = true; vDstDotName.Delete(0,strlen(srcStr)); vDstDotName.Insert(0,dstStr); ASSERT(vDstDotName.GetLength() < 17); if (vDstDotName.GetLength() >= 17) vDstDotName.Truncate(16); ret = 1; } } break; default: break; } if (bFind) break; } return ret; }
// Specific print methods according to pane type void CvSqlQueryLowerView::PrintSelect(CDC* pDC, int pageNum, int x, int &y, CaQuerySelectPageData* pPageData, int pageDataHeight) { ASSERT (pPageData->IsKindOf(RUNTIME_CLASS(CaQuerySelectPageData))); // Tuples caption pDC->SelectObject(&m_printerCaptFont); CString csTuplesCapt(_T("Resulting Tuples:")); pDC->TextOut(x, y, csTuplesCapt); y += m_nCaptLineHeight; y += m_nCaptLineHeight/2; pDC->SelectObject(&m_printerFont); y += m_nLineHeight; // Extra blank line // // Tuples // // Tuples header: // Note: pPageData->m_listRows.m_nHeaderCount CANNOT BE USED - must loop on position // Calculate columns margins for a nice frame rectangle display int colMarginX = (2+2) * m_PixelXPrintScale; // Spare 2 pixels left and 2 pixels right between text and frame int colMarginY = (1+1) * m_PixelYPrintScale; // Spare 1 pixel top and 1 pixel bottom between text and frame ASSERT (colMarginX % 2 == 0); // must be even ASSERT (colMarginY % 2 == 0); // must be even /* ////////////// TO BE KEPT - EMPHASIZES PRINTER PROBLEM IN ALIGNMENT // Draw rectangle CRect rect(2010, y, 2208, y + m_nLineHeight + colMarginY ); rect.right++; rect.bottom++; pDC->Rectangle(rect); rect.right--; rect.bottom--; // Draw text rect.DeflateRect(colMarginX / 2, colMarginY / 2); UINT nFormat = DT_VCENTER | DT_SINGLELINE | DT_LEFT; CString cs = "Erreur!"; pDC->DrawText(cs, rect, nFormat); y += m_nLineHeight + colMarginY; return; ////////////// TO BE KEPT - EMPHASIZES PRINTER PROBLEM IN ALIGNMENT */ POSITION posHeader = pPageData->m_listRows.m_listHeaders.GetHeadPosition(); int colCount = 0; int usedWidth = 0; while (posHeader) { CaQueryResultRowsHeader* pHeader = pPageData->m_listRows.m_listHeaders.GetNext(posHeader); ASSERT (pHeader); int printColWidth = pHeader->m_nWidth * m_PixelXPrintScale; if (printColWidth + colMarginX + usedWidth > m_nPageWidth) break; // Don't use this column, stop the loop // Draw rectangle CRect rect(usedWidth, y, usedWidth + printColWidth + colMarginX, y + m_nBoldLineHeight + colMarginY); rect.right++; rect.bottom++; pDC->Rectangle(rect); rect.right--; rect.bottom--; // Draw text pDC->SelectObject(&m_printerBoldFont); rect.DeflateRect(colMarginX / 2, colMarginY / 2); pDC->DrawText(pHeader->m_strHeader, rect, DT_CENTER | DT_VCENTER | DT_SINGLELINE); pDC->SelectObject(&m_printerFont); // Update loop variables usedWidth += printColWidth + colMarginX; colCount++; } // One line has been drawn y += m_nBoldLineHeight + colMarginY; // Now colCount contains number of displayable columns according to page width ASSERT (colCount > 0); // Tuples POSITION posRow = pPageData->m_listRows.m_listAdjacent.GetHeadPosition(); BOOL bFirstTime2 = TRUE; int curCol = 0; for (curCol=0; posRow; curCol++) { // Skip uninteresting lines (n/a , etc...) CStringList* pRow = pPageData->m_listRows.m_listAdjacent.GetNext(posRow); ASSERT (pRow); int rowData = pPageData->m_listRows.m_aItemData[curCol]; BOOL bSkip = FALSE; switch (rowData) { case 0: // normal lines: print break; case 1: // head lines : skip if n/a { POSITION posCol = pRow->GetHeadPosition(); CString cs = pRow->GetNext(posCol); if (cs == _T("n/a")) bSkip = TRUE; } break; case 2: if (bFirstTime2) bFirstTime2 = FALSE; else bSkip = TRUE; break; default: ASSERT (FALSE); break; } if (bSkip) continue; // skip the line (continue the for() ) // First, check line to be printed does not overlap 2 pages int curLinePage = y / pageDataHeight; int nextLinePage = (y + m_nLineHeight + colMarginY) / pageDataHeight; ASSERT (nextLinePage >= curLinePage); if (nextLinePage > curLinePage) y = nextLinePage * pageDataHeight; POSITION posCol = pRow->GetHeadPosition(); posHeader = pPageData->m_listRows.m_listHeaders.GetHeadPosition(); // use the first "colCount" columns usedWidth = 0; for (int cptCol = 0; cptCol < colCount; cptCol++) { // Pick column width and align info CaQueryResultRowsHeader* pHeader = pPageData->m_listRows.m_listHeaders.GetNext(posHeader); ASSERT (pHeader); int printColWidth = pHeader->m_nWidth * m_PixelXPrintScale; int printAlign = pHeader->m_nAlign; // Pick column displayable text CString cs = pRow->GetNext(posCol); if (rowData == 2) cs.LoadString(IDS_NEXT_TUPLES_UNAVAILABLE); //= _T("< Next tuples not available >"); // Draw rectangle CRect rect(usedWidth, y, usedWidth + printColWidth + colMarginX, y + m_nLineHeight + colMarginY ); rect.right++; rect.bottom++; pDC->Rectangle(rect); rect.right--; rect.bottom--; // Draw text rect.DeflateRect(colMarginX / 2, colMarginY / 2); UINT nFormat = DT_VCENTER | DT_SINGLELINE; int horzAlign = (printAlign & (LVCFMT_RIGHT | LVCFMT_CENTER | LVCFMT_LEFT)); switch (horzAlign) { case LVCFMT_RIGHT: nFormat |= DT_RIGHT; break; case LVCFMT_CENTER: nFormat |= DT_CENTER; break; case LVCFMT_LEFT: nFormat |= DT_LEFT; break; default: ASSERT(FALSE); nFormat |= DT_LEFT; break; } pDC->DrawText(cs, rect, nFormat); // Update loop variables usedWidth += printColWidth + colMarginX; } y += m_nLineHeight + colMarginY; } }
void CExploreMsgSg::OnItemchangedLstcMsgs(NMHDR* pNMHDR, LRESULT* pResult) { NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR; // User wants the signal details if ( m_eSelectType == SEL_SIGNAL ) { if(pNMListView->uNewState == (LVIS_FOCUSED |LVIS_SELECTED) ) { // Delete every other item from the list box. m_omSignalListBox.ResetContent(); // Get handle to selected message item int hSelItem = pNMListView->iItem; if ( (hSelItem != -1) ) { CStringList omSignalNames; omSignalNames.RemoveAll(); // Store last selection m_nMsgIndex = hSelItem; // Get selected message name m_omStrMessageName = m_omMsgList.GetItemText( hSelItem, 0 ); DWORD dwMsgCode = (COMMANDWORD)m_omMsgList.GetItemData(hSelItem); vGetSigNamesFromMsgCode(dwMsgCode, omSignalNames); // Add signal names into the list box POSITION pos = omSignalNames.GetHeadPosition(); while ( pos != NULL ) { m_omSignalListBox.AddString( omSignalNames.GetNext(pos)); } m_omSignalListBox.SetCurSel( 0 ); // Set horizontal extent of the list // box to max string availaable // so that user can scroll CSize sz; CString omStrText; CDC* pDC = m_omSignalListBox.GetDC(); if ( pDC != NULL) { int nDx = 0; for (int nCount = 0; nCount < m_omSignalListBox.GetCount(); nCount++) { m_omSignalListBox.GetText( nCount, omStrText ); // remove space omStrText.TrimRight(); sz = pDC->GetTextExtent(omStrText); if (sz.cx > nDx) { nDx = sz.cx; } } m_omSignalListBox.ReleaseDC(pDC); // Set the horizontal extent so every character of all // strings can be scrolled to. m_omSignalListBox.SetHorizontalExtent(nDx); } } } } else { // Store last selection m_nMsgIndex = pNMListView->iItem ; } *pResult = 0; }
void CCmd_ListOpStat::PreProcess(BOOL& done) { int i; POSITION pos; CCmd_ListOp cmd1(m_pClient); // Set up and run ListOp synchronously cmd1.Init(NULL, RUN_SYNC); cmd1.SetChkForSyncs(m_ChkForSyncs); cmd1.SetWarnIfLocked(m_WarnIfLocked); if(cmd1.Run(m_pFileSpecs, m_Command, m_ChangeNumber, m_NewType)) { m_FatalError= cmd1.GetError(); done=TRUE; if (m_ChkForSyncs) { CStringList * pSyncList = cmd1.GetSyncList(); if (!pSyncList->IsEmpty()) { for( pos= pSyncList->GetHeadPosition(); pos!= NULL; ) m_Unsynced.AddHead( pSyncList->GetNext(pos) ); CStringList * pEditList = cmd1.GetList(); for( pos= pEditList->GetHeadPosition(); pos!= NULL; ) { CString txt = pEditList->GetNext(pos); if ((i = txt.Find(_T('#'))) != -1) txt = txt.Left(i); m_RevertIfCancel.AddHead( txt ); } } else m_ChkForSyncs = FALSE; } } else { m_ErrorTxt= _T("Unable to Run ListOp"); m_FatalError=TRUE; } // Extract the CStringList from ListOp, which has filtered // results for the command. Note that Errors, warnings and // gee-whiz info have been thrown to the status window and // are not in the list CStringList *strList= cmd1.GetList(); // Check for huge file sets, where incremental screen update can take // a very looong time to complete. We are more tolerant for repoens, // because they involve updates in only one pane if(!m_FatalError && m_Command== P4REOPEN && strList->GetCount() > (3 * MAX_FILESEEKS)) { m_HitMaxFileSeeks= TRUE; TheApp()->StatusAdd(_T("CCmd_ListOpStat/P4REOPEN hit MAX_FILESEEKS - blowing off incremental update"), SV_DEBUG); } else if(!m_FatalError && m_Command!= P4REOPEN && strList->GetCount() > MAX_FILESEEKS) { m_HitMaxFileSeeks= TRUE; TheApp()->StatusAdd(_T("CCmd_ListOpStat hit MAX_FILESEEKS - blowing off incremental update"), SV_DEBUG); } // In the usual case of zero to a few hundred files, gather ostat-like info // for each file so that screen updates can be completed else if(!m_FatalError && strList->GetCount() > 0) { // Save a copy of the stringlist. for( pos= strList->GetHeadPosition(); pos!= NULL; ) m_StrListOut.AddHead( strList->GetNext(pos) ); // See if we need to run Ostat if(m_Command==P4EDIT || m_Command==P4DELETE) { // Set up and run ostat synchronously CCmd_Ostat cmd2(m_pClient); cmd2.Init(NULL, RUN_SYNC); if(cmd2.Run(FALSE, m_ChangeNumber)) m_FatalError= cmd2.GetError(); else { m_ErrorTxt= _T("Unable to Run Ostat"); m_FatalError=TRUE; } CObArray const *array= cmd2.GetArray(); if(!m_FatalError && array->GetSize() > 0) { // Save a copy of the oblist. for( int i=0; i < array->GetSize(); i++ ) m_StatList.AddHead( array->GetAt(i) ); } } else PrepareStatInfo(); } // Post the completion message if(!m_FatalError) { CString message; int already = 0; int reopened = 0; switch(m_Command) { case P4EDIT: for( pos= strList->GetHeadPosition(); pos!= NULL; ) { CString str = strList->GetNext(pos); if (str.Find(_T(" - currently opened ")) != -1) already++; else if (str.Find(_T(" - reopened ")) != -1) reopened++; } message.FormatMessage(IDS_OPENED_n_FILES_FOR_EDIT, strList->GetCount() - already - reopened); if (reopened) message.FormatMessage(IDS_s_n_FILES_REOPENED, message, reopened); if (already) message.FormatMessage(IDS_s_n_FILES_ALREADY_OPENED, message, already); break; case P4REOPEN: message.FormatMessage(IDS_REOPENED_n_FILES, strList->GetCount()); break; case P4REVERT: case P4VIRTREVERT: m_OutputError = cmd1.GetOutputErrFlag(); message.FormatMessage(m_OutputError ? IDS_ERROR_REVERTING_n_FILES : IDS_REVERTED_n_FILES, strList->GetCount()); break; case P4REVERTUNCHG: m_OutputError = cmd1.GetOutputErrFlag(); if (m_OutputError) message.FormatMessage(IDS_ERROR_REVERTING_n_FILES, strList->GetCount()); else if (m_NbrChgedFilesReverted) message.FormatMessage(IDS_REVERTED_n_FILES_n_CHG_n_UNCHG, m_NbrChgedFilesReverted + strList->GetCount(), m_NbrChgedFilesReverted, strList->GetCount()); else message.FormatMessage(IDS_REVERTED_n_FILES, strList->GetCount()); break; case P4LOCK: message.FormatMessage(IDS_LOCKED_n_FILES, strList->GetCount()); break; case P4UNLOCK: message.FormatMessage(IDS_UNLOCKED_n_FILES, strList->GetCount()); break; case P4DELETE: for( pos= strList->GetHeadPosition(); pos!= NULL; ) { CString str = strList->GetNext(pos); if (str.Find(_T(" - currently opened ")) != -1) already++; else if (str.Find(_T(" - reopened ")) != -1) reopened++; } message.FormatMessage(IDS_OPENED_n_FILES_FOR_DELETE, strList->GetCount() - already - reopened); if (reopened) message.FormatMessage(IDS_s_n_FILES_REOPENED, message, reopened); if (already) message.FormatMessage(IDS_s_n_FILES_ALREADY_OPENED, message, already); break; case P4ADD: message.FormatMessage(IDS_OPENED_n_FILES_FOR_ADD, strList->GetCount()); break; default: ASSERT(0); } if(!message.IsEmpty()) TheApp()->StatusAdd( message, SV_COMPLETION ); } done=TRUE; }
BOOL CBCGPODBCGridCtrl::OpenSQL (LPCTSTR lpszSQL) { ASSERT (lpszSQL != NULL); m_strSQL.Empty (); RemoveAll (); if (!m_bIsSorting) { DeleteAllColumns (); } if (m_pDataBase == NULL) { ASSERT (FALSE); return FALSE; } try { ASSERT_VALID (m_pDataBase); if (!m_pDataBase->IsOpen ()) { ASSERT (FALSE); return FALSE; } if (m_pRecordSet != NULL) { ASSERT_VALID (m_pRecordSet); if (m_pRecordSet->IsOpen ()) { m_pRecordSet->Close (); } delete m_pRecordSet; m_pRecordSet = NULL; } //--------------------------------------------------------- // Create a new record set and open it using SQL statement: //--------------------------------------------------------- m_pRecordSet = new CRecordset (m_pDataBase); if (!m_pRecordSet->Open (CRecordset::dynaset, lpszSQL)) { return FALSE; } int nColumns = 0; if (!m_bIsSorting) { //------------- // Add columns: //------------- CStringList lstField; if (!GetFieldList (lstField)) { return FALSE; } int nColumn = 0; for (POSITION pos = lstField.GetHeadPosition (); pos != NULL; nColumn++) { InsertColumn (nColumn, lstField.GetNext (pos), 50); } nColumns = (int) lstField.GetCount (); } else { nColumns = GetColumnCount (); } if (nColumns == 0) { // No columns AdjustLayout (); return TRUE; } //------------- // Add records: //------------- if (m_pRecordSet->IsEOF () && m_pRecordSet->IsBOF ()) { // The table is empty AdjustLayout (); return TRUE; } if (m_bVirtualMode) { while (!m_pRecordSet->IsEOF ()) { m_pRecordSet->MoveNext (); } SetVirtualRows (max (0, m_pRecordSet->GetRecordCount ())); } else { for (int nRow = 0; !m_pRecordSet->IsEOF (); m_pRecordSet->MoveNext (), nRow++) { CBCGPGridRow* pRow = CreateRow (nColumns); ASSERT_VALID (pRow); for (int nColumn = 0; nColumn < nColumns; nColumn++) { OnAddData (pRow, nColumn, nRow); } if (OnBeforeAddRow (pRow, nRow)) { AddRow (pRow, FALSE); } else { delete pRow; } } } m_strSQL = lpszSQL; AdjustLayout (); if (!m_pRecordSet->CanUpdate ()) { SetReadOnly (); } } catch (CDBException* pEx) { OnODBCException (pEx); pEx->Delete (); return FALSE; } return TRUE; }
OSStatus CThirdPage::LoadPrintDriverDefsFromFile(Manufacturers & manufacturers, const CString & filename, bool checkForDuplicateModels ) { HINF handle = INVALID_HANDLE_VALUE; const TCHAR * section = TEXT( "Manufacturer" ); LONG sectionCount; TCHAR line[ 1000 ]; CString klass; INFCONTEXT manufacturerContext; BOOL ok; OSStatus err = 0; // Make sure we can open the file handle = SetupOpenInfFile( filename, NULL, INF_STYLE_WIN4, NULL ); translate_errno( handle != INVALID_HANDLE_VALUE, GetLastError(), kUnknownErr ); require_noerr( err, exit ); // Make sure it's a printer file ok = SetupGetLineText( NULL, handle, TEXT( "Version" ), TEXT( "Class" ), line, sizeof( line ), NULL ); translate_errno( ok, GetLastError(), kUnknownErr ); require_noerr( err, exit ); klass = line; require_action( klass == TEXT( "Printer" ), exit, err = kUnknownErr ); sectionCount = SetupGetLineCount( handle, section ); translate_errno( sectionCount != -1, GetLastError(), kUnknownErr ); require_noerr( err, exit ); memset( &manufacturerContext, 0, sizeof( manufacturerContext ) ); for ( LONG i = 0; i < sectionCount; i++ ) { Manufacturers::iterator iter; Manufacturer * manufacturer; CString manufacturerName; CString temp; CStringList modelSectionNameDecl; CString modelSectionName; CString baseModelName; CString model; INFCONTEXT modelContext; LONG modelCount; POSITION p; if ( i == 0 ) { ok = SetupFindFirstLine( handle, section, NULL, &manufacturerContext ); err = translate_errno( ok, GetLastError(), kUnknownErr ); require_noerr( err, exit ); } else { ok = SetupFindNextLine( &manufacturerContext, &manufacturerContext ); err = translate_errno( ok, GetLastError(), kUnknownErr ); require_noerr( err, exit ); } ok = SetupGetStringField( &manufacturerContext, 0, line, sizeof( line ), NULL ); err = translate_errno( ok, GetLastError(), kUnknownErr ); require_noerr( err, exit ); manufacturerName = line; ok = SetupGetLineText( &manufacturerContext, handle, NULL, NULL, line, sizeof( line ), NULL ); err = translate_errno( ok, GetLastError(), kUnknownErr ); require_noerr( err, exit ); // Try to find some model section name that has entries. Explanation of int file structure // can be found at: // // <http://msdn.microsoft.com/en-us/library/ms794359.aspx> Split( line, ',', modelSectionNameDecl ); p = modelSectionNameDecl.GetHeadPosition(); modelSectionName = modelSectionNameDecl.GetNext( p ); modelCount = SetupGetLineCount( handle, modelSectionName ); baseModelName = modelSectionName; while ( modelCount <= 0 && p ) { CString targetOSVersion; targetOSVersion = modelSectionNameDecl.GetNext( p ); modelSectionName = baseModelName + TEXT( "." ) + targetOSVersion; modelCount = SetupGetLineCount( handle, modelSectionName ); } if ( modelCount > 0 ) { manufacturerName = NormalizeManufacturerName( manufacturerName ); iter = manufacturers.find( manufacturerName ); if ( iter != manufacturers.end() ) { manufacturer = iter->second; require_action( manufacturer, exit, err = kUnknownErr ); } else { try { manufacturer = new Manufacturer; } catch (...) { manufacturer = NULL; } require_action( manufacturer, exit, err = kNoMemoryErr ); manufacturer->name = manufacturerName; manufacturers[ manufacturerName ] = manufacturer; } memset( &modelContext, 0, sizeof( modelContext ) ); for ( LONG j = 0; j < modelCount; j++ ) { CString modelName; Model * model; if ( j == 0 ) { ok = SetupFindFirstLine( handle, modelSectionName, NULL, &modelContext ); err = translate_errno( ok, GetLastError(), kUnknownErr ); require_noerr( err, exit ); } else { SetupFindNextLine( &modelContext, &modelContext ); err = translate_errno( ok, GetLastError(), kUnknownErr ); require_noerr( err, exit ); } ok = SetupGetStringField( &modelContext, 0, line, sizeof( line ), NULL ); err = translate_errno( ok, GetLastError(), kUnknownErr ); require_noerr( err, exit ); modelName = line; if (checkForDuplicateModels == true) { if ( MatchModel( manufacturer, ConvertToModelName( modelName ) ) != NULL ) { continue; } } // // Stock Vista printer inf files embed guids in the model // declarations for Epson printers. Let's ignore those. // if ( modelName.Find( TEXT( "{" ), 0 ) != -1 ) { continue; } try { model = new Model; } catch (...) { model = NULL; } require_action( model, exit, err = kNoMemoryErr ); model->infFileName = filename; model->displayName = modelName; model->name = modelName; model->driverInstalled = false; manufacturer->models.push_back(model); } } } exit: if ( handle != INVALID_HANDLE_VALUE ) { SetupCloseInfFile( handle ); handle = NULL; } return err; }
BOOL CConfigDisplay::verifySkin(CString skin, BOOL stopOnError) { #ifdef _DEBUGBC return TRUE; #endif //AutoLog alog("CCD::verifySkin"); CStringList bmps; bmps.AddTail(MB_SKIN_DEF); bmps.AddTail(MB_SKIN_ALBUMART); bmps.AddTail(MB_SKIN_BACKGROUNDMAIN); bmps.AddTail(MB_SKIN_BACKGROUNDALBUMART); bmps.AddTail(MB_SKIN_BACKGROUNDLIBRARY); bmps.AddTail(MB_SKIN_BACKGROUNDMAIN); bmps.AddTail(MB_SKIN_BACKGROUNDPLAYLIST); bmps.AddTail(MB_SKIN_BUTTONLOGOOUT); bmps.AddTail(MB_SKIN_BUTTONLOGOHOVER); bmps.AddTail(MB_SKIN_BUTTONLOGOIN); bmps.AddTail(MB_SKIN_BUTTONBACKGROUND); bmps.AddTail(MB_SKIN_BUTTONCLEARHOVER); bmps.AddTail(MB_SKIN_BUTTONCLEARIN); bmps.AddTail(MB_SKIN_BUTTONCLEAROUT); bmps.AddTail(MB_SKIN_BUTTONEXITHOVER); bmps.AddTail(MB_SKIN_BUTTONEXITIN); bmps.AddTail(MB_SKIN_BUTTONEXITOUT); bmps.AddTail(MB_SKIN_BUTTONFASTFORWARDHOVER); bmps.AddTail(MB_SKIN_BUTTONFASTFORWARDIN); bmps.AddTail(MB_SKIN_BUTTONFASTFORWARDOUT); bmps.AddTail(MB_SKIN_BUTTONLOADHOVER); bmps.AddTail(MB_SKIN_BUTTONLOADIN); bmps.AddTail(MB_SKIN_BUTTONLOADOUT); bmps.AddTail(MB_SKIN_BUTTONMAXIMIZEHOVER); bmps.AddTail(MB_SKIN_BUTTONMAXIMIZEIN); bmps.AddTail(MB_SKIN_BUTTONMAXIMIZEOUT); bmps.AddTail(MB_SKIN_BUTTONMINIMIZEHOVER); bmps.AddTail(MB_SKIN_BUTTONMINIMIZEIN); bmps.AddTail(MB_SKIN_BUTTONMINIMIZEOUT); bmps.AddTail(MB_SKIN_BUTTONMENUHOVER); bmps.AddTail(MB_SKIN_BUTTONMENUIN); bmps.AddTail(MB_SKIN_BUTTONMENUOUT); bmps.AddTail(MB_SKIN_BUTTONPAUSEOUT); bmps.AddTail(MB_SKIN_BUTTONPLAYHOVER); bmps.AddTail(MB_SKIN_BUTTONPLAYIN); bmps.AddTail(MB_SKIN_BUTTONPLAYOUT); bmps.AddTail(MB_SKIN_BUTTONPROGRESSBACKGROUND); bmps.AddTail(MB_SKIN_BUTTONPROGRESSKNOB); bmps.AddTail(MB_SKIN_BUTTONRANDOMHOVER); bmps.AddTail(MB_SKIN_BUTTONRANDOMIN); bmps.AddTail(MB_SKIN_BUTTONRANDOMOUT); bmps.AddTail(MB_SKIN_BUTTONRESIZEHOVER); bmps.AddTail(MB_SKIN_BUTTONRESIZEIN); bmps.AddTail(MB_SKIN_BUTTONRESIZEOUT); bmps.AddTail(MB_SKIN_BUTTONRESTOREHOVER); bmps.AddTail(MB_SKIN_BUTTONRESTOREIN); bmps.AddTail(MB_SKIN_BUTTONRESTOREOUT); bmps.AddTail(MB_SKIN_BUTTONREVERSEHOVER); bmps.AddTail(MB_SKIN_BUTTONREVERSEIN); bmps.AddTail(MB_SKIN_BUTTONREVERSEOUT); bmps.AddTail(MB_SKIN_BUTTONSAVEHOVER); bmps.AddTail(MB_SKIN_BUTTONSAVEIN); bmps.AddTail(MB_SKIN_BUTTONSAVEOUT); bmps.AddTail(MB_SKIN_BUTTONSHUFFLEHOVER); bmps.AddTail(MB_SKIN_BUTTONSHUFFLEIN); bmps.AddTail(MB_SKIN_BUTTONSHUFFLEOUT); bmps.AddTail(MB_SKIN_BUTTONSTOPHOVER); bmps.AddTail(MB_SKIN_BUTTONSTOPIN); bmps.AddTail(MB_SKIN_BUTTONSTOPOUT); bmps.AddTail(MB_SKIN_BUTTONVOLUMEBACKGROUND); bmps.AddTail(MB_SKIN_BUTTONVOLUMEKNOB); bmps.AddTail(MB_SKIN_SCROLLBACKGROUND); bmps.AddTail(MB_SKIN_SCROLLBUTTON); bmps.AddTail(MB_SKIN_SCROLLDOWNARROW); bmps.AddTail(MB_SKIN_SCROLLUPARROW); POSITION pos; CString name,msg,bmp; for(pos = bmps.GetHeadPosition(); pos != NULL; ) { name = bmps.GetAt(pos); bmp = getSkin(skin, name); if (bmp == "") { if (msg.GetLength()) msg += "\r\n"; msg += name; } bmps.GetNext(pos); } CString tmp ; if (msg != "") { tmp = "The following bitmaps are missing from the\r\n"; tmp += skin; tmp += " skin.\r\n"; tmp += msg + "\r\n"; msg = tmp; } // Verify SkinDef's m_SkinDefKeyVals.RemoveAll(); loadSkinDefs(); CString skindef = getSkin(skin, MB_SKIN_DEF); RegistryKey regSD(skindef); regSD.ReadFile(); tmp = ""; if (checkSkinDef(regSD, tmp) != TRUE) { msg += "Problems with " + skindef + "\r\n"; msg += tmp; msg += "Either reinstall Muzikbrowzer or fix the skin."; } // read skin def custom CString skindefcustom = getSkin(skin, MB_SKIN_DEF_CUSTOM); RegistryKey regSDCustom(skindefcustom); regSDCustom.ReadFile(); tmp = ""; if (checkSkinDef(regSDCustom, tmp) != TRUE) { msg += "Problems with " + skindefcustom + "\r\n"; msg += "Go into Settings/Display and click Ok.\r\n"; msg += tmp; } CString key,val; tmp = ""; for( pos = m_SkinDefKeyVals.GetStartPosition(); pos != NULL; ) { m_SkinDefKeyVals.GetNextAssoc(pos, key, val); tmp += key + "\r\n"; } if (tmp.GetLength()) { msg += "Missing " + skin + " SkinDef parameters:\r\n"; msg += tmp; } if (msg.GetLength()) { logger.log(msg); if (stopOnError) { MBMessageBox("Bad skin", msg,FALSE,FALSE); } return FALSE; } return TRUE; }