Al final encontre un buen balance entre funcionalidad y facilidad de uso.
Usando un TFrame + TScrollBox. Facil y rapido!. El codigo ppal es asi (el codigo necesito unos fixs pero esta funcional. Para completar, hacer un Frame como lo quieras con aling=AlTop y asi no hay que calcular nada):
Código Delphi
[-]
unit formSelectPlugin;
interface
uses
{$ifdef FPC}
LResources,
{$else}
Windows,
{$endif}
Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls, ImgList, StdCtrls, Buttons, ExtCtrls, IniFiles,
PluginManager, Funciones;
type
TfrmDownloadPlugins = class(TForm)
lbDownload: TLabel;
barDownload: TProgressBar;
ListPlugins: TScrollBox;
Delay: TTimer;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure DelayTimer(Sender: TObject);
procedure FormActivate(Sender: TObject);
private
FPluginManager : TPluginManager;
FPlugins:TStringList;
procedure HidePanels;
procedure ShowPanels;
procedure btnDownloadClick(Sender: TObject);
public
SelectedPlugin:String;
end;
var
frmDownloadPlugins: TfrmDownloadPlugins;
implementation
uses framePlugin;
{$R *.dfm}
procedure TfrmDownloadPlugins.btnDownloadClick(Sender: TObject);
i: Integer;
begin
SelectedPlugin := FPlugins[(Sender as TButton).Tag];
lbDownload.Caption := 'Downloading/updating ' + SelectedPlugin;
HidePanels();
try
Cursor := crHourGlass;
try
FPluginManager.DescargarPlugin( SelectedPlugin );
Close;
except on E: Exception do
begin
ShowPanels();
ShowMessage( E.Message );
end; end; finally
Cursor := crDefault;
end;end;
procedure TfrmDownloadPlugins.FormActivate(Sender: TObject);
begin
Delay.Enabled := True;
end;
procedure TfrmDownloadPlugins.FormCreate(Sender: TObject);
begin
FPluginManager := TPluginManager.Create;
FPluginManager.Load;
ShowPanels();
FPlugins := TStringList.Create;
end;
procedure TfrmDownloadPlugins.FormDestroy(Sender: TObject);
begin
FPluginManager.Free;
FPlugins.Free;
end;
procedure TfrmDownloadPlugins.ShowPanels;
begin
ListPlugins.Visible := False;
end;
procedure TfrmDownloadPlugins.HidePanels;
begin
ListPlugins.Visible := True;
end;
procedure TfrmDownloadPlugins.DelayTimer(Sender: TObject);
var
Ini:TMemIniFile;
item: TfraPlugin;
Key, name, author:String;
plugin:TStringList;
i: Integer;
begin
Delay.Enabled := False;
try
Cursor := crHourGlass;
try
Ini := FPluginManager.ListaPluginsOnline();
except on E: Exception do
begin
ShowMessage( E.Message );
ModalResult := mrCancel;
Close;
Exit;
end; end; finally
Cursor := crDefault;
end;
Ini.ReadSections(FPlugins);
FPlugins.Sort;
for i := 0 to FPlugins.count - 1 do
begin
Key := FPlugins[i];
plugin := Split(Key,'-');
author := plugin[0];
name := plugin[1];
plugin.Free;
item := TfraPlugin.Create( ListPlugins );
item.Name := 'plug'+IntToStr(i);
ListPlugins.InsertControl( item );
item.Align := alTop;
item.lbTitulo.Caption := name;
item.lbVersion.Caption := Ini.ReadString( Key, 'Version','');
if FPluginManager.ListaPlugins.IndexOf( Key )>-1 then
begin
item.btnDownload.Caption := 'Update';
end;
item.btnDownload.OnClick := btnDownloadClick;
item.btnDownload.Tag := i;
end;
HidePanels;
end;
end.