LRasterPaint::ApplyText

#include "Ltwrappr.h"

L_INT LRasterPaint::ApplyText(UserDC, prcRect)

Writes a character string in the specified rectangle.

Parameters

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.

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 LRasterPaint::GetProperty. To set or change the current text properties, call LRasterPaint::SetProperty. 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 LRasterPaint::SetDCExtents.

If a bitmap has been set using the LRasterPaint::SetMetrics function, the text will be drawn on the specified bitmap. If UserDC is not NULL and a bitmap has been set using the LRasterPaint::SetMetrics 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 LRasterPaint_ApplyTextExample( CWnd* pWnd )  
{ 
   L_INT          nRet; 
   LRasterPaint   rstp; 
   CDC*           pDC = pWnd->GetDC() ; 
   PAINTTEXT      text ; 
   RECT           rcText ; 
   LOGFONT        lf ; 
   HFONT          hFont ; 
   RECT           rcDCExtents ; 
 
   /* Initiate the Paint toolkit */ 
   nRet = rstp.Initialize ( ); 
   if(nRet != SUCCESS) 
      return nRet; 
 
   /* 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 = rstp.GetProperty (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.nRotate = 45 ; 
 
   /* Set the new text properties */ 
   nRet = rstp.SetProperty (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 ) ; 
 
   /* Get the destination DC dimensions */   
   pWnd->GetClientRect ( &rcDCExtents ) ; 
 
   /* Set the toolkit user DC extents */ 
   nRet = rstp.SetDCExtents ( &rcDCExtents ) ; 
   if(nRet != SUCCESS) 
      return nRet; 
 
   /* Use the current text properties and the current transformations properties to draw the text to the DC (hDC) */ 
   nRet = rstp.ApplyText ( pDC->m_hDC, &rcText ) ; 
   if(nRet != SUCCESS) 
      return nRet; 
 
   /* Delete the font object */ 
   DeleteObject ( hFont ) ; 
 
   /* Free the paint tools handle */ 
   nRet = rstp.Free ( ) ; 
   if(nRet != SUCCESS) 
      return nRet; 
 
   pWnd->ReleaseDC( pDC ) ; 
 
   return SUCCESS ; 
} 
Help Version 21.0.2021.7.2
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS DigitalPaint C++ Class Library Help
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.