Haber si soy capaz de explicarlo sin ocupar más de 500.000 líneas
Tengo un form principal en el que le meto una clave y llama a un segundo form (con ShowModal) que con la clave del anterior hace una consulta a un servidor de mySql, el cual responde con una serie de registros que almaceno en un TListBox (hasta aqui todo funciona)
Este es el código del form principal
Código:
Application.CreateForm(TWin_GetNubes, Win_GetNubes);
with Win_GetNubes do begin
if( Alias='BAJAS' )
then CLV_GRUPO := '001'
else if( Alias='MEDIAS' )
then CLV_GRUPO := '002'
else CLV_GRUPO := '003';
GroupBox_TABLA.Caption := ' TIPOS DE NUBES ' + Alias + ' ';
ShowModal;
Free;
end; // del with
El problema viene, que al visualizar el form, este no se ajusta al texto máximo del TListBox (para que se vea toda la línea)
Este es el código del for problematico
Código:
procedure TWin_GetNubes.Form_OnShow(Sender: TObject);
var
Activo : integer;
Ancho : integer;
Cadena : string;
begin
Ancho := 0;
with Query_NUBES do begin
SQL.Clear;
SQL.Add( 'SELECT * FROM nubes WHERE grupo=''' + CLV_GRUPO + '''');
SQL.Add( ' AND orden<''100''');
SQL.Add( ' ORDER BY orden;' );
Open;
if IsEmpty then begin
{no hacer nada}
end else begin
First;
Activo := -1;
while not eof do begin
Cadena := FieldByName('NOTAS' ).AsString;
if( ListBox_NOTAS.Canvas.TextWidth(Cadena)>Ancho )
then Ancho := ListBox_NOTAS.Canvas.TextWidth(Cadena);
ListBox_GRUPO.Items.Add( FieldByName('GRUPO').AsString );
ListBox_ORDEN.Items.Add( FieldByName('ORDEN').AsString );
ListBox_CLV_SYNOP.Items.Add( FieldByName('CLV_SYNOP').AsString );
ListBox_CLV_METAR.Items.Add( FieldByName('CLV_METAR').AsString );
ListBox_CLV_TCU.Items.Add( FieldByName('CLV_TCU').AsString );
ListBox_NOTAS.Items.Add( Cadena );
if( FieldByName('ORDEN').AsString=CLV_ORDEN )
then Activo := ListBox_ORDEN.Items.Count-1;
Next;
end;
GroupBox_TABLA.Height := (ListBox_NOTAS.Items.Count*(ListBox_NOTAS.ItemHeight+2));
Win_GetNubes.ClientWidth := Ancho + ListBox_CLV_SYNOP.Width + 32;
Win_GetNubes.Height := Panel_SUPERIOR.Height + Panel_SEPARADOR_1.Height + GroupBox_TABLA.Height + Panel_INFERIOR.Height;
Panel_BOTONES.Left := (Win_GetNubes.Width-Panel_BOTONES.Width) div 2;
{ activar las listas }
ListBox_GRUPO.ItemIndex := Activo;
ListBox_ORDEN.ItemIndex := Activo;
ListBox_CLV_SYNOP.ItemIndex := Activo;
ListBox_CLV_METAR.ItemIndex := Activo;
ListBox_CLV_TCU.ItemIndex := Activo;
ListBox_NOTAS.ItemIndex := Activo;
ListBox_CLV_SYNOP.SetFocus;
end;
end;
Win_GetNubes.Caption := '['+IntToStr( Ancho )+']';
Win_GetNubes.Activate;
end;
Todos los TListBox están sincronizados y responden al teclado, solo eso... que no se vé el texto completo
Haber si te vale de algo