L_PntApplyText

#include "LtPnt.h"

L_LTPNT_API L_INT L_PntApplyText (pPaint, UserDC, prcRect)

pPAINTHANDLE pPaint;

/* pointer to a paint handle */

L_HDC UserDC;

/* handle to the device context */

const LPRECT prcRect;

/* pointer to a RECT structure */

Writes a character string in the specified rectangle.

Parameter

Description

pPaint

Pointer to a paint handle.

UserDC

Handle to a device context, such as a screen, to use as a display surface. This parameter can also be NULL. The mapping mode of the device context must be MM_TEXT.

prcRect

Pointer to a RECT structure that contains the bounding rectangle in which to write the text. This rectangle will also be used to align the text.

Returns

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

Comments

The text will be drawn using the current text properties. To determine the current text properties, call L_PntGetProperty. To set or change the current text properties, call L_PntSetProperty. For more information on the text properties, refer to the PAINTTEXT structure.

The text string and font must be set before calling this function. Otherwise, the function will return an error.

If UserDC is not NULL, the toolkit will paint the text on the specified device context. If UserDC is NULL, the text will not be painted on a device context.

If the UserDC is not NULL, the user should set the DC boundaries before calling this function, by calling L_PntSetDCExtents.

If a bitmap has been set using the L_PntSetMetrics function, the text will be drawn on the specified bitmap. If UserDC is not NULL and a bitmap has been set using the L_PntSetMetrics function, then the text will be drawn to both the device context and the bitmap.

The font handle in the hFont field of the PAINTTEXT structure should still be valid after calling this function.

Required DLLs and Libraries

LTPNT

For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application

See Also

Functions:

L_PntSetProperty, L_PntSetTransformation, L_PntSetClipRgn, L_PntSetMetrics, L_PntGetProperty, L_PntGetTransformation, L_PntGetClipRgn

Topics:

Painting Text

 

DigitalPaint Functions: Painting Shapes and Text

Example

 L_INT PntApplyTextExample(HWND hWnd)
{
   L_INT nRet;
   pPAINTHANDLE pPaint ;
   HDC          hDC ;
   PAINTTEXT    text ;
   RECT         rcText ;
   LOGFONT      lf ; 
   HFONT        hFont ;

   /* Initiate the Paint toolkit */
   nRet = L_PntInit ( &pPaint );
   if ( SUCCESS != nRet)
   {
      return nRet; 
   }

   /* Get device context to draw on */
   hDC = GetDC ( hWnd ) ;

   /* Set the required text font properties */
   lf.lfHeight         = 48 ;
   lf.lfWidth          = 0 ;
   lf.lfEscapement     = 0 ;
   lf.lfOrientation    = 0 ;
   lf.lfWeight         = FW_NORMAL ;
   lf.lfItalic         = FALSE ;
   lf.lfUnderline      = FALSE ;
   lf.lfStrikeOut      = FALSE ;
   lf.lfCharSet        = ANSI_CHARSET ;
   lf.lfOutPrecision   = OUT_DEFAULT_PRECIS ;
   lf.lfClipPrecision  = CLIP_DEFAULT_PRECIS ;
   lf.lfQuality        = DEFAULT_QUALITY ;
   lf.lfPitchAndFamily = FF_DONTCARE ;
   lstrcpy(lf.lfFaceName, TEXT("Times New Roman"));

   /* Create the desired text font */
   hFont = CreateFontIndirect ( &lf ) ;

   /* Get text properties */
   nRet = L_PntGetProperty ( pPaint, PAINT_GROUP_TEXT, &text ) ;
   if(nRet != SUCCESS)
      return nRet;

   /* Set the desired text properties */
   text.nSize                    = sizeof ( PAINTTEXT ) ;
   text.dwMask                   = PTF_TEXT          |
                                   PTF_FONT          |
                                   PTF_TRANSFORMINFO ;
   text.pszText                  = TEXT("LEAD") ;
   text.hFont                    = hFont ;
   text.TransformInfo.Scale.cx   = 100 ;
   text.TransformInfo.Scale.cy   = 100 ;
   text.TransformInfo.nRotate    = 45 ;

   /* Set the new text properties */
   nRet = L_PntSetProperty ( pPaint, PAINT_GROUP_TEXT, &text ) ;
   if(nRet != SUCCESS)
      return nRet;

   /* Set the target text drawing box coordinates with respect to the DC dimensions */
   SetRect ( &rcText, 10, 10, 200, 200 ) ;

   /* Use the current text properties and the current transformations properties to draw the text to the DC (hDC) */
  nRet = L_PntApplyText ( pPaint, hDC, &rcText ) ;
  if(nRet != SUCCESS)
     return nRet;

   /* Release the device context */
   ReleaseDC ( hWnd, hDC ) ;

   /* Delete the font object */
   DeleteObject ( hFont ) ;

   /* Free the paint tools handle */
   L_PntFree ( pPaint ) ;

   return SUCCESS ;
}