GUI is a bit different when it comes for example to selecting units in a strategy game. I usually make a loop of shown units that calculates which one's center point is nearest to the cursor, while cursor has to be closer than unit radius. That way it always clicks the unit you are pointing at.

Code:
Selected:=-1; Nearest:=9999;
for i:=0 to UnitCount-1 do
  with unit[i] do begin
    temp:=hypot(mouseX-X,mouseY-Y);
    if &#40;temp<Nearest&#41; and &#40;temp<=Radius&#41; then begin
      Selected&#58;=i; Nearest&#58;=temp;
    end;
  end;
// And here our Selected variable is index to closest unit to cursor
// if it is greater than or equal to 0 ...