LiteCAD API reference

一、Initialization

1.BOOL lcInitialize ();
Performs LiteCAD initialization. This function should be called once at the start of your application.Global properties can be set before lcInitialize.
2.BOOL lcUninitialize (BOOL bSaveConfig );
Parameters:
bSaveConfig(If TRUE, then LiteCAD will save current system configuration into the LC_PROP_G_DIRCFG directory.)

Attention:
If your application will work with camera device using IC Imaging Control DLL
then you also have to call the following functions :lcTIS_InitLibrarylcTIS_CloseLibrary.

二、Access Objects Properties

LiteCAD objects property can be one of the following types:
Boolean (true or false),
Integer (32 or 64 bit, depends on Windows bits),
Float (64-bit double float),
String (Unicode, 16 bit per character),
Handle (32 or 64 bit pointer, depends on Windows bits).

Each property has a symbolic name, written with template LC_PROP_object_propname, where object - object name, and the propname is a property name.

1.BOOL lcPropGetBool (HANDLE hObject, int idProp);
Parameters:
hObject(Handle to object.);idProp(Property’s identifier. ).
Return Value:
Property’s value.
其他类似的函数:lcPropGetInt;lcPropGetFloat;lcPropGetStr;lcPropGetHandle.
2. BOOL lcPropPutHandle ( HANDLE hObject,int idProp,HANDLE hValue);
Parameters:
hObject(Handle to object.);idProp(Property’s identifier.);hValue(Property’s new value.).
Return Value:
If the function succeeds, the return value is nonzero (TRUE).
其他类似的函数:lcPropPutBool;lcPropPutInt;lcPropPutFloat;lcPropPutStr.

Attention:
1.Some properties have more then one type, for example, you can set active layer either by its name or by handle:
lcPropPutStr (hDrw, LC_PROP_DRW_LAYER, L"Streets" );
lcPropPutHandle (hDrw, LC_PROP_DRW_LAYER, hLayer);
2.LiteCAD system variables are global properties, therefore in the lcProp… functions use NULL for the hObject parameter:
lcPropPutStr( 0, LC_PROP_G_DLGVAL, szFileName ).

三、Global properties

全局属性

四、Status Bar

1.HANDLE lcCreateStatbar (HWND hWndParent );
Parameters:
hWndParent(Handle to a parent window.)
Return Value:
Handle to the created object.If the function fails, the return value is NULL.
Remarks:
The size and position must be set later with the function lcStatbarResize.
2. BOOL lcDeleteStatbar (HANDLE hStarbar );
3.BOOL lcStatbarResize (HANDLE hStatbar, int Left,int Top,
int Width,int Height);

4. BOOL lcStatbarCell (HANDLE hStatbar,int Id,int Pos);
Parameters:
hStatbar(Handle to a status bar object.);Id(Specifies the cell identifier.);Pos(Specifies the cell position. )
5.BOOL lcStatbarText (HANDLE hStatbar,int Id,LPCWSTR szText);
Parameters:
hStatbar(Handle to a status bar object.);Id(Specifies the cell identifier.);szText(Specifies text string to be drawn in the cell. )
6. BOOL lcStatbarRedraw (HANDLE hStarbar);

The Status Bar object has the following properties:
LiteCAD参考文档的学习一
Code sample:

from \LC_Samples\LaserDraw\  project
HANDLE   g_hStatBar;    // status bar
//-----------------------------------------------
int APIENTRY _tWinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)
{
  ...
  // Create StatusBar
  g_hStatBar = lcCreateStatbar( g_hwMain );
  lcStatbarCell( g_hStatBar, 1, 0 );
  lcStatbarCell( g_hStatBar, 2, 100 );
  lcStatbarCell( g_hStatBar, 3, 200 );
  lcStatbarCell( g_hStatBar, 4, 350 );
  ...
}
//-----------------------------------------------
void OnAppResize (WPARAM SizeType, int Wmain, int Hmain)
{
  int x, y, w, h, Hsbar;

  // Default height of the status bar
  Hsbar = lcPropGetInt( 0, LC_PROP_G_SBARHEIGHT );
  ...
  // StatusBar position
  x = 0;
  y = Hmain - Hsbar + 1;
  w = Wmain;
  h = Hsbar;
  lcStatbarResize( g_hStatBar, x, y, w, h );
}
//-----------------------------------------------
void OnMouseMove (HANDLE hEvent)
{
  ...
  // Display data in status bar
  // X
  okDblToStr( X, szNum, 2 );
  swprintf( szBuf, L"X: %s", szNum );
  lcStatbarText( g_hStatBar, 1, szBuf );
  // Y
  okDblToStr( Y, szNum, 2 );
  swprintf( szBuf, L"Y: %s", szNum );
  lcStatbarText( g_hStatBar, 2, szBuf );
  // redraw the status bar
  lcStatbarRedraw( g_hStatBar );
}

相关文章: