AV-SOFT.COM
AVLock SIMPLE
Introduction
What is AVLock Gold?
How to buy AVLock Gold?
How to Upgrade from previous versions?
What's new in version 5
Another AVlock components
License Agreement
Using AVLock Gold
How to install AVLock Gold?
How works AVLockGold?
Brief practice with demo's
Step by step samples
Basic sample
Working with modules
Creating your own registration form
Running on a network
"MoveReg" feature
Some configuration issues
Hacking cautions
How to translate AVLock Gold to any language?
Properties
Methods
Events
Useful concepts
Registration keys
KeyFiles
RegFiles and ControlFiles
RegistryKeys
MasterComputers and RegularComputers
Utilities
AVLockManager
RegMonitor
Configure
KeyGen
Php key generators
FAQs

Creating your own registration form

Top  Previous  Next

avlockg53

Up to here we have used  the built in registration form calling it with the execute method. 

However, you  also can construct your own customized registration form and also create your own method execute to invoke it. Let us see how do it. For more details please see the Demo4 sample.

.

 

1. Open your project into the Delphi IDE.

 

2. Add a new Form to your project (File|New Form).

 

 

form2

 

   Change the name to RegForm1.

 

3. Add these controls to your form:

   //for Delphi

Memo1: TMemo;

Label1: TLabel;

Progressbar1: TProgressbar;

BtnCancel: TButton;

BtnReg: TButton;

BtnOk: TButton;

 

   //for .NET platform in C# language (see 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. Enter code for these event-handlers:

 

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

 

   //for .NET platform in C# language (see 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. Comment these two lines: (only for Delphi)

//var

//RegForm1: TRegForm;

 

6. In Project|Options|Forms, move RegForm1 to the right panel (Available forms). (only for Delphi)

 

7. Open your main form and create here your own MyExecute function.

 

//sample in Object Pascal for 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;

 

//sample in C# for the .NET platform

    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. Add this line to your main form, in the OnCreate event for Delphi or OnLoad event for C#.

 

//for Delphi

procedure TForm1.FormCreate(Sender: TObject);

begin

if not myExecute then application.Terminate;

end;

 

   //for .NET platform in C# language (see demo4)

      private void Form4_Load(object sender, System.EventArgs e)

   {

     if (!myexecute()) Application.Exit();

   }

 

 

9. Run your new trial program.

 

Take a look to the examples demo3 and demo4 to see how to do more full featured trial programs.

.

 

If you have any questions not answered by this help file, please don't hesitate to contact me at http://valega.com/contacto.php.