Add a simple wxSetWindowFont() helper

This function is a just a very thin wrapper for WM_SETFONT, but it's
still better to have it rather than write casts to WPARAM and
MAKELPARAM() in several different places.

Note that this removes the assert for font validity from
wxWindow::SetFont() which really doesn't make much sense (and if we
wanted to have it, it would be better to have it for all ports in
wxWindowBase instead) and was never triggered since more than 20 years
of its existence.
This commit is contained in:
Vadim Zeitlin
2018-12-29 02:11:20 +01:00
committed by Maarten Bent
parent 8e15849706
commit b24d7e3ae4
6 changed files with 12 additions and 14 deletions

View File

@@ -113,14 +113,11 @@ public:
// set font for all windows
void SetFont(const wxFont& font)
{
HFONT hfont = GetHfontOf(font);
wxCHECK_RET( hfont, wxT("invalid font") );
for ( size_t n = 0; n < m_count; n++ )
{
if ( m_hwnds[n] )
{
::SendMessage(m_hwnds[n], WM_SETFONT, (WPARAM)hfont, 0);
wxSetWindowFont(m_hwnds[n], font);
// otherwise the window might not be redrawn correctly
::InvalidateRect(m_hwnds[n], NULL, FALSE /* don't erase bg */);