[Project64] Cleanup ModifiedEditBox.cpp

This commit is contained in:
zilmar 2015-11-13 08:27:28 +11:00
parent 6d38975b98
commit a4c438c20d
1 changed files with 62 additions and 62 deletions

View File

@ -23,84 +23,84 @@ m_bString(bString)
CModifiedEditBox::~CModifiedEditBox() CModifiedEditBox::~CModifiedEditBox()
{ {
if (m_BoldFont) if (m_BoldFont)
{ {
DeleteObject(m_BoldFont); DeleteObject(m_BoldFont);
} }
} }
void CModifiedEditBox::SetReset(bool Reset) void CModifiedEditBox::SetReset(bool Reset)
{ {
m_Reset = Reset; m_Reset = Reset;
if (m_Reset) if (m_Reset)
{ {
SetChanged(false); SetChanged(false);
} }
} }
void CModifiedEditBox::SetChanged(bool Changed) void CModifiedEditBox::SetChanged(bool Changed)
{ {
m_Changed = Changed; m_Changed = Changed;
if (m_Changed) if (m_Changed)
{ {
SetReset(false); SetReset(false);
if (m_BoldFont == NULL) if (m_BoldFont == NULL)
{ {
m_OriginalFont = (HFONT)SendMessage(WM_GETFONT); m_OriginalFont = (HFONT)SendMessage(WM_GETFONT);
LOGFONT lfSystemVariableFont; LOGFONT lfSystemVariableFont;
GetObject(m_OriginalFont, sizeof(LOGFONT), &lfSystemVariableFont); GetObject(m_OriginalFont, sizeof(LOGFONT), &lfSystemVariableFont);
lfSystemVariableFont.lfWeight = FW_BOLD; lfSystemVariableFont.lfWeight = FW_BOLD;
m_BoldFont = CreateFontIndirect(&lfSystemVariableFont); m_BoldFont = CreateFontIndirect(&lfSystemVariableFont);
} }
SendMessage(WM_SETFONT, (WPARAM)m_BoldFont); SendMessage(WM_SETFONT, (WPARAM)m_BoldFont);
InvalidateRect(NULL); InvalidateRect(NULL);
if (m_TextField) if (m_TextField)
{ {
::SendMessage(m_TextField, WM_SETFONT, (WPARAM)m_BoldFont, 0); ::SendMessage(m_TextField, WM_SETFONT, (WPARAM)m_BoldFont, 0);
::InvalidateRect(m_TextField, NULL, true); ::InvalidateRect(m_TextField, NULL, true);
} }
} }
else else
{ {
if (m_OriginalFont) if (m_OriginalFont)
{ {
SendMessage(WM_SETFONT, (WPARAM)m_OriginalFont); SendMessage(WM_SETFONT, (WPARAM)m_OriginalFont);
InvalidateRect(NULL); InvalidateRect(NULL);
if (m_TextField) if (m_TextField)
{ {
::SendMessage(m_TextField, WM_SETFONT, (WPARAM)m_OriginalFont, 0); ::SendMessage(m_TextField, WM_SETFONT, (WPARAM)m_OriginalFont, 0);
::InvalidateRect(m_TextField, NULL, true); ::InvalidateRect(m_TextField, NULL, true);
} }
} }
} }
} }
stdstr CModifiedEditBox::GetWindowText(void) stdstr CModifiedEditBox::GetWindowText(void)
{ {
stdstr Result; stdstr Result;
ATLASSERT(::IsWindow(m_hWnd)); ATLASSERT(::IsWindow(m_hWnd));
int nLen = ::GetWindowTextLength(m_hWnd); int nLen = ::GetWindowTextLength(m_hWnd);
if (nLen == 0) if (nLen == 0)
{ {
return Result; return Result;
} }
Result.resize(nLen + 1); Result.resize(nLen + 1);
::GetWindowText(m_hWnd, (char *)Result.c_str(), nLen + 1); ::GetWindowText(m_hWnd, (char *)Result.c_str(), nLen + 1);
return Result; return Result;
} }
void CModifiedEditBox::SetTextField(HWND hWnd) void CModifiedEditBox::SetTextField(HWND hWnd)
{ {
if (m_TextField && m_OriginalFont) if (m_TextField && m_OriginalFont)
{ {
::SendMessage(m_TextField, WM_SETFONT, (WPARAM)m_OriginalFont, 0); ::SendMessage(m_TextField, WM_SETFONT, (WPARAM)m_OriginalFont, 0);
} }
m_TextField = hWnd; m_TextField = hWnd;
if (m_Changed && m_BoldFont) if (m_Changed && m_BoldFont)
{ {
::SendMessage(m_TextField, WM_SETFONT, (WPARAM)m_BoldFont, 0); ::SendMessage(m_TextField, WM_SETFONT, (WPARAM)m_BoldFont, 0);
} }
} }