// Gets the comma formatted score of the i-th entry. string HighScores::GetScore(Uint32 i) { multimap<Uint32, string, std::greater<Uint32> >::iterator itr = m_table.begin(); Uint32 j = 0; while (j < i) { itr++; ++j; } return AddCommas(itr->first); }
LRESULT CSimpleGraph::OnMouseHover(WPARAM, LPARAM lp) { CPoint pt(LOWORD(lp), HIWORD(lp)); // client window coords CHexEditView *pv = GetView(); ASSERT(pv != NULL); m_bar = get_bar(pt); if (m_bar > -1 && !m_tip.IsWindowVisible()) { // Update the tip info m_tip.Clear(); CString ss; if (theApp.hex_ucase_) ss.Format("Byte: %d [%02.2Xh] %s", m_bar, m_bar, pv->DescChar(m_bar)); else ss.Format("Byte: %d [%02.2xh] %s", m_bar, m_bar, pv->DescChar(m_bar)); m_tip.AddString(ss); char buf[32]; // used with sprintf (CString::Format can't handle __int64) sprintf(buf, "%I64d", m_val[m_bar]); ss = buf; AddCommas(ss); m_tip.AddString("Count: " +ss); // Work out the tip window display position and move the tip window there CPoint tip_pt = pt + CSize(16, 16); ClientToScreen(&tip_pt); m_tip.Move(tip_pt, false); m_tip.Show(); track_mouse(TME_LEAVE); return 0; // return 0 to say we processed it } return 1; }
void SetReportInfo (HWND Dlg, DefragReport &Report, uint32 BytesDivisor, const wchar_t *BytesUnits, bool Fractional) { wchar_t Text[1000]; wchar_t Text2[1000]; wchar_t Text3[1000]; memset (Text, 0, sizeof (Text)); // Volume name SetDlgItemText (Dlg, IDC_DRIVELETTER, Report.RootPath.c_str()); // Volume label SetDlgItemText (Dlg, IDC_VOLUMELABEL, Defrag->GetVolume().GetVolumeInfo().Name.c_str()); // Volume Serial SetDlgItemText (Dlg, IDC_VOLUMESERIAL, Defrag->GetVolume().GetVolumeInfo().Serial.c_str()); // File System SetDlgItemText (Dlg, IDC_FILESYSTEM, Defrag->GetVolume().GetVolumeInfo().FileSystem.c_str()); // DiskSizeBytes if (Fractional) { swprintf (Text, L"%.2f %s", (double)(signed)(Report.DiskSizeBytes / (BytesDivisor / 1024)) / 1024.0, BytesUnits); } else { AddCommas (Text, Report.DiskSizeBytes / BytesDivisor); wcscat (Text, L" "); wcscat (Text, BytesUnits); } SetDlgItemText (Dlg, IDC_DISKSIZEBYTES, Text); // DiskFreeBytes if (Fractional) { swprintf (Text, L"%.2f %s", (double)(signed)(Defrag->GetVolume().GetVolumeInfo().FreeBytes / (BytesDivisor / 1024)) / 1024.0, BytesUnits); } else { AddCommas (Text, Defrag->GetVolume().GetVolumeInfo().FreeBytes / BytesDivisor); wcscat (Text, L" "); wcscat (Text, BytesUnits); } SetDlgItemText (Dlg, IDC_DISKFREEBYTES, Text); // DiskSizeClusters AddCommas (Text, Defrag->GetVolume().GetVolumeInfo().ClusterCount); wcscat (Text, L" clusters"); SetDlgItemText (Dlg, IDC_DISKSIZECLUSTERS, Text); // DiskClusterSize swprintf (Text, L"%u bytes", Defrag->GetVolume().GetVolumeInfo().ClusterSize); SetDlgItemText (Dlg, IDC_DISKCLUSTERSIZE, Text); // DirsCount AddCommas (Text, Report.DirsCount); SetDlgItemText (Dlg, IDC_DIRSCOUNT, Text); // FilesCount AddCommas (Text, Report.FilesCount); SetDlgItemText (Dlg, IDC_FILESCOUNT, Text); // FilesFragged swprintf (Text, L"(%.2f%%)", Report.PercentFragged); AddCommas (Text2, Report.FraggedFiles.size()); swprintf (Text3, L"%s %s", Text, Text2); SetDlgItemText (Dlg, IDC_FILESFRAGGED, Text3); // Average Frags swprintf (Text, L"%.2f", Report.AverageFragments); SetDlgItemText (Dlg, IDC_AVERAGEFRAGS, Text); // FilesSizeBytes if (Fractional) { swprintf (Text, L"%.2f %s", (double)(signed)(Report.FilesSizeBytes / (BytesDivisor / 1024)) / 1024.0, BytesUnits); } else { AddCommas (Text, Report.FilesSizeBytes / (uint64)BytesDivisor); wcscat (Text, L" "); wcscat (Text, BytesUnits); } SetDlgItemText (Dlg, IDC_FILESSIZEBYTES, Text); // Files SizeOnDisk if (Fractional) { swprintf (Text, L"%.2f %s", (double)(signed)((Report.FilesSizeBytes + Report.FilesSlackBytes) / (BytesDivisor / 1024)) / 1024.0, BytesUnits); } else { AddCommas (Text, (Report.FilesSizeBytes + Report.FilesSlackBytes) / (uint64)BytesDivisor); wcscat (Text, L" "); wcscat (Text, BytesUnits); } SetDlgItemText (Dlg, IDC_FILESSIZEONDISK, Text); // FilesSlackBytes if (Fractional) { swprintf (Text, L"%.2f %s", (double)(signed)(Report.FilesSlackBytes / (BytesDivisor / 1024)) / 1024.0, BytesUnits); } else { AddCommas (Text, Report.FilesSlackBytes / BytesDivisor); wcscat (Text, L" "); wcscat (Text, BytesUnits); } swprintf (Text2, L"(%.2f%%)", Report.PercentSlack); swprintf (Text3, L"%s %s", Text2, Text); SetDlgItemText (Dlg, IDC_FILESSLACKBYTES, Text3); // Recommendation bool PFRec = false; // Recommend based off percent fragged files? bool AFRec = false; // Recommend based off average fragments per file? if (Report.PercentFragged >= 5.0f) PFRec = true; if (Report.AverageFragments >= 1.1f) AFRec = true; wcscpy (Text, L"* "); if (PFRec) { swprintf ( Text2, L"%.2f%% of the files on this volume are fragmented. ", Report.PercentFragged ); wcscat (Text, Text2); } if (AFRec) { swprintf ( Text2, L"The average fragments per file (%.2f) indicates a high degree of fragmentation. ", Report.AverageFragments ); wcscat (Text, Text2); } if (Report.PercentFragged < 5.0f && Report.AverageFragments < 1.1f) swprintf (Text, L"* No defragmentation is necessary at this point."); else if (Report.PercentFragged < 15.0f && Report.AverageFragments < 1.3f) wcscat (Text, L"It is recommended that you perform a Fast Defrag."); else wcscat (Text, L"It is recommended that you perform an Extensive Defrag."); // Should we recommend a smaller cluster size? if (Report.PercentSlack >= 10.0f) { swprintf ( Text2, L"\n* A large amount of disk space (%.2f%%) is being lost " L"due to a large (%u bytes) cluster size. It is recommended " L"that you use a disk utility such as Partition Magic to " L"reduce the cluster size of this volume.", Report.PercentSlack, Defrag->GetVolume().GetVolumeInfo().ClusterSize ); wcscat (Text, Text2); } SetDlgItemText (Dlg, IDC_RECOMMEND, Text); return; }