void DemoTextsAndStyles (HANDLE hLcWnd)
{
HANDLE hDrw, hBlock, hTStyle;
WCHAR* szStyleName;
WCHAR* szFontName;
WCHAR szText[256];
int i;
bool bWinFont;
double X, Y, H;
// get drawing and block, linked with CAD window
hDrw = lcPropGetHandle( hLcWnd, LC_PROP_WND_DRW );
hBlock = lcPropGetHandle( hLcWnd, LC_PROP_WND_BLOCK );
// add text styles and text entity for each style
X = 0;
Y = 0;
H = 5.0;
for (i=0; i<4; ++i){
switch( i ){
case 0:
szStyleName = L"Style 1";
szFontName = L"Arial";
bWinFont = true;
break;
case 1:
szStyleName = L"Style 2";
szFontName = L"gothice";
bWinFont = false;
break;
case 2:
szStyleName = L"Style 3";
szFontName = L"Times New Roman";
bWinFont = true;
break;
case 3:
szStyleName = L"Style 4";
szFontName = L"italicc";
bWinFont = false;
break;
}
// get text style with specified name
hTStyle = lcDrwGetObjectByName( hDrw, LC_OBJ_TEXTSTYLE, szStyleName );
if (hTStyle == NULL){
// the style don't exist, create new text style
hTStyle = lcDrwAddTextStyle( hDrw, szStyleName, szFontName, bWinFont );
}
if (hTStyle){
// set current text style
lcPropPutHandle( hDrw, LC_PROP_DRW_TEXTSTYLE, hTStyle );
// make text string as "<style name> - <font name>"
wcscpy( szText, lcPropGetStr( hTStyle, LC_PROP_TSTYLE_NAME ));
wcscat( szText, L" - " );
wcscat( szText, lcPropGetStr( hTStyle, LC_PROP_TSTYLE_FONT ));
// set default text height
lcPropPutFloat( hTStyle, LC_PROP_TSTYLE_HEIGHT, H );
// add text entity
lcBlockAddText( hBlock, szText, X, Y );
Y = Y - (H + H);
}
}
// zoom extents
lcWndZoomRect( hLcWnd, 0,0,0,0 );
}