Ver Mensaje Individual
  #7  
Antiguo 25-09-2013
Neeruu Neeruu is offline
Miembro
 
Registrado: oct 2007
Posts: 512
Reputación: 19
Neeruu Va por buen camino
Código Delphi [-]
type
  TFrmMensaje = class(TForm)
    RxTheme1: TRxTheme;
    PnlBase: TPanel;
    ListBox1: TListBox;
    Panel1: TPanel;
    BtnOk: TButton;
    BtnCancel: TButton;
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure BtnOkClick(Sender: TObject);
    procedure BtnCancelClick(Sender: TObject);    
  private
    neBtnOk:TNotifyEvent;
    neBtnCancel:TNotifyEvent;
    { Private declarations }
  public
    procedure ShowMessage(sCaption:String; sMensaje:TStrings; CantBtn:Integer);

    property BtnOk:TNotifyEvent read neBtnOk write neBtnOk default nil;
    property BtnCancel:TNotifyEvent read neBtnCancel write neBtnCancel default nil;
    { Public declarations }
  end;

var
  FrmMensaje: TFrmMensaje;

implementation

{$R *.dfm}

procedure TFrmMensaje.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  Action := caHide;
end;

procedure TFrmMensaje.BtnCancelClick(Sender: TObject);
begin
  Close;
  if Assigned(BtnCancel) then
    BtnCancel(Self);
end;

procedure TFrmMensaje.BtnOkClick(Sender: TObject);
begin
  Close;
  if Assigned(BtnOk) then
    BtnOk(Self);
end;

procedure TFrmMensaje.ShowMessage(sCaption:String; sMensaje:TStrings; CantBtn:Integer);
begin
  Case CantBtn of
    1:begin
        BtnOk.Left := PnlBase.Width-BtnOk.Width - 6;
        BtnCancel.Visible := False;
        BtnCancel.Enabled := False;
      end;
    else
      begin
        BtnOk.Left := 6;
        BtnCancel.Visible := True;
        BtnCancel.Enabled := True;
      end;
  end;


  FrmMensaje.Caption := sCaption;
  ListBox1.Items.Clear;
  ListBox1.Items := sMensaje;

  FrmMensaje.ShowModal;
end;


Al Form lo llamo de esta manera...

Código Delphi [-]
FrmMensaje.BtnOk := MiProc o Nil dependiendo de que quiero que haga;
FrmMensaje.BtnCancel := MiProc o Nil dependiendo de que quiero que haga;
FrmMensaje.ShowMessage('',MyStringList, 2);

Como debería modificar las propiedades BtnOK y BtnCancel para poder hacer lo siguiente...
Código Delphi [-]
FrmMensaje.BtnOk := (procedure (Sender:TObject)
                               begin
                                     ShowMessage('Presiono el Btn OK');
                               end);
__________________
Saluda Atte Neeruu!!! :)
Responder Con Cita