L_PntApplyText

#include "LtPnt.h"

L_LTPNT_API L_INT L_PntApplyText (pPaint, UserDC, prcRect)

Writes a character string in the specified rectangle.

Parameters

pPAINTHANDLE pPaint

Pointer to a paint handle.

L_HDC 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.

const LPRECT 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

Value Meaning
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

See Also

Functions

Topics

Example

L_INT PntApplyTextExample(HWND hWnd) 
{ 
   L_INT nRet; 
   pPAINTHANDLE pPaint ; 
   HDC          hDC ; 
   PAINTTEXT    text ; 
   RECT         rcText ; 
   LOGFONT      lf ;  
   HFONT        hFont ; 
 
   memset(&text,0,sizeof(PAINTTEXT)); 
 
   /* 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 ) ; 
 
   /* Set the DC Extents */ 
   RECT rcClient; 
   GetClientRect(hWnd, &rcClient); 
   nRet = L_PntSetDCExtents ( pPaint, &rcClient ); 
 
   /* 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 ; 
} 
Help Version 20.0.2020.4.2
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2020 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Digital Paint C API Help