changing font of a static text
I am trying to change the font of a static text that I created in the
resource editor in Visual Studio. However, when I run the following
OnCreate function to change the font during initialization:
int UserControls::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CFormView::OnCreate(lpCreateStruct) == -1) return -1;
// Get device context
m_chdc = new CClientDC(this);
CFont unitfont;
unitfont.CreatePointFont(60, "MS Shell Dlg", m_chdc);
unitlabel01.SetFont(&unitfont);
SetTimer(ADEPTHSLIDER, 1000, NULL); // sampling timer for showing
slider position
return 0;
}
I encountered a runtime error as shown here (http://imagebin.org/
46581). The breakpoint that the assertion triggered is in this
function:
_AFXWIN_INLINE void CWnd::SetFont(CFont* pFont, BOOL bRedraw)
{ ASSERT(::IsWindow(m_hWnd)); ::SendMessage(m_hWnd, WM_SETFONT,
(WPARAM)pFont->GetSafeHandle(), bRedraw); }
I'm not sure what went wrong with my attempt to change the font. Some
pointers would be helpful.
Thanks.