/*
ItemRect example
This example uses a list box on a form. When the user clicks one of the items in the list box, a beep occurs if the mouse is in the first half of the item. A similar technique can be used to detect “hot” regions in an owner-draw list box:
*/ 
void __fastcall TForm1::FormCreate(TObject *Sender)
{
  ListBox1->Items->Add("Hello");
  ListBox1->Items->Add("New");
  ListBox1->Items->Add("World");
}

void __fastcall TForm1::ListBox1MouseUp(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y)
{
  TRect ItemBounds;
  if (Button == mbLeft)
  {
    ItemBounds = ListBox1->ItemRect(ListBox1->ItemIndex);
    if (Y > ItemBounds.Top && 
        Y < ItemBounds.Bottom && 
        X > ItemBounds.Left && 
        X < (ItemBounds.Left + ItemBounds.Right)/2)
      MessageBeep(0);
  }
} 
