Finishing the Client for an Internet Access Control Application
Last week we began our discussion of the client side of an Internet access control program. This week we'll continue to cover the important parts of the code. We'll start with the reading thread, then go to the ini file. Keep reading to be enlightened.
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:
//activate the screenblock or lock the workstation
//close the timer form
procedure TForm2.FormShow(Sender: TObject);
if times > 0 then
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:
When the times variable reaches the number one the warning to save the work is shown:
if times = 1 then
label3.caption:='You have one minute left,'+#13#10+'please save your work.';
When the session time is used up, a message is sent to the server informing it of the change:
if times = 0 then
//users time is up, disable the timer:
//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
The workstation is then lock, i.e. keyboard and mouse access is blocked:
//activate the screen block or lock the workstation
The timer form is closed:
//close the timer form
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.