Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS General Discussion » Is there a way to change the font for printing a grid? Collapse All
Subject Author Date
Richard Rodruck Sep 6, 2007 - 6:42 PM

When I print a grid the font is very large. It is as though the DC is not changed form the screen to the printer DC.

Technical Support Sep 10, 2007 - 2:12 PM

By default, in the grid windows the same font is used for the desktop painting, printing and print previewing. This font is returned by the grid’s OnSiwGetDefaultFont() virtual method. We do not support custom fonts for desktop and printer for particular cells. So, we will discuss only the font replacement for the entire grid. To change the default printing and print preview font in your print-preview-able grid control, you should override the CExtPPVW_Printable::OnPrepareDC() virtual method:

      virtual void OnPrepareDC(
            CDC * pDC,
            CPrintInfo * pInfo = NULL
            )
      {
            ASSERT_VALID( this );
            ASSERT_VALID( pDC );
            ASSERT( pDC->GetSafeHdc() != NULL );
            pInfo; // unused parameter
            CFont * pFont = . . . // your custom font
            ASSERT( pFont->GetSafeHandle() != NULL );
            pDC->SelectObject( pFont );
      }