Roger Lascelles' Site

 

 

Sample Delphi Projects with Source

 

Generic Windows API Programs

These programs do not use the Delphi Visual Component Library. Instead the programs directly use the Windows operating system to provide elements like edit controls, buttons, text etc.

The advantage of API projects is that a whole application of 15K to 100K can still perform useful work. The disadvantage of API projects is that the programmer must endure a steep learning curve to master the Windows API functions and must spend a lot more work to build each program. For a program with plenty of visual featuress, it takes roughly 10 times longer to build an API program.

API programs are excellent for small programs like installers and resident programs which should be sparing of resources. API programs are a poor choice for most office applications which require a sophisticated user interface.

If you want to write API programs, you must own a good textbook. The classic text is Programming Windows 95 by Charles Petzold, Microsoft Press. Like most API texts, the book assumes you are using the C language. However, it is not hard to find the equivalent Pascal declarations in the windows.pas file included in your Delphi installation. If you persevere and master the API, you will be able to understand the Delphi VCL source code and Windows itself, which puts you on the path to becoming an expert programmer.

Each demo project uses a dialog : a window containing controls and defined by a resource script. The dialog is reasonably easy to define using a resource editor like Borland's Resource Workshop or the Microsoft Resource Editor. A resource editor lets you visually build each dialog, then save the "receipe" for the dialog as a resource script. Delphi includes a resource compiler which can turn your resource script into a .res file. Use the {$R} Delphi compiler directive to include .res files into your project.

 

Project uses only a dialog

Project shows a main window and pops up a dialog on top of the window

Project uses a dialog as its main window

 

Enumerate Windows Present on the System

This simple program shows how to use the API function EnumerateWindows(). It displays a list of Windows and Process IDs. You can select a Window and switch focus to that Window or dump that Window as a bitmap to file.

ShowApps

 

Use the Windows "Browse For Folder" dialog

The undocumented Browse For Folder function is available on Win9x and NT4 and later. The dialog lets a user choose a folder, even across a network. Includes a function which you can call for easy use of the dialog. Sample app included.

BrowseForFolder

 

Display BDE Information

Program shows BDE information. Used as part of the system info menu for a database app, assisting with phone support.

BDE Info

 

Display Version Info

Program displays the version info embedded in EXE and DLL files. Includes a function which you can call for easy reading of version info.

Version Info

 

CSV Component Reads & Writes CSV Files Just Like a TTable

This component has been used in scores of projects. Opens CSV files and reads them. Or, it will create a new CSV file and allow you to write to it. Like a TTable, it has Open, Close, Next methods and the EOF property.

CSV Component

 

Freeform Reporting Classes

The fastest way to add printing to an application. Simply pass your heading, paragraph, and grid data to the printing engine to write your document. Invisibly handles numbered pages, page tiling, text wrapping, formatting, headers, fonts and line spacing. A single print class gives your application 5 different report formats, because the identical print operation can output to the Windows printer or to Text, CSV, RTF and HTML files.

Optionally, you can add the user interface which lets customers format reports to their own requirements. Font size / italic / bold / underline, line spacing, tiling etc can be set for each report element. User settings can be saved in an Ini file so your customer individually tailors each report type with no code needed.

Although the report has a generic appearance, this is an excellent way to print text and-or tables when the length of the report is indeterminate or paper size must be flexible. Page tiling means wide tables are printed across multiple pages.

V 1.01
- TPrintRreport stores last written foldeer in IniFile.
- RTF tabular data now has alignment withhin cells and bolded column headings.

Includes demo application

Freeform Reporting

 

Roger Lascelles Home Page

Hosted by www.Geocities.ws

1