Skip to content

Commit

Permalink
Fix CPU frequence rectangle width
Browse files Browse the repository at this point in the history
  • Loading branch information
rayfalling committed Oct 1, 2022
1 parent 9b2c8ff commit 255c189
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions TrafficMonitor/TaskBarDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,21 +265,20 @@ void CTaskBarDlg::DrawDisplayItem(CDrawCommon& drawer, DisplayItem type, CRect r
format_str = _T("%s");
else
format_str = _T("%s/s");
CString str_in_speed = CCommon::DataSizeToString(theApp.m_in_speed, theApp.m_taskbar_data);
CString str_out_speed = CCommon::DataSizeToString(theApp.m_out_speed, theApp.m_taskbar_data);
CString str_total_speed = CCommon::DataSizeToString(theApp.m_in_speed + theApp.m_out_speed, theApp.m_taskbar_data);
//if (theApp.m_taskbar_data.swap_up_down)
// std::swap(str_in_speed, str_out_speed);

if (type == TDI_UP)
{
CString str_out_speed = CCommon::DataSizeToString(theApp.m_out_speed, theApp.m_taskbar_data);
str_value.Format(format_str, str_out_speed.GetString());
}
else if (type == TDI_DOWN)
{
CString str_in_speed = CCommon::DataSizeToString(theApp.m_in_speed, theApp.m_taskbar_data);
str_value.Format(format_str, str_in_speed.GetString());
}
else
{
CString str_total_speed = CCommon::DataSizeToString(theApp.m_in_speed + theApp.m_out_speed, theApp.m_taskbar_data);
str_value.Format(format_str, str_total_speed.GetString());
}
}
Expand Down Expand Up @@ -346,6 +345,10 @@ void CTaskBarDlg::DrawDisplayItem(CDrawCommon& drawer, DisplayItem type, CRect r
}
else if (type == TDI_CPU_FREQ) {
str_value = CCommon::FreqToString(theApp.m_cpu_freq, theApp.m_taskbar_data);

// 部分字体下CPU频率会显示不全
int text_width = m_pDC->GetTextExtent(str_value).cx;
rect_value.right = rect_value.left + text_width + 4;
}

drawer.DrawWindowText(rect_value, str_value, text_color, value_alignment);
Expand Down

0 comments on commit 255c189

Please sign in to comment.