project64/Source/Project64/UserInterface/WTLControls/ModifiedEditBox.cpp

82 lines
1.9 KiB
C++
Raw Normal View History

2016-01-27 09:11:59 +00:00
#include "stdafx.h"
2021-04-12 11:35:39 +00:00
CModifiedEditBox::CModifiedEditBox(bool bString /* = true */, HWND hWnd /* = nullptr */) :
2022-09-21 05:16:07 +00:00
CEdit(hWnd),
m_Changed(false),
m_Reset(false),
m_BoldFont(nullptr),
m_OriginalFont(nullptr),
m_TextField(nullptr),
m_bString(bString)
2016-01-27 09:11:59 +00:00
{
}
CModifiedEditBox::~CModifiedEditBox()
{
if (m_BoldFont)
{
DeleteObject(m_BoldFont);
}
}
void CModifiedEditBox::SetReset(bool Reset)
{
m_Reset = Reset;
if (m_Reset)
{
SetChanged(false);
}
}
void CModifiedEditBox::SetChanged(bool Changed)
{
m_Changed = Changed;
if (m_Changed)
{
SetReset(false);
2021-04-12 11:35:39 +00:00
if (m_BoldFont == nullptr)
2016-01-27 09:11:59 +00:00
{
m_OriginalFont = (HFONT)SendMessage(WM_GETFONT);
LOGFONT lfSystemVariableFont;
GetObject(m_OriginalFont, sizeof(LOGFONT), &lfSystemVariableFont);
lfSystemVariableFont.lfWeight = FW_BOLD;
m_BoldFont = CreateFontIndirect(&lfSystemVariableFont);
}
SendMessage(WM_SETFONT, (WPARAM)m_BoldFont);
2021-04-12 11:35:39 +00:00
InvalidateRect(nullptr);
2016-01-27 09:11:59 +00:00
if (m_TextField)
{
::SendMessage(m_TextField, WM_SETFONT, (WPARAM)m_BoldFont, 0);
2021-04-12 11:35:39 +00:00
::InvalidateRect(m_TextField, nullptr, true);
2016-01-27 09:11:59 +00:00
}
}
else
{
if (m_OriginalFont)
{
SendMessage(WM_SETFONT, (WPARAM)m_OriginalFont);
2021-04-12 11:35:39 +00:00
InvalidateRect(nullptr);
2016-01-27 09:11:59 +00:00
if (m_TextField)
{
::SendMessage(m_TextField, WM_SETFONT, (WPARAM)m_OriginalFont, 0);
2021-04-12 11:35:39 +00:00
::InvalidateRect(m_TextField, nullptr, true);
2016-01-27 09:11:59 +00:00
}
}
}
}
void CModifiedEditBox::SetTextField(HWND hWnd)
{
if (m_TextField && m_OriginalFont)
{
::SendMessage(m_TextField, WM_SETFONT, (WPARAM)m_OriginalFont, 0);
}
m_TextField = hWnd;
if (m_Changed && m_BoldFont)
{
::SendMessage(m_TextField, WM_SETFONT, (WPARAM)m_BoldFont, 0);
}
2021-03-17 09:26:55 +00:00
}