void CategoryDlg::InitializeLists() { CListBox inBox(GetDlgItem(IDC_INCLUDE_LIST)); CListBox exBox(GetDlgItem(IDC_EXCLUDE_LIST)); ClearListBox(inBox); ClearListBox(exBox); int inWidth = 0; int exWidth = 0; ScopedGdiObjectSelection hIn(inBox.GetDC(), inBox.GetFont()); ScopedGdiObjectSelection hEx(exBox.GetDC(), exBox.GetFont()); for (auto it = m_categories.begin(); it != m_categories.end(); ++it) { if (it->second) { inBox.AddString(WStr(it->first)); inWidth = std::max(inWidth, GetTextWidth(inBox.GetDC(), it->first)); } else { exBox.AddString(WStr(it->first)); exWidth = std::max(exWidth, GetTextWidth(exBox.GetDC(), it->first)); } } inBox.SetHorizontalExtent(inWidth + 3*GetSystemMetrics(SM_CXBORDER)); exBox.SetHorizontalExtent(exWidth + 3*GetSystemMetrics(SM_CXBORDER)); UpdateUiState(); }
void SaveFilterSettings(const std::vector<Filter>& filters, CRegKey& reg) { int i = 0; for (auto it = filters.begin(); it != filters.end(); ++it, ++i) { CRegKey regFilter; regFilter.Create(reg, WStr(wstringbuilder() << L"Filter" << i)); regFilter.SetStringValue(L"", WStr(it->text.c_str())); regFilter.SetDWORDValue(L"MatchType", MatchTypeToInt(it->matchType)); regFilter.SetDWORDValue(L"FilterType", FilterTypeToInt(it->filterType)); regFilter.SetDWORDValue(L"Type", FilterTypeToInt(it->filterType)); regFilter.SetDWORDValue(L"BgColor", it->bgColor); regFilter.SetDWORDValue(L"FgColor", it->fgColor); regFilter.SetDWORDValue(L"Enable", it->enable); } }
void CTreeView::AddTestCase(unsigned id, const std::string& name, bool check) { HTREEITEM hItem = InsertItem(WStr(name), m_iEmpty, m_iEmpty, m_parents.back(), TVI_LAST); SetItemData(hItem, id); SetCheckState(hItem, check); m_items[id] = hItem; ++m_levels[m_depth]; }
void LogMessages(Settings settings) { LogSources sources(true); sources.AddDBWinReader(false); if (HasGlobalDBWinReaderRights()) sources.AddDBWinReader(true); sources.SetAutoNewLine(settings.autonewline); std::ofstream fs; if (!settings.filename.empty()) { OpenLogFile(fs, WStr(settings.filename)); fs.flush(); } auto guard = make_guard([&fs, &settings]() { if (!settings.filename.empty()) { fs.flush(); fs.close(); std::cout << "Log file closed.\n"; } }); std::string separator = settings.tabs ? "\t" : " "; while (!g_quit) { auto lines = sources.GetLines(); int linenumber = 0; for (auto it = lines.begin(); it != lines.end(); ++it) { if (settings.console) { if (settings.linenumber) { ++linenumber; std::cout << std::setw(5) << std::setfill('0') << linenumber << std::setfill(' ') << separator; } OutputDetails(settings, *it); std::cout << separator << it->message.c_str() << "\n"; } if (!settings.filename.empty()) { WriteLogFileMessage(fs, it->time, it->systemTime, it->pid, it->processName, it->message); } } if (settings.flush) { std::cout.flush(); fs.flush(); } Sleep(250); } std::cout.flush(); }
std::wstring ProcessInfo::GetProcessInfo(HANDLE handle) { FILETIME creation = { 0 }; FILETIME exit = { 0 }; FILETIME kernel = { 0 }; FILETIME user = { 0 }; GetProcessTimes(handle, &creation, &exit, &kernel, &user); return WStr(GetTimeText(creation)).str(); }
BOOL CAboutDlg::OnInitDialog(CWindow /*wndFocus*/, LPARAM /*lInitParam*/) { CenterWindow(GetParent()); m_srclink.SubclassWindow(GetDlgItem(IDC_DEBUGVIEW_SRC_URL)); m_link.SubclassWindow(GetDlgItem(IDC_DEBUGVIEW_URL)); int version[4] = { VERSION }; SetDlgItemText(IDC_VERSION, WStr(wstringbuilder() << L"DebugView++ V" << version[0] << L"." << version[1] << L"." << version[2] << L"." << version[3])); SetDlgItemText(IDC_DATE, _T(__DATE__)); return TRUE; }
LRESULT CTreeView::OnGetInfoTip(NMHDR* pnmh) { NMTVGETINFOTIP* pNmGetInfoTip = reinterpret_cast<NMTVGETINFOTIP*>(pnmh); std::wstring tooltip = WStr(m_pMainFrame->GetTestItem(GetItemData(pNmGetInfoTip->hItem)).fullName).str(); size_t maxSize = pNmGetInfoTip->cchTextMax; if (tooltip.size() + 1 > maxSize) tooltip = tooltip.substr(maxSize - 4) + L"..."; assert(tooltip.size() + 1 <= maxSize); wcsncpy(pNmGetInfoTip->pszText, tooltip.c_str(), tooltip.size() + 1); return 0; }
void CTreeView::EnterTestSuite(unsigned id, const std::string& name, bool check) { HTREEITEM hItem = InsertItem(WStr(name), m_iEmpty, m_iEmpty, m_parents.back(), TVI_LAST); SetItemData(hItem, id); SetCheckState(hItem, check); m_items[id] = hItem; m_parents.push_back(hItem); ++m_levels[m_depth]; ++m_depth; if (m_depth >= static_cast<int>(m_levels.size())) m_levels.push_back(0); }
BOOL CSourceDlg::OnInitDialog(CWindow /*wndFocus*/, LPARAM /*lInitParam*/) { CenterWindow(GetParent()); CComboBox combo = GetDlgItem(IDC_TYPE); combo.AddString(WStr(SourceTypeToString(SourceType::Udp))); combo.AddString(WStr(SourceTypeToString(SourceType::Tcp))); combo.AddString(WStr(SourceTypeToString(SourceType::DebugViewAgent))); SetDlgItemText(IDC_NAME, WStr(m_name)); switch (m_sourceType) { case SourceType::Udp: combo.SetCurSel(0); break; case SourceType::Tcp: combo.SetCurSel(1); break; case SourceType::DebugViewAgent: combo.SetCurSel(2); break; default: combo.SetCurSel(0); break; } SetDlgItemInt(IDC_PORT, m_port); SetDlgItemText(IDC_IPADDRESS, WStr(m_address)); UpdateUI(); return TRUE; }
void CSourcesDlg::UpdateGrid() { m_grid.DeleteAllItems(); for (auto& sourceInfo : m_sourceInfos) { int item = m_grid.GetItemCount(); m_grid.InsertItem(item, PropCreateCheckButton(L"", sourceInfo.enabled)); m_grid.SetSubItem(item, 1, PropCreateReadOnlyItem(L"", sourceInfo.description.c_str())); m_grid.SetSubItem(item, 2, PropCreateReadOnlyItem(L"", WStr(SourceTypeToString(sourceInfo.type)))); if (sourceInfo.type == SourceType::System) m_grid.SetSubItem(item, 3, PropCreateReadOnlyItem(L"", L"")); else m_grid.SetSubItem(item, 3, PropCreateReadOnlyItem(L"", L"x")); } }
void LoadFilterSettings(std::vector<Filter>& filters, CRegKey& reg) { for (int i = 0; ; ++i) { CRegKey regFilter; if (regFilter.Open(reg, WStr(wstringbuilder() << L"Filter" << i)) != ERROR_SUCCESS) break; filters.push_back(Filter( Str(RegGetStringValue(regFilter)), IntToMatchType(RegGetDWORDValue(regFilter, L"MatchType", MatchType::Regex)), IntToFilterType(RegGetDWORDValue(regFilter, L"Type")), RegGetDWORDValue(regFilter, L"BgColor", Colors::BackGround), RegGetDWORDValue(regFilter, L"FgColor", Colors::Text), RegGetDWORDValue(regFilter, L"Enable", 1) != 0)); } }
void CFilterDlg::OnOk(UINT /*uNotifyCode*/, int nID, CWindow /*wndCtl*/) { m_name = Win32::GetDlgItemText(*this, IDC_NAME); CFilterPage* pPage = nullptr; try { pPage = &m_messagePage; m_filter.messageFilters = m_messagePage.GetFilters(); pPage = &m_processPage; m_filter.processFilters = m_processPage.GetFilters(); } catch (std::regex_error& ex) { SelectTab(pPage == &m_processPage); MessageBox(WStr(L"Regular expression syntax error: " + GetRegexErrorDescription(ex.code())), LoadString(IDR_APPNAME).c_str(), MB_ICONERROR | MB_OK); pPage->ShowError(); return; } EndDialog(nID); }
void CFilterDlg::OnException(const std::exception& ex) { MessageBox(WStr(ex.what()).c_str(), LoadString(IDR_APPNAME).c_str(), MB_ICONERROR | MB_OK); }