...
lcEventSetProc( LC_EVENT_LBDOWN, EventProc, 0, 0 );
...
//-----------------------------------------------
void CALLBACK EventProc (HANDLE hEvent)
{
int EventType;
EventType = lcPropGetInt( hEvent, LC_PROP_EVENT_TYPE );
switch( EventType ){
...
case LC_EVENT_LBDOWN:
OnLBDown( hEvent );
break;
...
}
}
//-----------------------------------------------
void OnLBDown (HANDLE hEvent)
{
HANDLE hLcWnd, hEnt;
int i, nEnts, Color, Xwin, Ywin;
BOOL bCtrl;
// State of Ctrl key: 1-pressed, 0-released
bCtrl = lcPropGetInt( hEvent, LC_PROP_EVENT_INT4 );
if (bCtrl){
// graphics window handle
hLcWnd = lcPropGetHandle( hEvent, LC_PROP_EVENT_WND );
// get cursor coordinates (window coordinate space, pixels)
Xwin = lcPropGetInt( hEvent, LC_PROP_EVENT_INT1 );
Ywin = lcPropGetInt( hEvent, LC_PROP_EVENT_INT2 );
// get entities under cursor position
nEnts = lcWndGetEntsByPoint( hLcWnd, Xwin, Ywin, -1 );
if (nEnts > 0){
for (i=0; i<nEnts; ++i){
hEnt = lcWndGetEntity( i );
// change entity color
Color = lcPropGetInt( hEnt, LC_PROP_ENT_COLOR );
if (Color == RGB(255,0,0)){
lcPropPutInt( hEnt, LC_PROP_ENT_COLOR, RGB(255,255,0) );
lcPropPutInt( hEnt, LC_PROP_ENT_FCOLOR, RGB(255,255,0) );
}else{
lcPropPutInt( hEnt, LC_PROP_ENT_COLOR, RGB(255,0,0) );
lcPropPutInt( hEnt, LC_PROP_ENT_FCOLOR, RGB(255,0,0) );
}
}
lcWndGetEntity( -1 ); // free memory
lcWndRedraw( hLcWnd );
}
// disable LiteCAD default actions on this event
lcEventReturnCode( 1 );
}
}