This part of my Web site is dedicated to articles dealing with Delphi, a programming environment that I have used since I purchased Delphi 3 in 1998. Since then, I have used Delphi 4, Delphi 5, Delphi 6 and Delphi 2009.
Delphi is an integrated programming environment (IDE) developed by Borland and now owned by Embarcadero. It is derived from Pascal, a programming language based on ALGOL and designed as a language that could be used for teaching. It was developed by Nicholas Wirth in the late 60's. Object-Pascal was developed later for object-oriented programming.
My first undertaking with Delphi has been a (Paradox) database-driven personnel information manager that I still use to-day but that I have never commercialized. Such development entailed the development of several tools and components, the details of which are presented on this site. These programs have been developed some years ago when I was still active in the field. I present them here as I believe that they can be useful to someone. Have fun :-)
Miscellaneous hints, tips and tricks
This is a collection of hints, tips and tricks for Delphi programming. I'll add more snippets and things when I have time or there's some need. Right now it is in rather "messy" order but proper layout is being prepared. Maybe you will find what you want here. The subjects which are developed are the following:
- An algorithm for the calculation of the date of occurrence of Easter Sunday each year;
- How to programmatically find a node in a ShellTreeView component;
- Where to find the VCL component's icons;
- Formatting the display of a TTimeField;
- Get rid of flicker with LockWindowUpdate();
- Specifics for Paradox and dBase tables;
- BLOB has been modified;
- Avoiding data losses in Paradox tables;
- Check Table existence;
- Copy of the structure of a table;
- Copying a table;
- Compacting a table;
- MySQL databases;
- Table types;
- Accessing MySQL databases with Delphi;
- Catching exceptions in threads.
SpamFilter - An Add-In for Outlook
I was tired of purchasing antispam software which all failed one way or another. Some of them were way too slow, others often classified friend E-mails as spam. Some were difficult to use, others had a so poor interface it was a pity, and I was spending too much time fighting spam everyday even with these tools. I decided to do something about it. Since I use Outlook as my mail client software, I tought that it was a very good opportunity to familiarize with Outlook addins and design one that would get rid of that spam. This page presents my approach to the problem. Have a look at it at SpamFilter - An Addin for Outlook.
Since I moved from Windows XP to Windows Vista, I don't use this program anymore (Microsoft Outlook 2000 is no longer supported by this operating system). Now, I use Windows Mail as my mail program and it comes with an effective spam filter.
Support for automation events
I needed to add a new capability to the SpamFilter program that I am developing: that of trapping the addition of new items to the in-box folder of Microsoft Outlook in order to filter out known spammers, the list of which is maintained by the application. This caused me to investigate the way that events are dealt with in COM. This article is a summary of my notes on the subject.
For the development of a personal information manager project, I needed an data-aware formatted memos (TDBRichEdit) editor that would be used in several applications. Either, I would develop a component containing several visual components or I would use a frame (TFrame class), a class introduced with Delphi 5. I selected this approach. Come and see how I did it.
From Delphi, database application developers can access various types of databases using the Borland Database Engine (BDE). It originated in Delphi 1 as an engine for accessing Paradox databases. Despite a few problems, the BDE is one of the reasons for Delphi's success in the database arena and it is a mature technology. The technology was deprecated in 2002.
In the course of developing a personnal information manager using the BDE and a Paradox database, I had to develop three genuine data-aware controls to be used as interfaces to the database. It led me to study component development and in particular the development of data-aware controls.
A data-aware Treeview component
In this article, I have developed a data-aware Treeview component and used the opportunity to show how one must proceed to implement database connectivity and tailor property editors to restrict data fields to certain types. This component fetches its content from a table from a database rather than fill itself from a text file as the TTreeview component of the VCL does. The process is tricky and requires that the table contains specific fields that the component uses.
A data-aware push-button calendar component
This data-aware visual control was required to highlight special days in a database-driven personnal information manager then under development. The component TGtroDBPushButtonCalendar is a class (derived from TCustomGrid) that can be used to implement a special purpose calendar whose main action is to associate or disassociate a record in a dataset with the date selected in the calendar. This article can be viewed here.
A data-aware DateTimePicker component
This data-aware visual control was required to select dates in a database-driven personnal information manager then under development. The component TGtroDBDateTimePicker is a class (derived from TDateTimePicker) provides this capability. The article can be viewed here.
Using ADO instead of the BDE
The development of the PIM referred to above dates back to year 2001. Recently, I wandered if it would not be a good idea to connect to the Paradox database with ADO instead of the BDE. The BDE is a mature but deprecated technology.
ADO is Microsoft's data access layer for relational databases, spreadsheets, email, documents, graphics and the Internet. The dbGO (D2009) components available in the component palette encapsulate the functionality of ADO objects and make them available in Delphi. Most of the ADO connection and dataset components are analogous to one of the BDE.
In a test program, I connected the program with ADO and used an appropriate connection string for the TADOTable that I used. I used a TDBGrid component to view the content of each table of the database. Surprise! All the fields of all the table were on the DBGrid display save for the ftFmtMemo fields. They did not show at all.
I raised the question on the Embarcadero Developer's Network and I received two answers: one from Dmitry Arefiev stating that a BDE connection to a Paradox database was best whereas Bill Todd replied and I quote:
"Paradox formatted memo fields use a proprietary encoding scheme that has never been published AFAIK. They do not use standard RTF. Only the BDE supports them. Since the BDE was abandoned in 2002 your best solution for the long term is is move to another database such as Firebird or SQLite. However, there is no way that I know of to convert the formatted memo fields to another database and preserve the formatting." (bold and italic formatting added by the author)
As a result, I gave up the idea.
Development of other components
Specializing the ShellTreeView component for a backup program
I am in the process of developing a file backup program and I needed a component to allow the user to select files for the backup.. The component is based on the ShellTreeView component. Two capabilities have been added to this component: checkboxes next to each visible node and a procedure to list all the files belonging to the checked directory (and its subfolders). Come and see how I have done it.
Using the Windows Shell to enumerate files
In the course of devising the component described above, the objective of which is to enumerate the files contained in folders of the Windows Shell, two methods were considered for this enumeration: the Find and the Shell method. The Find method is documented in the above article whereas the Shell method is described here. This method was not used as it was too slow.
Two components to play/record sound with a voice modem
The initial idea was simple: develop a mail box system for home with which I could get CallerID notification, play a greeting message and have callers leave messages on my home telephone. This article covers a very simple way to play and record sound to and from a voice modem wave device.
A backup and restore component
This article shows how to develop a backup component using Delphi 2009 and the zlib compression algorithm. First, some theory of data compression is reviewed and, second, a compression component is presented and developed. A test program is provided with the component.