// // ---------- general functions ---------- // // display a line of text in a list // static void displayTextBuffer(TCHAR *txt) { // display a line of text in a list TCHAR* ptr; TCHAR sNum[20]; // find ptr to second line ptr = _tcschr(sDisplayBuf,'\n') + 1; if( ptr == NULL ) ptr = TEXT("-- no line? --"); // remove first line from tBuffer // (slightly illegal as copying in the same buffer ...) _tcsncpy_s(sDisplayBuf, _countof(sDisplayBuf), ptr, _TRUNCATE); // append new line with linenumber // line separator in editbox is cr-lf, so \r\n _ultot_s(++nLine, sNum, 20, 10); _tcsncat_s(sDisplayBuf, _countof(sDisplayBuf), TEXT("\r\n"), _TRUNCATE); _tcsncat_s(sDisplayBuf, _countof(sDisplayBuf), sNum, _TRUNCATE); _tcsncat_s(sDisplayBuf, _countof(sDisplayBuf), TEXT(": "), _TRUNCATE); // append text and display new set of lines in Edit Box _tcsncat_s(sDisplayBuf, _countof(sDisplayBuf), txt, _TRUNCATE); SetWindowText(hEdit, sDisplayBuf); }
wstring ULongToStr(unsigned long ulVal) { wstring strRet; TCHAR buff[20]; _ultot_s(ulVal,buff,sizeof(buff)/sizeof(buff[0]),10); strRet = buff; return strRet; }
/** * @brief WM_INITDIALOG handler of Machine State dialog. * @param hwnd - window handle. * @param hwndFocus - system-defined focus window. * @param lParam - user-defined parameter. * @return true to setup focus to system-defined control. */ static BOOL MachineStateDlg_OnInitDialog(HWND hwnd, HWND hwndFocus, LPARAM lParam) { lParam; hwndFocus; if (g_pResManager->m_hBigAppIcon) SendMessage(hwnd, WM_SETICON, ICON_BIG, (LPARAM)g_pResManager->m_hBigAppIcon); if (g_pResManager->m_hSmallAppIcon) SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)g_pResManager->m_hSmallAppIcon); CenterWindow(hwnd, GetParent(hwnd)); g_LayoutMgr.InitLayout(hwnd, g_arrMachineStateLayout, countof(g_arrMachineStateLayout)); HWND hwndProcessList = GetDlgItem(hwnd, IDC_PROCESS_LIST); ListView_SetExtendedListViewStyle(hwndProcessList, LVS_EX_FULLROWSELECT | LVS_EX_LABELTIP); HWND hwndModuleList = GetDlgItem(hwnd, IDC_PROCESS_MODULES_LIST); ListView_SetExtendedListViewStyle(hwndModuleList, LVS_EX_FULLROWSELECT | LVS_EX_LABELTIP); RECT rcList; GetClientRect(hwndProcessList, &rcList); rcList.right -= GetSystemMetrics(SM_CXHSCROLL); TCHAR szColumnTitle[64]; LVCOLUMN lvc; ZeroMemory(&lvc, sizeof(lvc)); lvc.mask = LVCF_TEXT | LVCF_WIDTH; lvc.pszText = szColumnTitle; lvc.cx = rcList.right / 5; LoadString(g_hInstance, IDS_COLUMN_PID, szColumnTitle, countof(szColumnTitle)); ListView_InsertColumn(hwndProcessList, CID_PROCESS_ID, &lvc); lvc.cx = rcList.right * 4 / 5; LoadString(g_hInstance, IDS_COLUMN_PROCESS, szColumnTitle, countof(szColumnTitle)); ListView_InsertColumn(hwndProcessList, CID_PROCESS_NAME, &lvc); lvc.cx = rcList.right / 2; LoadString(g_hInstance, IDS_COLUMN_MODULE, szColumnTitle, countof(szColumnTitle)); ListView_InsertColumn(hwndModuleList, CID_MODULE_NAME, &lvc); lvc.cx = rcList.right / 4; LoadString(g_hInstance, IDS_COLUMN_VERSION, szColumnTitle, countof(szColumnTitle)); ListView_InsertColumn(hwndModuleList, CID_MODULE_VERSION, &lvc); lvc.cx = rcList.right / 4; LoadString(g_hInstance, IDS_COLUMN_BASE, szColumnTitle, countof(szColumnTitle)); ListView_InsertColumn(hwndModuleList, CID_MODULE_BASE, &lvc); CEnumProcess::CProcessEntry ProcEntry; if (g_pEnumProc->GetProcessFirst(ProcEntry)) { LVITEM lvi; ZeroMemory(&lvi, sizeof(lvi)); lvi.mask = LVIF_TEXT | LVIF_PARAM; TCHAR szProcessID[64]; int iItemPos = 0; do { _ultot_s(ProcEntry.m_dwProcessID, szProcessID, countof(szProcessID), 10); lvi.iItem = iItemPos; lvi.pszText = szProcessID; lvi.lParam = ProcEntry.m_dwProcessID; ListView_InsertItem(hwndProcessList, &lvi); ListView_SetItemText(hwndProcessList, iItemPos, CID_PROCESS_NAME, ProcEntry.m_szProcessName); ++iItemPos; } while (g_pEnumProc->GetProcessNext(ProcEntry)); } // LVM_SETIMAGELIST resets header control image list g_ProcessListOrder.InitList(hwndProcessList); g_ModulesListOrder.InitList(hwndModuleList); return TRUE; }
/** * @param uValue - new field value. */ void CNumEdit::SetValue(UINT32 uValue) { TCHAR szValue[64]; _ultot_s(uValue, szValue, countof(szValue), m_eNumFormat); SetValue(szValue, countof(szValue)); }