//---------------------------------------------------------------------------
void
__fastcall TForm1::PaintBox1MouseDown(TObject *Sender, TMouseButton
Button, TShiftState Shift, int X, int Y)
{
int sens = 4; //sensitivity
//test slope equality
if (abs((Y - P1.y)*(P2.x - X) - (x - P1.x)*(P2.y - Y)) < sens)
{
//make sure click is between enpoints
if ((X > P1.x && X < P2.x) || (X < P1.x &&
X >P2.x))
{
//line has been clicked
}
}
}
|