Ver Mensaje Individual
  #2  
Antiguo 29-12-2017
Avatar de ecfisa
ecfisa ecfisa is offline
Moderador
 
Registrado: dic 2005
Ubicación: Tres Arroyos, Argentina
Posts: 10.508
Reputación: 36
ecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to behold
Hola.

No entiendo bien tu dificultad, pero hice una prueba con los valores que indicas en tu mensaje:
Cita:
156|56|183|56|214|56|238|56|
y no me dió ningún problema.

El código de la prueba:
Código Delphi [-]
...

implementation  {$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
const
  VP: array[0..3] of string = ('156','183','214','238');
var
  sg: TStringGrid;
  cv: TCanvas;
  i : Integer;
begin
  sg := StringGrid1;
  sg.FixedCols := 0;
  sg.FixedRows := 0;
  sg.ColCount  := 2;
  sg.RowCount  := 4;
  cv := Image1.Picture.Bitmap.Canvas;
  for i := 0 to 3 do
  begin
    cv.Pixels[StrToInt(VP[i]), 56] := clRed;
    sg.Cells[0, i] := VP[i];
    sg.Cells[1, i] := '56';
  end;
end;


procedure TForm1.Image1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
var
  dx, dy, r : Integer;
  sg: TStringGrid;
begin
  // (quité el case ya que no se necesita para la prueba)
  sg := StringGrid1;
  for r := 0 to StringGrid1.RowCount - 1 do
  begin
    dx := X - (StrToInt(StringGrid1.Cells[0, r]));
    dy := Y - (strToInt(StringGrid1.Cells[1, r]));
    if (abs(dx) < 5) and (abs(dy) < 5) then
    begin
      sg.Selection := TGridRect(Rect(0, r, sg.ColCount, r));
      Label1.Caption := 'Encontrado en renglon ' + inttostr(r);
    end;
  end;
end;
...

Salida:

La única situación en que se me ocurre que podría haber confusión es cuando se solapen los valores de X e Y dada la tolerancia de 5 píxeles que les das.

Saludos
__________________
Daniel Didriksen

Guía de estilo - Uso de las etiquetas - La otra guía de estilo ....

Última edición por ecfisa fecha: 29-12-2017 a las 19:54:29.
Responder Con Cita