Estas seguro de eso, (RownCount - 1) es el índice de la ultima fila. O estas diciendo que dephi se confunde y sigue incrementando J :-\Aqui hay un problema:
delphi
for j:= 1 to StringGrid1.RowCount - 1 do
Se pasa y no se detiene cuando llega a la ultima linea(row) del stringgrid.
Cargar un StringGrid con un file Intelhex.
Comenzado por
Guest_Jose Fco_*
, nov 03 2008 05:04
24 respuestas en este tema
#21
Escrito 09 noviembre 2008 - 01:02
#22 Guest_Jose Fco_*
Escrito 09 noviembre 2008 - 02:19
Yo creo un stringgrid de 256 lineas y luego al llenarlo con el file Intelhex se pasa de esa linea.
Dejame hacer otra prueba y postear una foto de lo que digo.
Un Saludo.
Dejame hacer otra prueba y postear una foto de lo que digo.
Un Saludo.
#23 Guest_Jose Fco_*
Escrito 09 noviembre 2008 - 02:31
Aqui esta todo el codigo donde estoy trabajando solo con un stringgrid:
Cuando cuando copilo todo esta bien, crea el stringgrid deceado.Pero de solo hacer click en el boton se desforma el stringgrid y se hace mas grande(mas lineas)
Es a lo que me refiero.Entonces pues delphi ve que le decimos hasta la ultima linea menos una y el es obediente.Algo al hacer click al boton y antes de selecionar file alguno incrementa las lineas al grid.
Un Saludo.
delphi
type TBuffer = array[$0000..$FFFF] of Byte; TForm1 = class(TForm) StringGrid1: TStringGrid; Button1: TButton; OpenDialog1: TOpenDialog; procedure FormShow(Sender: TObject); procedure Button1Click(Sender: TObject); private procedure InicializaGridBuffer; { Private declarations } public { Public declarations } end; const BufferSize = 4096; var Form1: TForm1; Cuantos, CuentaB : Integer; implementation {$R *.dfm} procedure TForm1.InicializaGridBuffer; var i,r,j,k,l: integer; begin StringGrid1.ColWidths[0] := 35; StringGrid1.Cells[0,0] := 'Addr'; for i := 0 to 15 do StringGrid1.Cells[i+1,0] := IntTohex(i,2); for j := 0 to (BufferSize div 16)-1 do // (BufferSize div 16) begin k := j; StringGrid1.Height := StringGrid1.Height + 1; StringGrid1.RowCount := StringGrid1.RowCount + 1; StringGrid1.Cells[0,k+1] := IntToHex(l,4); l := l + 16; for r := 1 to 16 do StringGrid1.Cells[r,k+1] := IntToHex(255,2); end; end; procedure TForm1.FormShow(Sender: TObject); begin InicializaGridBuffer; CuentaB := 0; end; // Insertamos la linea de datos en un buffer function Insertar(Str: String; var Buffer: TBuffer): String; var i,j,k: Integer; begin Result:= EmptyStr; Str:= Trim(Str); if Copy(Str,1,1) = ':' then if TryStrToInt('$' + Copy(Str,2,2),i) then if Length(Str) = ((2*i) + 11) then if TryStrToInt('$' + Copy(Str,4,4),j) then if TryStrToInt('$' + Copy(Str,8,2),k) then if k = 0 then begin Str:= Copy(Str,10,2*i); for k:= j to (j + i - 1) do begin Buffer[k]:= StrToInt('$' + Copy(Str,1,2)); Delete(Str,1,2); end; end; end; procedure TForm1.Button1Click(Sender: TObject); var i,j: Integer; Buffer: TBuffer; begin if OpenDialog1.Execute then begin //for i:= 1 to StringGrid1.RowCount - 1 do //StringGrid1.Rows[i].Clear; with TStringList.Create do try LoadFromFile(OpenDialog1.Filename); // Llenamos todo el buffer con $FF FillChar(Buffer,Sizeof(Buffer),#$FF); // Leemos el archivo linea a linea e insertamos los datos en el buffer for i:= 0 to Count - 1 do Insertar(Strings[i],Buffer); for j:= 1 to StringGrid1.RowCount - 1 do for i:= 1 to StringGrid1.ColCount - 1 do StringGrid1.Cells[i,j]:= IntToHex(Buffer[((j-1)*16)+i-1],2); finally Free; end; end; end; end.
Cuando cuando copilo todo esta bien, crea el stringgrid deceado.Pero de solo hacer click en el boton se desforma el stringgrid y se hace mas grande(mas lineas)
Es a lo que me refiero.Entonces pues delphi ve que le decimos hasta la ultima linea menos una y el es obediente.Algo al hacer click al boton y antes de selecionar file alguno incrementa las lineas al grid.
Un Saludo.
#24
Escrito 09 noviembre 2008 - 02:53
¿A que boton te refieres?, si es el de ejecutar de delphi, fijate que que el procedure InicializaGridBuffer estas aumentando en 256 filas el stringgrid.Pero de solo hacer click en el boton se desforma el stringgrid y se hace mas grande(mas lineas)
#25 Guest_Jose Fco_*
Escrito 09 noviembre 2008 - 03:09
Yo copilo y esto es lo que sale:
Luego al solo darle al boton que tengo en el form esto es lo que pasa:
Se incrementa o mejor dicho creo que se crea otra vez el stringgrid pero sin address.(FF) solo F en las grid.
En algun lado del codigo esta entendiendo eso.
Un Saludo.
Luego al solo darle al boton que tengo en el form esto es lo que pasa:
Se incrementa o mejor dicho creo que se crea otra vez el stringgrid pero sin address.(FF) solo F en las grid.
En algun lado del codigo esta entendiendo eso.
Un Saludo.