LRasterPaint::ApplyText
#include "Ltwrappr.h"
L_INT LRasterPaint::ApplyText(UserDC, prcRect)
HDC UserDC; |
/* handle to the device context */ |
LPRECT prcRect; |
/* pointer to a RECT structure */ |
Writes a character string in the specified rectangle.
Parameter |
Description |
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 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 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
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
Example
L_INT TextTest ( CWnd* pWnd )
{
LRasterPaint rstp;
CDC* pDC = pWnd->GetDC() ;
PAINTTEXT text ;
RECT rcText ;
LOGFONT lf ;
HFONT hFont ;
/* Initiate the Paint toolkit */
if ( SUCCESS != rstp.Initialize ( ) )
{
return FAILURE ;
}
/* 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 */
rstp.GetProperty (PAINT_GROUP_TEXT, &text ) ;
/* 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 */
rstp.SetProperty (PAINT_GROUP_TEXT, &text ) ;
/* 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) */
rstp.ApplyText ( pDC->m_hDC, &rcText ) ;
/* Delete the font object */
DeleteObject ( hFont ) ;
/* Free the paint tools handle */
rstp.Free ( ) ;
pWnd->ReleaseDC( pDC ) ;
return SUCCESS ;
}