diff --git a/Library/Meter.cpp b/Library/Meter.cpp index ea51b209..cf54611c 100644 --- a/Library/Meter.cpp +++ b/Library/Meter.cpp @@ -63,6 +63,7 @@ CMeter::CMeter(CMeterWindow* meterWindow) m_MeterWindow = meterWindow; m_AntiAlias = false; m_DynamicVariables = false; + m_Initialized = false; } /* @@ -85,6 +86,7 @@ CMeter::~CMeter() */ void CMeter::Initialize() { + m_Initialized = true; } /* @@ -280,11 +282,12 @@ void CMeter::ReadConfig(const WCHAR* section) DebugLog(L"The transformation matrix has incorrect number of values:", parser.ReadString(section, L"TransformationMatrix", L"").c_str()); } - +/* Are these necessary? if (m_W == 0 || m_H == 0) { throw CError(std::wstring(L"The meter ") + section + L" has zero dimensions.", __LINE__, __FILE__); } +*/ } /* diff --git a/Library/Meter.h b/Library/Meter.h index 1f71bc40..4a1478e0 100644 --- a/Library/Meter.h +++ b/Library/Meter.h @@ -126,6 +126,7 @@ protected: Gdiplus::Color m_SolidColor2; Gdiplus::REAL m_SolidAngle; bool m_AntiAlias; // If true, the line is antialiased + bool m_Initialized; CMeterWindow* m_MeterWindow; }; diff --git a/Library/MeterString.cpp b/Library/MeterString.cpp index d51989a9..6b9aa36b 100644 --- a/Library/MeterString.cpp +++ b/Library/MeterString.cpp @@ -164,6 +164,11 @@ void CMeterString::ReadConfig(const WCHAR* section) { WCHAR tmpName[256]; + // Store the current font values so we know if the font needs to be updated + std::wstring oldFontFace = m_FontFace; + int oldFontSize = m_FontSize; + TEXTSTYLE oldStyle = m_Style; + // Read common configs CMeter::ReadConfig(section); @@ -286,6 +291,14 @@ void CMeterString::ReadConfig(const WCHAR* section) { m_DimensionsDefined = true; } + + if (m_Initialized && + (oldFontFace != m_FontFace || + oldFontSize != m_FontSize || + oldStyle != m_Style)) + { + Initialize(); // Recreate the font + } } /* diff --git a/Library/MeterWindow.cpp b/Library/MeterWindow.cpp index 4bd4088c..6680ff18 100644 --- a/Library/MeterWindow.cpp +++ b/Library/MeterWindow.cpp @@ -2590,15 +2590,7 @@ LRESULT CMeterWindow::OnNcHitTest(WPARAM wParam, LPARAM lParam) LRESULT CMeterWindow::OnSettingChange(WPARAM wParam, LPARAM lParam) { m_Monitors.count = 0; - - try - { - Refresh(false); - } - catch (CError& error) - { - MessageBox(m_Window, error.GetString().c_str(), APPNAME, MB_OK | MB_TOPMOST | MB_ICONEXCLAMATION); - } + PostMessage(m_Window, WM_DELAYED_REFRESH, (WPARAM)NULL, (LPARAM)NULL); // Commented: Calling DefWindowProc seems to cause crash sometimes return 0; // DefWindowProc(m_Window, m_Message, wParam, lParam);