Ver Mensaje Individual
  #8  
Antiguo 01-05-2010
Avatar de mamcx
mamcx mamcx is offline
Moderador
 
Registrado: sep 2004
Ubicación: Medellín - Colombia
Posts: 3.913
Reputación: 25
mamcx Tiene un aura espectacularmamcx Tiene un aura espectacularmamcx Tiene un aura espectacular
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 para visualizar & descargar plugins para BestSeller
Autor: Mario Montoya
}
interface

uses
  {$ifdef FPC}
  LResources,
  {$else}
  Windows,
  {$endif}
  Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ComCtrls, ImgList, StdCtrls, Buttons, ExtCtrls, IniFiles,
  {MotionServer} 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
    { Private declarations }
    FPluginManager : TPluginManager;
    FPlugins:TStringList;
    procedure HidePanels;
    procedure ShowPanels;
    procedure btnDownloadClick(Sender: TObject);
  public
    { Public declarations }
    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;//except
    end;//try
  finally
    Cursor := crDefault;
  end;//try
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;//except
    end;//try
  finally
    Cursor := crDefault;
  end;//try

  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;//if

    item.btnDownload.OnClick := btnDownloadClick;
    item.btnDownload.Tag := i;
  end;//for

  HidePanels;
end;

end.
__________________
El malabarista.
Responder Con Cita