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;
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;
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);