Delphi-Kylix
  Home arrow Delphi-Kylix arrow Page 4 - Finishing the Client for an Internet Acces...
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
DELPHI-KYLIX

Finishing the Client for an Internet Access Control Application
By: David Web
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2008-10-06

    Table of Contents:
  • Finishing the Client for an Internet Access Control Application
  • Check the ini file
  • Code Explained
  • The Timer Window

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Finishing the Client for an Internet Access Control Application - The Timer Window


    (Page 4 of 4 )

    The timer will keep the user informed of how much time she has left for the session. It will automatically put itself in the bottom right corner of the screen. When there is only one minute left, the user will be given a warning saying that they should save their work and the window will turn red. Below is a listing of the code that makes it all happen:

    Listing 2:


    unit utimer;


    interface


    uses

    Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

    Dialogs, ExtCtrls, StdCtrls;


    type

    TForm2 = class(TForm)

    Timer1: TTimer;

    Label1: TLabel;

    StaticText1: TStaticText;

    Image1: TImage;

    StaticText2: TStaticText;

    Label2: TLabel;

    Label3: TLabel;

    procedure Timer1Timer(Sender: TObject);

    procedure FormShow(Sender: TObject);

    private

    { Private declarations }

    public

    { Public declarations }

    times:integer;

    end;


    var

    Form2: TForm2;


    implementation


    uses uclient;


    {$R *.dfm}


    procedure TForm2.Timer1Timer(Sender: TObject);

    var

    BlockInput : function(Block: BOOL): BOOL; stdcall;


    begin

    times:=times-1;

    label1.caption:=inttostr(times);

    if times = 1 then

    begin

    form2.Color:=clred;

    label3.caption:='You have one minute left,'+#13#10+'please save your work.';

    end;

    if times = 0 then

    begin

    //users time is up, disable the timer:

    timer1.Enabled:=false;

    //write to server, inform that times up and free this workstation

    form1.tc.Socket.WriteLn('timesup:'+form1.edname.text+'@plchldr');

    //form1.tc.Socket.WriteLn('timesup:'+form1.GetComputerName+'@plchldr');

    //activate the screenblock or lock the workstation

    form1.visible:=true;

    form1.setoff:=true;

    //close the timer form

    form2.close;

    end;

    end;


    procedure TForm2.FormShow(Sender: TObject);

    begin

    if times > 0 then

    begin

    form2.Color:=clblack;

    label1.Caption:=inttostr(times);

    label2.Caption:=inttostr(times);

    timer1.enabled:=true;

    end;

    end;


    end.

    Most of the code in here is responsible for updating the user interface. The workhorse is the timer event, which we will discuss.

    When a session is started, the main application that we discussed before sends the time that is allocated to the timer form in a variable called "times." The timer component that I'm using deducts one from the times variable. For example, if the times variable contains fifteen, then every minute that passes will deduct one from the variable until it reaches zero, at which time the session will be ended. Let's walk through the code that does all of this.

    Code that sets session time, deducts one for every minute that passes, and updates the appropriate visual accordingly: 

    times:=times-1;

    label1.caption:=inttostr(times);


    When the times variable reaches the number one the warning to save the work is shown:


    if times = 1 then

    begin

    form2.Color:=clred;

    label3.caption:='You have one minute left,'+#13#10+'please save your work.';

    end;


    When the session time is used up, a message is sent to the server informing it of the change:


    if times = 0 then

    begin

    //users time is up, disable the timer:

    timer1.Enabled:=false;

    //write to server, inform that times up and free this workstation

    //this is the debug version of the communication, comment it out when implementing the application

    form1.tc.Socket.WriteLn('timesup:'+form1.edname.text+'@plchldr');


    {uncomment the line below if you are implementing this program}

    //form1.tc.Socket.WriteLn('timesup:'+form1.GetComputerName+'@plchldr');


    The workstation is then lock, i.e. keyboard and mouse access is blocked:

    //activate the screen block or lock the workstation

    form1.visible:=true;

    form1.setoff:=true;


    The timer form is closed:


    //close the timer form

    form2.close;

    end;


    Below is a screen shot of the server with three workstations connected to it.



    The three client applications that you see are debug versions. The full client version will usually be located on a separate computer and will cover the entire screen.


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

     

    DELPHI-KYLIX ARTICLES

    - Loading an XML Document into the DOM
    - Delphi Wrapper Classes and XML
    - Delphi and the DOM
    - Delphi and XML
    - Internet Access: Client Service
    - Finishing the Client for an Internet Access ...
    - The Client for an Internet Access Control Ap...
    - User Management for an Internet Access Contr...
    - Important Procedures for an Internet Access ...
    - Server Code for an Internet Access Control A...
    - Constructing the Interface for an Internet A...
    - Building a Server Application for an Interne...
    - Building an Internet Access Control Applicat...
    - Client Dataset: Working with Data Packets an...
    - Using the Client Dataset in an N-Tiered Appl...







    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 3 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek