mirror of
https://github.com/zhongyang219/TrafficMonitor.git
synced 2026-10-23 18:37:49 +08:00
新增:支持设置字体的粗体、斜体、下划线等字形。
This commit is contained in:
@@ -577,3 +577,49 @@ CString CCommon::IntToString(int n)
|
||||
str.Format(_T("%d"), n);
|
||||
return str;
|
||||
}
|
||||
|
||||
void CCommon::NormalizeFont(LOGFONT & font)
|
||||
{
|
||||
wstring name;
|
||||
wstring style;
|
||||
name = font.lfFaceName;
|
||||
if (name.back() == L' ')
|
||||
name.pop_back();
|
||||
size_t index = name.rfind(L' ');
|
||||
if (index == wstring::npos)
|
||||
return;
|
||||
style = name.substr(index + 1);
|
||||
//font.name = font.name.Left(index);
|
||||
bool style_acquired = false;
|
||||
if (style == L"Light")
|
||||
{
|
||||
font.lfWeight = FW_LIGHT;
|
||||
style_acquired = true;
|
||||
}
|
||||
else if (style == L"Semilight")
|
||||
{
|
||||
font.lfWeight = 350;
|
||||
style_acquired = true;
|
||||
}
|
||||
else if (style == L"Semibold")
|
||||
{
|
||||
font.lfWeight = FW_SEMIBOLD;
|
||||
style_acquired = true;
|
||||
}
|
||||
else if (style == L"Bold")
|
||||
{
|
||||
font.lfWeight = FW_BOLD;
|
||||
style_acquired = true;
|
||||
}
|
||||
else if (style == L"Black")
|
||||
{
|
||||
font.lfWeight = FW_BLACK;
|
||||
style_acquired = true;
|
||||
}
|
||||
|
||||
if (style_acquired)
|
||||
{
|
||||
name = name.substr(0, index);
|
||||
}
|
||||
wcsncpy_s(font.lfFaceName, name.c_str(), 32);
|
||||
}
|
||||
|
||||
+3
-16
@@ -11,13 +11,6 @@ public:
|
||||
|
||||
static string UnicodeToStr(const wchar_t* wstr);
|
||||
|
||||
////将一个int类型数据写入ini文件,如果成功则返回true
|
||||
//static bool WritePrivateProfileIntW(const wchar_t * AppName, const wchar_t * KeyName, int value, const wchar_t * Path);
|
||||
////将一个wstring类型数据写入ini文件,如果成功则返回true
|
||||
//static bool WriteIniStringW(const wchar_t* AppName, const wchar_t* KeyName, wstring str, const wchar_t* path);
|
||||
////从int文件读取一个wstring类型数据
|
||||
//static wstring GetIniStringW(const wchar_t* AppName, const wchar_t* KeyName, const wchar_t* default_str, const wchar_t* path);
|
||||
|
||||
/*根据数据的大小转换成以KB、MB、GB为单位的字符串
|
||||
size:数据的大小,单位为字节
|
||||
short_mode:是否使用精简模式(减小小数点位数,单位不显示“B”)
|
||||
@@ -69,9 +62,6 @@ public:
|
||||
//在指定位置绘制文本
|
||||
static void DrawWindowText(CDC* pDC, CRect rect, LPCTSTR lpszString, COLORREF color, COLORREF back_color);
|
||||
|
||||
////为一个Static控件填充指定的颜色
|
||||
//static void FillStaticColor(CStatic& static_ctr, COLORREF color);
|
||||
|
||||
//设置绘图的剪辑区域
|
||||
static void SetDrawArea(CDC* pDC, CRect rect);
|
||||
|
||||
@@ -89,12 +79,6 @@ public:
|
||||
//将一个字符串保存到剪贴板
|
||||
static bool CopyStringToClipboard(const wstring& str);
|
||||
|
||||
////判断现在是否刚开机,在刚开机的time毫秒内返回true,否则返回false(在启用了快速启动时,此函数可能会无法得到正确的结果)
|
||||
//static bool WhenStart(int time, bool write_log = false);
|
||||
|
||||
////显示鼠标提示
|
||||
//static CString GetMouseTipsInfo(__int64 today_traffic, int cpu_usage, int memory_usage, int used_memory, int total_memory, bool show_cpu_memory);
|
||||
|
||||
//获取Windows版本
|
||||
static void GetWindowsVersion(int& major_version, int& minor_version, int& build_number);
|
||||
|
||||
@@ -114,5 +98,8 @@ public:
|
||||
static CString LoadText(LPCTSTR front_str, UINT id, LPCTSTR back_str = nullptr);
|
||||
|
||||
static CString IntToString(int n);
|
||||
|
||||
//删除字体名称后面的Bold、Light等字符串,并根据这些字符串设置字体粗细
|
||||
static void NormalizeFont(LOGFONT& font);
|
||||
};
|
||||
|
||||
|
||||
@@ -84,6 +84,19 @@ enum class Language
|
||||
SIMPLIFIED_CHINESE //简体中文
|
||||
};
|
||||
|
||||
//字体
|
||||
struct FontInfo
|
||||
{
|
||||
CString name; //字体名称
|
||||
int size; //字体大小
|
||||
bool bold; //粗体
|
||||
bool italic; //斜体
|
||||
bool underline; //下划线
|
||||
bool strike_out; //删除线
|
||||
};
|
||||
|
||||
//将字号转成成LOGFONT结构中的lfHeight
|
||||
#define FONTSIZE_TO_LFHEIGHT(font_size) (-MulDiv(font_size, GetDeviceCaps(::GetDC(HWND_DESKTOP), LOGPIXELSY), 72))
|
||||
|
||||
//选项设置数据
|
||||
#define MAIN_WND_COLOR_NUM 4 //主窗口颜色数量
|
||||
@@ -92,8 +105,7 @@ struct MainWndSettingData
|
||||
//主窗口
|
||||
COLORREF text_colors[MAIN_WND_COLOR_NUM]{}; //文字颜色(分别为“上传”、“下载”、“CPU”、“内存”的颜色)
|
||||
bool specify_each_item_color{ false }; //是否指定每个项目的颜色
|
||||
CString font_name; //字体名称
|
||||
int font_size; //字体大小
|
||||
FontInfo font; //字体
|
||||
DispStrings disp_str; //显示的文本
|
||||
bool speed_short_mode{ false }; //网速显示简洁模式(减少小数点的位数,单位不显示“B”)
|
||||
bool swap_up_down{ false }; //交换上传和下载显示的位置
|
||||
@@ -111,8 +123,7 @@ struct TaskBarSettingData
|
||||
COLORREF back_color{ RGB(0, 0, 0) }; //背景颜色
|
||||
COLORREF text_colors[TASKBAR_COLOR_NUM]{}; //文字颜色(依次为“上传”、“下载”、“CPU”、“内存”的标签和数据颜色)
|
||||
bool specify_each_item_color{ false }; //是否指定每个项目的颜色
|
||||
CString font_name; //字体名称
|
||||
int font_size; //字体大小
|
||||
FontInfo font; //字体
|
||||
DispStrings disp_str; //显示的文本
|
||||
bool swap_up_down{ false }; //交换上传和下载显示的位置
|
||||
bool speed_short_mode{ false }; //网速显示简洁模式(减少小数点的位数,单位不显示“B”)
|
||||
|
||||
@@ -102,3 +102,47 @@ bool CIniHelper::GetIntArray(const wchar_t * AppName, const wchar_t * KeyName, i
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
bool CIniHelper::WriteBoolArray(const wchar_t * AppName, const wchar_t * KeyName, const bool * values, int size)
|
||||
{
|
||||
int value{};
|
||||
for (int i{}; i < size; i++)
|
||||
{
|
||||
if (values[i])
|
||||
value |= (1 << i);
|
||||
}
|
||||
return WriteInt(AppName, KeyName, value);
|
||||
}
|
||||
|
||||
void CIniHelper::GetBoolArray(const wchar_t * AppName, const wchar_t * KeyName, bool * values, int size, bool default_value)
|
||||
{
|
||||
int value = GetInt(AppName, KeyName, 0);
|
||||
for (int i{}; i < size; i++)
|
||||
{
|
||||
values[i] = ((value >> i) % 2 != 0);
|
||||
}
|
||||
}
|
||||
|
||||
void CIniHelper::SaveFontData(const wchar_t * AppName, const FontInfo & font)
|
||||
{
|
||||
WriteString(AppName, L"font_name", wstring(font.name));
|
||||
WriteInt(AppName, L"font_size", font.size);
|
||||
bool style[4];
|
||||
style[0] = font.bold;
|
||||
style[1] = font.italic;
|
||||
style[2] = font.underline;
|
||||
style[3] = font.strike_out;
|
||||
WriteBoolArray(AppName, L"font_style", style, 4);
|
||||
}
|
||||
|
||||
void CIniHelper::LoadFontData(const wchar_t * AppName, FontInfo & font, const FontInfo& default_font)
|
||||
{
|
||||
font.name = GetString(AppName, L"font_name", default_font.name).c_str();
|
||||
font.size = GetInt(AppName, L"font_size", default_font.size);
|
||||
bool style[4];
|
||||
GetBoolArray(AppName, L"font_style", style, 4);
|
||||
font.bold = style[0];
|
||||
font.italic = style[1];
|
||||
font.underline = style[2];
|
||||
font.strike_out = style[3];
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
#define DEF_CH L'\"' //写入和读取ini文件字符串时,在字符串前后添加的字符
|
||||
#include "CommonData.h"
|
||||
|
||||
class CIniHelper
|
||||
{
|
||||
@@ -17,6 +18,11 @@ public:
|
||||
bool GetBool(const wchar_t * AppName, const wchar_t * KeyName, bool default_value);
|
||||
bool WriteIntArray(const wchar_t * AppName, const wchar_t * KeyName, const int* values, int size); //写入一个int数组,元素个数为size
|
||||
bool GetIntArray(const wchar_t * AppName, const wchar_t * KeyName, int* values, int size, int default_value = 0); //读取一个int数组,储存到values,元素个数为size
|
||||
bool WriteBoolArray(const wchar_t * AppName, const wchar_t * KeyName, const bool* values, int size);
|
||||
void GetBoolArray(const wchar_t * AppName, const wchar_t * KeyName, bool* values, int size, bool default_value = false);
|
||||
|
||||
void SaveFontData(const wchar_t * AppName, const FontInfo& font);
|
||||
void LoadFontData(const wchar_t * AppName, FontInfo& font, const FontInfo& default_font);
|
||||
|
||||
protected:
|
||||
wstring m_path;
|
||||
|
||||
@@ -78,12 +78,12 @@ BOOL CMainWndSettingsDlg::OnInitDialog()
|
||||
// TODO: 在此添加额外的初始化
|
||||
|
||||
//初始化各控件状态
|
||||
SetDlgItemText(IDC_FONT_NAME_EDIT, m_data.font_name);
|
||||
SetDlgItemText(IDC_FONT_NAME_EDIT, m_data.font.name);
|
||||
//wchar_t buff[16];
|
||||
//swprintf_s(buff, L"%d", m_data.font_size);
|
||||
//SetDlgItemText(IDC_FONT_SIZE_EDIT, buff);
|
||||
m_font_size_edit.SetRange(5, 72);
|
||||
m_font_size_edit.SetValue(m_data.font_size);
|
||||
m_font_size_edit.SetValue(m_data.font.size);
|
||||
|
||||
SetDlgItemText(IDC_UPLOAD_EDIT, m_data.disp_str.up.c_str());
|
||||
SetDlgItemText(IDC_DOWNLOAD_EDIT, m_data.disp_str.down.c_str());
|
||||
@@ -216,20 +216,29 @@ void CMainWndSettingsDlg::OnBnClickedSetDefaultButton()
|
||||
void CMainWndSettingsDlg::OnBnClickedSetFontButton()
|
||||
{
|
||||
// TODO: 在此添加控件通知处理程序代码
|
||||
CFont font;
|
||||
font.CreatePointFont(m_data.font_size * 10, m_data.font_name);
|
||||
LOGFONT lf{}; //LOGFONT变量
|
||||
font.GetLogFont(&lf);
|
||||
LOGFONT lf{};
|
||||
lf.lfHeight = FONTSIZE_TO_LFHEIGHT(m_data.font.size);
|
||||
lf.lfWeight = (m_data.font.bold ? FW_BOLD : FW_NORMAL);
|
||||
lf.lfItalic = m_data.font.italic;
|
||||
lf.lfUnderline = m_data.font.underline;
|
||||
lf.lfStrikeOut = m_data.font.strike_out;
|
||||
lf.lfPitchAndFamily = DEFAULT_PITCH | FF_SWISS;
|
||||
wcsncpy_s(lf.lfFaceName, m_data.font.name.GetString(), 32);
|
||||
CCommon::NormalizeFont(lf);
|
||||
CFontDialog fontDlg(&lf); //构造字体对话框,初始选择字体为之前字体
|
||||
if (IDOK == fontDlg.DoModal()) // 显示字体对话框
|
||||
{
|
||||
//获取字体信息
|
||||
m_data.font_name = fontDlg.GetFaceName();
|
||||
m_data.font_size = fontDlg.GetSize() / 10;
|
||||
m_data.font.name = fontDlg.GetFaceName();
|
||||
m_data.font.size = fontDlg.GetSize() / 10;
|
||||
m_data.font.bold = (fontDlg.IsBold() != FALSE);
|
||||
m_data.font.italic = (fontDlg.IsItalic() != FALSE);
|
||||
m_data.font.underline = (fontDlg.IsUnderline() != FALSE);
|
||||
m_data.font.strike_out = (fontDlg.IsStrikeOut() != FALSE);
|
||||
//将字体信息显示出来
|
||||
SetDlgItemText(IDC_FONT_NAME_EDIT, m_data.font_name);
|
||||
SetDlgItemText(IDC_FONT_NAME_EDIT, m_data.font.name);
|
||||
wchar_t buff[16];
|
||||
swprintf_s(buff, L"%d", m_data.font_size);
|
||||
swprintf_s(buff, L"%d", m_data.font.size);
|
||||
SetDlgItemText(IDC_FONT_SIZE_EDIT, buff);
|
||||
}
|
||||
}
|
||||
@@ -304,9 +313,9 @@ void CMainWndSettingsDlg::OnOK()
|
||||
}
|
||||
else
|
||||
{
|
||||
m_data.font_size = font_size;
|
||||
m_data.font.size = font_size;
|
||||
}
|
||||
GetDlgItemText(IDC_FONT_NAME_EDIT, m_data.font_name);
|
||||
GetDlgItemText(IDC_FONT_NAME_EDIT, m_data.font.name);
|
||||
|
||||
CTabDlg::OnOK();
|
||||
}
|
||||
|
||||
@@ -313,8 +313,9 @@ void CTaskBarDlg::SaveConfig()
|
||||
ini.WriteIntArray(L"task_bar", L"task_bar_text_color", (int*)theApp.m_taskbar_data.text_colors, TASKBAR_COLOR_NUM);
|
||||
ini.WriteBool(L"task_bar", L"specify_each_item_color", theApp.m_taskbar_data.specify_each_item_color);
|
||||
ini.WriteBool(L"task_bar", L"tack_bar_show_cpu_memory", theApp.m_tbar_show_cpu_memory);
|
||||
ini.WriteString(_T("task_bar"), _T("tack_bar_font_name"), wstring(theApp.m_taskbar_data.font_name));
|
||||
ini.WriteInt(L"task_bar", L"tack_bar_font_size", theApp.m_taskbar_data.font_size);
|
||||
//ini.WriteString(_T("task_bar"), _T("tack_bar_font_name"), wstring(theApp.m_taskbar_data.font.name));
|
||||
//ini.WriteInt(L"task_bar", L"tack_bar_font_size", theApp.m_taskbar_data.font.size);
|
||||
ini.SaveFontData(L"task_bar", theApp.m_taskbar_data.font);
|
||||
ini.WriteBool(L"task_bar", L"task_bar_swap_up_down", theApp.m_taskbar_data.swap_up_down);
|
||||
|
||||
ini.WriteString(_T("task_bar"), _T("up_string"), theApp.m_taskbar_data.disp_str.up);
|
||||
@@ -341,9 +342,15 @@ void CTaskBarDlg::LoadConfig()
|
||||
theApp.m_taskbar_data.specify_each_item_color = ini.GetBool(L"task_bar", L"specify_each_item_color", false);
|
||||
theApp.m_tbar_show_cpu_memory = ini.GetBool(_T("task_bar"), _T("tack_bar_show_cpu_memory"), true);
|
||||
theApp.m_taskbar_data.swap_up_down = ini.GetBool(_T("task_bar"), _T("task_bar_swap_up_down"), false);
|
||||
theApp.m_taskbar_data.font_name = ini.GetString(_T("task_bar"), _T("tack_bar_font_name"), CCommon::LoadText(IDS_MICROSOFT_YAHEI)).c_str();
|
||||
theApp.m_taskbar_data.font_size = ini.GetInt(_T("task_bar"), _T("tack_bar_font_size"), 9);
|
||||
|
||||
|
||||
//theApp.m_taskbar_data.font.name = ini.GetString(_T("task_bar"), _T("tack_bar_font_name"), CCommon::LoadText(IDS_MICROSOFT_YAHEI)).c_str();
|
||||
//theApp.m_taskbar_data.font.size = ini.GetInt(_T("task_bar"), _T("tack_bar_font_size"), 9);
|
||||
FontInfo default_font{};
|
||||
default_font.name = CCommon::LoadText(IDS_MICROSOFT_YAHEI);
|
||||
default_font.size = 9;
|
||||
ini.LoadFontData(_T("task_bar"), theApp.m_taskbar_data.font, default_font);
|
||||
|
||||
|
||||
theApp.m_taskbar_data.disp_str.up = ini.GetString(L"task_bar", L"up_string", L"↑: $");
|
||||
theApp.m_taskbar_data.disp_str.down = ini.GetString(L"task_bar", L"down_string", L"↓: $");
|
||||
theApp.m_taskbar_data.disp_str.cpu = ini.GetString(L"task_bar", L"cpu_string", L"CPU: $");
|
||||
@@ -358,7 +365,7 @@ void CTaskBarDlg::LoadConfig()
|
||||
theApp.m_taskbar_data.double_click_action = static_cast<DoubleClickAction>(ini.GetInt(_T("task_bar"), _T("double_click_action"), 0));
|
||||
}
|
||||
|
||||
void CTaskBarDlg::ApplySettings()
|
||||
void CTaskBarDlg::SetTextFont()
|
||||
{
|
||||
//如果m_font已经关联了一个字体资源对象,则释放它
|
||||
if (m_font.m_hObject)
|
||||
@@ -366,8 +373,26 @@ void CTaskBarDlg::ApplySettings()
|
||||
m_font.DeleteObject();
|
||||
}
|
||||
//创建新的字体
|
||||
m_font.CreatePointFont(theApp.m_taskbar_data.font_size * 10, theApp.m_taskbar_data.font_name);
|
||||
m_font.CreateFont(
|
||||
FONTSIZE_TO_LFHEIGHT(theApp.m_taskbar_data.font.size), // nHeight
|
||||
0, // nWidth
|
||||
0, // nEscapement
|
||||
0, // nOrientation
|
||||
(theApp.m_taskbar_data.font.bold ? FW_BOLD : FW_NORMAL), // nWeight
|
||||
theApp.m_taskbar_data.font.italic, // bItalic
|
||||
theApp.m_taskbar_data.font.underline, // bUnderline
|
||||
theApp.m_taskbar_data.font.strike_out, // cStrikeOut
|
||||
ANSI_CHARSET, // nCharSet
|
||||
OUT_DEFAULT_PRECIS, // nOutPrecision
|
||||
CLIP_DEFAULT_PRECIS, // nClipPrecision
|
||||
DEFAULT_QUALITY, // nQuality
|
||||
DEFAULT_PITCH | FF_SWISS, // nPitchAndFamily
|
||||
theApp.m_taskbar_data.font.name);
|
||||
}
|
||||
|
||||
void CTaskBarDlg::ApplySettings()
|
||||
{
|
||||
SetTextFont();
|
||||
CalculateWindowWidth();
|
||||
}
|
||||
|
||||
@@ -448,7 +473,7 @@ BOOL CTaskBarDlg::OnInitDialog()
|
||||
m_pDC = GetDC();
|
||||
|
||||
//设置字体
|
||||
m_font.CreatePointFont(theApp.m_taskbar_data.font_size * 10, theApp.m_taskbar_data.font_name);
|
||||
SetTextFont();
|
||||
m_pDC->SelectObject(&m_font);
|
||||
|
||||
this->GetWindowRect(m_rect);
|
||||
|
||||
@@ -63,6 +63,7 @@ public:
|
||||
static void SaveConfig(); //保存设置到ini文件
|
||||
static void LoadConfig(); //从ini文件载入设置
|
||||
|
||||
void SetTextFont();
|
||||
void ApplySettings();
|
||||
void CalculateWindowWidth(); //计算窗口需要的宽度
|
||||
|
||||
|
||||
@@ -81,12 +81,12 @@ BOOL CTaskBarSettingsDlg::OnInitDialog()
|
||||
// TODO: 在此添加额外的初始化
|
||||
|
||||
//初始化各控件状态
|
||||
SetDlgItemText(IDC_FONT_NAME_EDIT1, m_data.font_name);
|
||||
SetDlgItemText(IDC_FONT_NAME_EDIT1, m_data.font.name);
|
||||
//wchar_t buff[16];
|
||||
//swprintf_s(buff, L"%d", m_data.font_size);
|
||||
//SetDlgItemText(IDC_FONT_SIZE_EDIT1, buff);
|
||||
m_font_size_edit.SetRange(5, 72);
|
||||
m_font_size_edit.SetValue(m_data.font_size);
|
||||
m_font_size_edit.SetValue(m_data.font.size);
|
||||
|
||||
SetDlgItemText(IDC_UPLOAD_EDIT1, m_data.disp_str.up.c_str());
|
||||
SetDlgItemText(IDC_DOWNLOAD_EDIT1, m_data.disp_str.down.c_str());
|
||||
@@ -137,20 +137,29 @@ BOOL CTaskBarSettingsDlg::OnInitDialog()
|
||||
void CTaskBarSettingsDlg::OnBnClickedSetFontButton1()
|
||||
{
|
||||
// TODO: 在此添加控件通知处理程序代码
|
||||
CFont font;
|
||||
font.CreatePointFont(m_data.font_size * 10, m_data.font_name);
|
||||
LOGFONT lf{}; //LOGFONT变量
|
||||
font.GetLogFont(&lf);
|
||||
LOGFONT lf{};
|
||||
lf.lfHeight = FONTSIZE_TO_LFHEIGHT(m_data.font.size);
|
||||
lf.lfWeight = (m_data.font.bold ? FW_BOLD : FW_NORMAL);
|
||||
lf.lfItalic = m_data.font.italic;
|
||||
lf.lfUnderline = m_data.font.underline;
|
||||
lf.lfStrikeOut = m_data.font.strike_out;
|
||||
lf.lfPitchAndFamily = DEFAULT_PITCH | FF_SWISS;
|
||||
wcsncpy_s(lf.lfFaceName, m_data.font.name.GetString(), 32);
|
||||
CCommon::NormalizeFont(lf);
|
||||
CFontDialog fontDlg(&lf); //构造字体对话框,初始选择字体为之前字体
|
||||
if (IDOK == fontDlg.DoModal()) // 显示字体对话框
|
||||
{
|
||||
//获取字体信息
|
||||
m_data.font_name = fontDlg.GetFaceName();
|
||||
m_data.font_size = fontDlg.GetSize() / 10;
|
||||
m_data.font.name = fontDlg.GetFaceName();
|
||||
m_data.font.size = fontDlg.GetSize() / 10;
|
||||
m_data.font.bold = (fontDlg.IsBold() != FALSE);
|
||||
m_data.font.italic = (fontDlg.IsItalic() != FALSE);
|
||||
m_data.font.underline = (fontDlg.IsUnderline() != FALSE);
|
||||
m_data.font.strike_out = (fontDlg.IsStrikeOut() != FALSE);
|
||||
//将字体信息显示出来
|
||||
SetDlgItemText(IDC_FONT_NAME_EDIT1, m_data.font_name);
|
||||
SetDlgItemText(IDC_FONT_NAME_EDIT1, m_data.font.name);
|
||||
wchar_t buff[16];
|
||||
swprintf_s(buff, L"%d", m_data.font_size);
|
||||
swprintf_s(buff, L"%d", m_data.font.size);
|
||||
SetDlgItemText(IDC_FONT_SIZE_EDIT1, buff);
|
||||
}
|
||||
}
|
||||
@@ -295,9 +304,9 @@ void CTaskBarSettingsDlg::OnOK()
|
||||
}
|
||||
else
|
||||
{
|
||||
m_data.font_size = font_size;
|
||||
m_data.font.size = font_size;
|
||||
}
|
||||
GetDlgItemText(IDC_FONT_NAME_EDIT1, m_data.font_name);
|
||||
GetDlgItemText(IDC_FONT_NAME_EDIT1, m_data.font.name);
|
||||
|
||||
CTabDlg::OnOK();
|
||||
}
|
||||
|
||||
@@ -472,10 +472,14 @@ void CTrafficMonitorDlg::LoadConfig()
|
||||
theApp.m_main_wnd_data.swap_up_down = ini.GetBool(_T("config"), _T("swap_up_down"), false);
|
||||
theApp.m_main_wnd_data.hide_main_wnd_when_fullscreen = ini.GetBool(_T("config"), _T("hide_main_wnd_when_fullscreen"), true);
|
||||
|
||||
theApp.m_main_wnd_data.font_name = ini.GetString(_T("config"), _T("font_name"), CCommon::LoadText(IDS_MICROSOFT_YAHEI)).c_str();
|
||||
theApp.m_main_wnd_data.font_size = ini.GetInt(_T("config"), _T("font_size"), 10);
|
||||
FontInfo default_font{};
|
||||
default_font.name = CCommon::LoadText(IDS_MICROSOFT_YAHEI);
|
||||
default_font.size = 10;
|
||||
ini.LoadFontData(_T("config"), theApp.m_main_wnd_data.font, default_font);
|
||||
//theApp.m_main_wnd_data.font.name = ini.GetString(_T("config"), _T("font_name"), CCommon::LoadText(IDS_MICROSOFT_YAHEI)).c_str();
|
||||
//theApp.m_main_wnd_data.font.size = ini.GetInt(_T("config"), _T("font_size"), 10);
|
||||
|
||||
theApp.m_main_wnd_data.disp_str.up = ini.GetString(L"config", L"up_string", CCommon::LoadText(IDS_UPLOAD_DISP, _T(": $")));
|
||||
theApp.m_main_wnd_data.disp_str.up = ini.GetString(_T("config"), L"up_string", CCommon::LoadText(IDS_UPLOAD_DISP, _T(": $")));
|
||||
theApp.m_main_wnd_data.disp_str.down = ini.GetString(L"config", L"down_string", CCommon::LoadText(IDS_DOWNLOAD_DISP, _T(": $")));
|
||||
theApp.m_main_wnd_data.disp_str.cpu = ini.GetString(L"config", L"cpu_string", L"CPU: $");
|
||||
theApp.m_main_wnd_data.disp_str.memory = ini.GetString(L"config", L"memory_string", CCommon::LoadText(IDS_MEMORY_DISP, _T(": $")));
|
||||
@@ -528,8 +532,10 @@ void CTrafficMonitorDlg::SaveConfig()
|
||||
ini.WriteString(L"connection", L"connection_name", CCommon::StrToUnicode(m_connection_name.c_str()).c_str());
|
||||
ini.WriteString(_T("config"), _T("skin_selected"), m_skin_name.c_str());
|
||||
ini.WriteInt(L"config", L"notify_icon_selected", m_notify_icon_selected);
|
||||
ini.WriteString(_T("config"), _T("font_name"), wstring(theApp.m_main_wnd_data.font_name));
|
||||
ini.WriteInt(L"config", L"font_size", theApp.m_main_wnd_data.font_size);
|
||||
|
||||
//ini.WriteString(_T("config"), _T("font_name"), wstring(theApp.m_main_wnd_data.font.name));
|
||||
//ini.WriteInt(L"config", L"font_size", theApp.m_main_wnd_data.font.size);
|
||||
ini.SaveFontData(L"config", theApp.m_main_wnd_data.font);
|
||||
|
||||
ini.WriteBool(L"config", L"swap_up_down", theApp.m_main_wnd_data.swap_up_down);
|
||||
ini.WriteBool(L"config", L"hide_main_wnd_when_fullscreen", theApp.m_main_wnd_data.hide_main_wnd_when_fullscreen);
|
||||
@@ -893,7 +899,21 @@ void CTrafficMonitorDlg::SetTextFont()
|
||||
{
|
||||
if (m_font.m_hObject) //如果m_font已经关联了一个字体资源对象,则释放它
|
||||
m_font.DeleteObject();
|
||||
m_font.CreatePointFont(theApp.m_main_wnd_data.font_size * 10, theApp.m_main_wnd_data.font_name);
|
||||
m_font.CreateFont(
|
||||
FONTSIZE_TO_LFHEIGHT(theApp.m_main_wnd_data.font.size), // nHeight
|
||||
0, // nWidth
|
||||
0, // nEscapement
|
||||
0, // nOrientation
|
||||
(theApp.m_main_wnd_data.font.bold ? FW_BOLD : FW_NORMAL), // nWeight
|
||||
theApp.m_main_wnd_data.font.italic, // bItalic
|
||||
theApp.m_main_wnd_data.font.underline, // bUnderline
|
||||
theApp.m_main_wnd_data.font.strike_out, // cStrikeOut
|
||||
ANSI_CHARSET, // nCharSet
|
||||
OUT_DEFAULT_PRECIS, // nOutPrecision
|
||||
CLIP_DEFAULT_PRECIS, // nClipPrecision
|
||||
DEFAULT_QUALITY, // nQuality
|
||||
DEFAULT_PITCH | FF_SWISS, // nPitchAndFamily
|
||||
theApp.m_main_wnd_data.font.name);
|
||||
m_disp_cpu.SetFont(&m_font);
|
||||
m_disp_memory.SetFont(&m_font);
|
||||
m_disp_up.SetFont(&m_font);
|
||||
@@ -1923,9 +1943,9 @@ void CTrafficMonitorDlg::OnChangeSkin()
|
||||
if (theApp.m_general_data.allow_skin_cover_font)
|
||||
{
|
||||
if (!skinDlg.GetSkinData().font_name.empty())
|
||||
theApp.m_main_wnd_data.font_name = skinDlg.GetSkinData().font_name.c_str();
|
||||
theApp.m_main_wnd_data.font.name = skinDlg.GetSkinData().font_name.c_str();
|
||||
if (skinDlg.GetSkinData().font_size >= MIN_FONT_SIZE && skinDlg.GetSkinData().font_size <= MAX_FONT_SIZE)
|
||||
theApp.m_main_wnd_data.font_size = skinDlg.GetSkinData().font_size;
|
||||
theApp.m_main_wnd_data.font.size = skinDlg.GetSkinData().font_size;
|
||||
SetTextFont();
|
||||
}
|
||||
//获取项目的显示文本
|
||||
|
||||
Reference in New Issue
Block a user