Start with the project you created in Low-Level DigitalPaint: Filling an Area.
IDM_PAINTTEST_TEXT
static L_VOID OnText ( HWND hWnd, pPAINTHANDLE pPaint )
{
HDC hDC ;
PAINTTEXT text ;
RECT rcText ;
LOGFONTW lf ;
HFONT hFont ;
// 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 ) ;
// 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
L_PntSetProperty ( pPaint, 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
L_PntApplyText ( pPaint, hDC, &rcText ) ;
// Delete the font object
DeleteObject ( hFont ) ;
// Release the device context
ReleaseDC ( hWnd, hDC ) ;
}
Add the following line after the "return 0L ;" of the "case IDM_PAINTTEST_FILL
:" statement:
case IDM_PAINTTEST_TEXT:
OnText ( hWnd, pPaint ) ;
return 0L ;
Compile and run the project by selecting Build->Execute tutorial.exe from the menu.