Code sample Home

Create multiline text with stacked characters

void DemoMText (HANDLE hLcWnd)
{
  double x0, y0, W, H, Ht;
  HANDLE hDrw, hBlock, hTStyle, hText;
  WCHAR* szText = L"\\A1;H\\H0.5x;\\S^2;\\H2x;O 1\\H0.6x;\\S2/3;\\H1.6667x;+4\\H0.6x;\\S0.5^;\\H1.6667x;=3.66666...";

  // get drawing and block, linked with CAD window
  hDrw = lcPropGetHandle( hLcWnd, LC_PROP_WND_DRW );
  hBlock = lcPropGetHandle( hLcWnd, LC_PROP_WND_BLOCK );
  // set font "Arial" for the text style "Standard"
  hTStyle = lcPropGetHandle( hDrw, LC_PROP_DRW_TEXTSTYLE_STD );
  lcPropPutBool( hTStyle, LC_PROP_TSTYLE_WINFONT, true );
  lcPropPutStr( hTStyle, LC_PROP_TSTYLE_FONT, L"Arial" );
  lcPropPutBool( hTStyle, LC_PROP_TSTYLE_SOLID, true );
  // set active text style
  lcPropPutHandle( hDrw, LC_PROP_DRW_TEXTSTYLE, hTStyle );
  // add multiline text
  x0 = 0.0;
  y0 = 0.0;
  W = 130.0;  // wrap width
  Ht = 10.0;  // text height
  hText = lcBlockAddMText( hBlock, szText, x0, y0, W, LC_TA_CENTER, 0.0, Ht, 1.0 );
  // add bounding rectangle
  W = lcPropGetFloat( hText, LC_PROP_MTEXT_WRECT ) * 1.1;
  H = lcPropGetFloat( hText, LC_PROP_MTEXT_HRECT ) * 1.2;
  lcBlockAddRect( hBlock, x0, y0, W, H, 0.0, false );
  // update view
  lcBlockUpdate( hBlock, true, 0 );
  lcWndExeCommand( hLcWnd, LC_CMD_ZOOM_EXT, 0 );
}
This will create a drawing as shown on the picture below:



Used functions:

lcBlockAddMText
lcBlockAddRect

lcBlockUpdate

lcWndExeCommand

lcPropGetHandle
lcPropGetFloat
lcPropPutBool
lcPropPutStr
lcPropPutHandle