
|
Hasta aquí hemos utilizado la forma de registración estándar llamándola con el método execute. No obstante, Ud. también puede construir su propia forma de registración y crear su propio método execute para invocarlo. Permítanos mostrarle cómo hacerlo.
|
.
1. Abra su proyecto en Delphi IDE.
2. Agregue un nuevo Form a su proyecto (File|New Form).

Cambie el nombre a RegForm1.
3. Agregue estos controles a su form:
//para Delphi
Memo1: TMemo;
Label1: TLabel;
Progressbar1: TProgressbar;
BtnCancel: TButton;
BtnReg: TButton;
BtnOk: TButton;
//para la plataforma .NET en lenguaje C# (ver demo4)
public System.Windows.Forms.TextBox memo1;
public System.Windows.Forms.Label label1;
public System.Windows.Forms.ProgressBar pb1;
public System.Windows.Forms.Button BtnCancel;
public System.Windows.Forms.Button BtnReg;
public System.Windows.Forms.Button BtnOk;
4. Entre codigo para estos manejadores de eventos:
//para Delphi
procedure TRegForm1.BtnCancelClick(Sender: TObject);
begin
modalresult:=mrCancel;
end;
procedure TRegForm1.BtnOkClick(Sender: TObject);
begin
modalresult:=mrOk;
end;
procedure TRegForm1.BtnRegClick(Sender: TObject);
begin
modalresult:=mrYes;
end;
//para la plataforma .NET en lenguaje C# (ver demo4)
private void BtnCancel_Click(object sender, System.EventArgs e)
{
DialogResult = DialogResult.Cancel;
}
private void BtnOk_Click(object sender, System.EventArgs e)
{
DialogResult = DialogResult.OK;
}
private void BtnReg_Click(object sender, System.EventArgs e)
{
DialogResult = DialogResult.Yes;
}
5. Comente estas dos lineas:
//var
//RegForm1: TRegForm;
6. En Project|Options|Forms, mueva RegForm1 al panel derecho (Available forms).
7. Abra su form principal y cree aquí su propia función MyExecute.
//Ejemplo en Object Pascal para Delphi
function TForm1.MyExecute:boolean;
var F:TRegForm1;
begin
Result:=False;
try
with avlockG51 do
begin
read;
writelastdate;
Maketrial;
Result:= NotShow;
if not result then
begin
F:=TRegForm1.Create(nil);
try
F.Caption:=AppName;
F.BtnOk.Enabled:=not expired;
F.Label1.caption:=GetText1;
F.Memo1.Lines.add(GetText2);
F.Progressbar1.Min :=0;
F.Progressbar1.Max := trunc(enddate-BeginDate);
F.Progressbar1.Position := trunc(date-BeginDate);
F.ShowModal;
if F.modalresult = mrYes then
begin
execute; Result:=True;
end else if (F.modalresult = mrOk) then Result:=True;
finally
F.Free;
end;
end;
setmodules;
settext;
end;
except
application.terminate;
end;
end;
//Ejemplo en C# para la plataforma .NET
private bool myexecute()
{
bool result=false;
try
{
avLockGold1.read();
avLockGold1.writelastdate();
avLockGold1.maketrial();
result= avLockGold1.notshow();
if (!result)
{
Form1 F = new Form1();
F.Text=avLockGold1.FAppName;
F.BtnOk.Enabled = (!avLockGold1.FExpired);
F.label1.Text = avLockGold1.gettext1();
F.memo1.Text = avLockGold1.gettext2();
ushort d = avLockGold1.datetoword(DateTime.Now);
ushort b = avLockGold1.datetoword(avLockGold1.FBeginDate);
ushort e = avLockGold1.datetoword(avLockGold1.FEndDate);
if (e<d) e=d;
if (b>d) b=d;
F.pb1.Minimum = b;
F.pb1.Maximum = e;
F.pb1.Value = d;
DialogResult mresult = F.ShowDialog();
if (mresult == DialogResult.Yes) //register
{
avLockGold1.execute(); result=true;
}
else if (mresult == DialogResult.OK) result=true;
}
//setmodules();
//settext();
}
catch
{
Application.Exit();
}
return result;
}
8. Agregue esta linea al evento OnCreate de su form principal, (evento OnLoad para C#).
//Para Delphi
procedure TForm1.FormCreate(Sender: TObject);
begin
if not myExecute then application.Terminate;
end;
//Para la plataforma .NET en lenguaje C# (ver demo4)
private void Form4_Load(object sender, System.EventArgs e)
{
if (!myexecute()) Application.Exit();
}
9. Ejecute su nuevo programa trial.
Observe los ejemplos demo3 y demo4 para ver cómo realizar programas triales más avanzados.
.
Si hay algo que no quedó claro o tiene preguntas no respondidas por esta ayuda, por favor no dude en contactarnos en nuestro sitio http://valega.com/contacto.php.
|