COleControl::OnFontChanged

virtual void OnFontChanged( );

Remarks

Called by the framework when the stock Font property value has changed. The default implementation calls COleControl::InvalidateControl. If the control is subclassing a Windows control, the default implementation also sends a WM_SETFONT message to the control’s window.

Override this function if you want notification after this property changes.

Example

// SampleActCtrl.cpp

void CSampleActCtrl::OnFontChanged() 
{
   //////////////////////////////////////////////////////////
   // Always set it to the container's font
   if (m_MyEdit.m_hWnd != NULL)
   {
      IFontDisp* pFontDisp = NULL;
      IFont *pFont = NULL;
      HRESULT hr;

      // Get the container's FontDisp interface
      pFontDisp = AmbientFont();
      if (pFontDisp)
      {
         hr = pFontDisp->QueryInterface(IID_IFont, (LPVOID *) &pFont);
         if (FAILED(hr))
         {
            pFontDisp->Release();
            return;
         }
      }

      HFONT hFont = NULL;
      if (pFont)
      {
         pFont->get_hFont(&hFont);
         m_MyEdit.SendMessage(WM_SETFONT, (WPARAM)hFont, 0L);
      }

      pFontDisp->Release();
   }

   // Invalidate the control
   m_MyEdit.Invalidate();
   m_MyEdit.UpdateWindow();
   ///////////////////////////////////////////////////////////
   
   COleControl::OnFontChanged();
}

COleControl OverviewClass MembersHierarchy Chart

See Also   COleControl::GetFont, COleControl::InternalGetFont, COleControl::InvalidateControl