Pascal Newsletter #30 - 20-DEC-2001
INDEX
1. A FEW WORDS FROM THE EDITOR
2. DESIGN PATTERNS IN DELPHI
3. FORUMS
4. TIPS & TRICKS
- Downloading Files
- Printing a TStringGrid
- Ellipsis - Displaying a long text in a short space
- Running an application as an NT Service
- Searching for files recursing into subdirectories
5. DELPHI ON THE NET
- Components, Libraries and Utilities
. Shareware/Commercial
. Freeware
- Articles, Tips and Tricks
- Tutorials
- Other Links
________________________________________________________________________
1. A FEW WORDS FROM THE EDITOR
In the tip "Using a login form in our application" published in the
last issue, I used "exit" to terminate the program, but that doesn't
destroy the login form correctly. Thanks Steven for the notice. There
are many ways to correct this, like freeing the login form to terminate
the application instead of using "exit":
if frmLogin.ShowModal <> mrOK then
frmLogin.Free; // Login failed ==> Terminate program
In this issue I'm glad to thank Bradley Baumann for contributing two
articles for this publication. By the way, if you solved a particular
problem, I'd like to invite you to share your code in this newsletter.
If you feel this newsletter is useful, please give us a hand to help us
reach 10,000 subscribers in the next months. One way you can help us is
by sending this link to your friends:
http://www.latiumsoftware.com/en/pascal/delphi-newsletter.php
Another way you can help us is by voting for us in any or some of these
rankings to help give more visibility to our web site and thus increase
the number of subscriptions to this newsletter:
http://www.programmingpages.com/?r=latiumsoftwarecomenpascal
http://top100borland.com/in.php?who=20
Please vote. It's just a few seconds that REALLY make the difference.
Regards,
Ernesto De Spirito
eds2008 @ latiumsoftware.com
________________________________________________________________________
JfControls Library. Multi-language. Multi-appearance. Skins. Privileges.
More than 40 integrated and customizable components. Impressive GUI.
Centralized resources administration. Multiple programming problems
solved. For Delphi 3-2006 & C++ Builder 3-6. http://www.jfactivesoft.com
________________________________________________________________________
2. DESIGN PATTERNS IN DELPHI
Design patterns are said to be the future of OOP. If you are interested
in design patterns in Delphi, here are some links to get you started:
* What are Design Patterns?
http://www.developer.com/design/article.php/3325211
* Introduction to Design Patterns - by Ader Gonzalez
http://tech.groups.yahoo.com/group/JEDI-Patterns/
* Introduction to Design Patterns in Delphi - by James Heyworth, 1996
http://www.obsof.com/delphi_tips/pattern.html
* PatternExplorer
http://www.patternexplorer.com/
* Wrapper Design Pattern
http://www.castle-cadenza.demon.co.uk/wrapper.htm
* Creating a real singleton class in Delphi 5 - by Lasse V. Karlsen
http://community.borland.com/article/0,1410,22576,00.html
These examples (singleton, observer, explorer, etc.) seem nice for the
classroom, but they are too "low level" for my taste. A "higher level"
example that comes to my mind is a treeview/listview pattern, which
can be materialized in a VCL component encapsulating the relationship
between a treeview (any TCustomTreeview descendant) and a listview (any
TCustomListview descendant), like for example drag-and-drop to copy or
move elements. I hope in the future we get to see more of this stuff to
make our lives as programmers easier.
________________________________________________________________________
IBAdmin 3.2 - Complete Interbase SQL tool - A powerful DBA/Development
tool for managing Interbase servers and databases. IBAdmin provides many
capabilities to help with your DB design and management. You can use the
Database Designer to visually design the database structure, the Grant
Manager to manage users, or the SQL Debugger which can be used to debug
stored procedures and triggers. Comfortable SQL code editing with Code-
Insight and Code Completion. >>>>>>>>> http://www.sqlly.com/
________________________________________________________________________
3. FORUMS
Delphi
======
If you know much of Delphi but you are still far from being a guru this
forum is for you. This is the only forum for intermediate-level Delphi
programmers on the Web (Delphi hackers are also welcome :-)). The forum
now has more than 420 members, while it maintains its low traffic:
http://groups.yahoo.com/group/delphi-en
If you want to join the group, the best way is to subscribe from the
web since you can access the special features available at the web site
(a Yahoo! ID is required and you can get yours free by registering as a
Yahoo! user), but if you don't want to register or if you don't have
full Internet access you also can subscribe by email:
http://groups.yahoo.com/group/delphi-en/join
delphi-en-subscribe@yahoogroups.com
Components
==========
This is a forum for searching/recommending software components (VCL and
CLX components, ActiveX objects, DLL libraries, shared objects, etc.),
as well as utilities, tutorials, information, etc. The forum is rather
new and currently has a bit more than 50 members and almost no messages:
http://groups.yahoo.com/group/components
I hope you join the forum to form a larger group. You can subscribe from
the web or --more easily-- by email:
http://tech.groups.yahoo.com/group/components/join
components-subscribe@yahoogroups.com
________________________________________________________________________
4. TIPS & TRICKS
Downloading Files
=================
By Bradley Baumann
http://www.scrapcode.com
bradley@bestweb.net / _@scrapcode.com
Seems as if not too many people know about the great URLMon (included
with Delphi)... Here's a quick example that will download index.html
from "www.scrapcode.com", to "c:\":
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls,
Forms, Dialogs, StdCtrls, URLMon;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
URLDownloadToFile(nil, 'http://www.scrapcode.com/index.php',
'c:\index.html', 0, nil);
end;
end.
Printing a TStringGrid
======================
By Bradley Baumann
http://www.scrapcode.com
bradley@bestweb.net / _@scrapcode.com
Here is a component that I wrote to print out the selected lines (to the
printer) of a TStringGrid, it's called TPrintGrid. I hope enjoy it, if
you have any questions, comments, suggestions - please don't hesitate
to ask me.
------------------
Editor's note: The code of this component is included in the archive
that accompanies this newsletter. I included a little demo application.
Ellipsis - Displaying a long text in a short space
==================================================
Probably you saw in many places that when when the text is too long for
the space assigned to it (for example in the case of long items in a
narrow ListBox), the text is then displayed with ellipsis ('...') at the
end. This is done with the API DrawText or DrawTextEx, using the
constants DT_END_ELLIPSIS or DT_WORD_ELLIPSIS in the format parameter.
For example:
procedure TForm1.PaintBox1Paint(Sender: TObject);
var
DTParams: DrawTextParams;
Rect : TRect;
begin
with DTParams do begin
cbSize := SizeOf(DrawTextParams);
iTabLength := 6;
iLeftMargin := 2;
iRightMargin := 2;
end;
Rect := Paintbox1.ClientRect;
Paintbox1.Canvas.Rectangle(Rect);
DrawTextEx(Paintbox1.Canvas.Handle, PChar(Paintbox1.Hint), -1,
Rect, DT_CENTER + DT_VCENTER + DT_SINGLELINE + DT_END_ELLIPSIS,
@DTParams);
end;
Probably you also saw the use of ellipsis to abbreviate file paths. This
is done with the DT_PATH_ELLIPSIS constant:
DrawTextEx(Paintbox1.Canvas.Handle, PChar(Application.ExeName), -1,
Rect, DT_CENTER + DT_VCENTER + DT_SINGLELINE + DT_PATH_ELLIPSIS,
@DTParams);
Running an application as an NT Service
=======================================
In Windows NT/2000, one option is executing your application with
SRVANY.EXE so it runs as a service, but the application won't benefit
from all the features the OS makes available for services. SRVANY.EXE
is basically for Win 9x service applications that you want to run as
services in NT.
If you want your application to truly be an NT service, you should
design it as such (File menu / New... / New / Service Application).
Here you can find some examples:
http://www.aldyn.ru/demos/
http://delphi.icm.edu.pl/ftp/d50free/svcxmpl.zip
http://delphi.icm.edu.pl/ftp/d40free/servicew.zip
Searching for files recursing into subdirectories
=================================================
The following function will search the directory passed as parameter,
as well as all its subdirectories, searching for files matching the
file specification (like '*.htm?') also passed as parameter. The files
found will be added to a string list passed as the third parameter:
procedure SearchDir(Folder: string; FileSpec: string; List: TStrings);
procedure rSearchDir(Folder: string);
var
SearchRec: TSearchRec;
begin
if FindFirst(Folder + FileSpec, faReadOnly Or faHidden
Or faSysFile Or faArchive, SearchRec) = 0 then
try
repeat
List.Add(Folder + SearchRec.Name);
until FindNext(SearchRec) <> 0;
finally
FindClose(SearchRec);
end;
if FindFirst(folder + '*', faReadOnly Or faHidden Or faSysFile
Or faArchive Or faDirectory, SearchRec) = 0 then
try
repeat
if ((SearchRec.Attr and faDirectory) <> 0)
and (SearchRec.Name <> '.')
and (SearchRec.Name <> '..') then
rSearchDir(Folder + SearchRec.Name + '\');
until FindNext(SearchRec) <> 0;
finally
FindClose(SearchRec);
end;
end;
begin
rSearchDir(IncludeTrailingBackslash(Folder));
end;
Sample call:
SearchDir('C:\Windows', '*.EXE', Listbox1.Items);
________________________________________________________________________
5. DELPHI ON THE NET
By Dave Murray
Components, Libraries and Utilities
===================================
Shareware/Commercial
--------------------
* CoolHints2k version 1.01a
With CoolHints2k you can create Office2000-like dialogs and hint
system. The package contains all necessary controls and can be used
to build ordinal dialogs and other purpose windows. Use Delphi's
designer to build the forms and combine controls from the CoolHints2k
package with any other VCL you have. For Delphi 3-6 and BCB 3-5.
http://www.cooldev.com/cd_products.html#CoolHints2k
* HtmlTools version 1.03b
Package to deal with the HTML code. Currenty contains an HTML parser
that allows to parse HTML code and various HTML tags and an HTML
stripper to work with the HTML document. Native Delphi code. For
Delphi 2-6 and BCB 3-5.
http://www.cooldev.com/cd_products.html#HtmlTools
Considering registering the package? The license of Tips System
includes the HtmlTools package as well and it uses advantages of
HtmlTools: http://www.cooldev.com/cd_products.html#TipsSystem
* PsQRFilters v 2.0 - by Pragnaan Software. Shareware ($79)
WYSIWYG Export Filters for QuickReport! Export to PDF, HTML, RTF,
Excel, Text, JPEG, GIF, BMP and more. An ideal solution for creating
copies of reports for distribution. All report elements are exported
and there are plenty of options to play with!
http://www.pragnaan.com
* PsFRExportFilters v 1.1 - by Pragnaan Software. Shareware ($79)
WYSIWYG Export Filters for FastReport! Export to PDF, HTML, RTF, JPEG,
GIF, BMP and more. An ideal solution for creating copies of reports
for distribution. All report elements are exported and output can be
easily customized even by the end-user!
http://www.pragnaan.com
Freeware
--------
* UniRed 1.10
An Unicode plain text editor that supports many charsets including
16-bit Unicode (little and big endian), UTF-8, Windows ANSI, DOS OEM,
Latin-1, Latin-2, etc. and Cyrillic charsets. Syntax highlighting can
emphasize elements by colors and/or text styles. Supports many
languages including HTML, C/C++, Delphi, Java, etc. Search and
replace by regular expressions. Can co-operate with ISpell, allowing
spell check in any language. Can call external compilers and more.
http://www.esperanto.mv.ru/UniRed/ENG/index.html
* CursorDance - by Neil J. Rubenking
Create 16-color and 256-color cursors and animated cursors with this
easy-to-use utility. Delphi 5 source code included.
http://www.pcmag.com/article/0,2997,s%253D1478%2526a%253D9354,00.asp
* A Component that plots graphs - by Vimil Saju
A TGraph Component.
http://www.delphi3000.com/articles/article_2790.asp
* EldoS Sounds v.1.12 - by Eugene Mayevski
The component for different sound decoders and players. Currently
includes MP3 decoder and player.
http://www.freedownloadscenter.com/Best/eldos-sounds.html
* Regular Expression Library v.2.1.1 - by Edward Diener
A library of components and classes to do search and replace of data
using Regular Expressions. There is full support for using the
library in non-VCL modules as well as VCL components.
http://www.tropicsoft.com/Components/RegularExpression/
* Decosp Components Library v.2.5 - by Decosp
A set of 20+ multipurpose components for Delphi, that allow you to
make your application more attractive and GUI more convenient.
Components include: Enhanced mask edit, Date edit, Tree edit,
Enhanced combo box edit, Tree grid, InterDev style Page controls,
Outbar control and Syntax Memo edit (with Delphi and T-SQL syntax).
http://www.torry.net/authorsmore.php?id=3165
* MPEG Tools
Freeware library of classes for Mpeg player functions.
http://www.dv.co.yu/mpgscript/mpgtools.htm
* PGP Components for Delphi
Directly interface with PGP's SDK libraries versions 6.5.X and 7.X.X.
Functions include: Encode & decode; Create & verify file detached
signatures; Import, export, revoke, delete keys; Key management
functions; Key generation (DH/DSS, RSA); Keyserver functions; etc.
http://home.t-online.de/home/idw.doc/PGPcomp.htm
* JabberCOM 2.4.2.1
COM component which allows developers quick and easy implementation
of a Jabber (XML Instant Messaging) client. JabberCOM encapsulates
all of the socket and XML handling into a single DLL.
http://jabbercom.sourceforge.net/
* ReSource Compression Component v.2.61 - by Victor Kasenda.
BWT (Block Sorting) Compressor, includes Archiver Demo with add/
extract/ delete. Uses Sadakane's Suffix Sort, Structured Arithmetic
Encoder and CRC32. Compression levels similar to PPM, with speeds
closer to LZ. Source included.
http://www.vclcomponents.com/Delphi/Compression__Encryption/
ReSource_Compression_Component-info.html
* Aravil CAB Components v.1.03 - by Ravil Batyrshin.
Consists of 2 native VCL components TSTCabReader & TSTCabWriter.
Easily create CAB archives and then extract files from archives.
The components are wrappers over Microsoft Cabinet.dll, they simplify
your work with archives and add useful capabilities. Source included.
http://www.torry.net/authorsmore.php?id=3386
* XP Menu v.1.506 - by Khaled Shagrouni.
XP Menu is non-visual component that changes the visual aspects of
menus & toolbars to the look and feel of Office XP. No code required,
you do not have to reconstruct menus or toolbars using components
other than those shipped with Delphi. Source included.
http://www.shagrouni.com/english/software/xpmenu.html
Articles, Tips and Tricks
=========================
* Delphi Database Programming Course - by Zarko Gajic
Free online database programming course for beginner Delphi developers
focused on ADO techniques.
http://delphi.about.com/library/weekly/aa010101a.htm
A new chapter has been added in the last two weeks:
Chapter 21 "Using ADO in Delphi 3 and 4 (before AdoExpress)" explains
how to import Active Data Objects (ADO) type-libraries in Delphi 3 and
4 to create a wrapper around components that encapsulate the
functionality of ADO objects, properties and methods.
http://delphi.about.com/library/weekly/aa112701a.htm
* Extending WebSnap: Changing grid layout - by Gabriel Corneanu
Web components designed to combine the power of DataSetAdapter and
AdapterGrid with the layout generated by AdapterFieldGroup and
LayoutGroup.
http://community.borland.com/article/0,1410,28105,00.html
* Exceptional exceptions - by Marcelo Lopez Ruiz
Learn about structured exceptions and some unusual ways to use them.
http://community.borland.com/article/0,1410,27185,00.html
* Checking if an application (window) is not responding? - by T Stutz
http://www.swissdelphicenter.ch/torry/showcode.php?id=910
* How to convert a Bitmap to an Icon? - by Thomas Stutz
http://www.swissdelphicenter.ch/torry/showcode.php?id=913
* Yahoo Instant Messenger protocol - by César Nicolás Peña Núñez
Implementing Yahoo Instant Messenger protocol in Delphi. This article
covers how to login to the server, get buddy list, ignore list and
whether the user has mail. Requires Indy Internet Library or an HTTP
component that you know how to use.
http://www.howtodothings.com/showarticle.asp?article=361
* Header file format of Interbase/Firebird files - by Peter Morris
This simple class will allow you to specify an Interbase / Firebird
database and it will retrive information about the database including
secondary files, page sizes & number of pages for each file and disk
structure number.
http://www.howtodothings.com/showarticle.asp?article=369
* Julian Date - by Peter Morris
How many days since the start of the year.
http://www.howtodothings.com/showarticle.asp?article=374
* Copy files with windows progress - by Peter Morris
How to copy multiple / large files & show the windows progress form.
http://www.howtodothings.com/showarticle.asp?article=383
* Easy XML - by Boris Yankov
How to use TXMLDocument in Delphi 6.
http://www.delphi3000.com/articles/article_2902.asp
* A simple Internet Explorer like autosuggest - by Masoud Kalali
A simple Internet Explorer like autosuggest listbox.
http://www.delphi3000.com/articles/article_2905.asp
* How to Reboot, Shut Down and Log Off Windows - by David Cardeiro
http://www.delphi3000.com/articles/article_2910.asp
* Changing the default printer - by May Dexter
How do I change the default Windows printer?
http://www.delphi3000.com/articles/article_2911.asp
* Undocumented: Delphi VCL Access License - by Erwin Molendijk
The SysUtils.pas unit contains some very interesting routines that
are used by the VCL to check if the correct version of Delphi is
being used to compile the code (eg. Enterprise or Pro).
http://www.delphi3000.com/articles/article_2912.asp
* TICQ OCX Component, Full Source Code - by Ruslan Abu Zant
Full component source code you can use to connect to ICQ servers.
http://www.delphi3000.com/articles/article_2913.asp
* Finding Printers on the network - by Cleverson Gallego
Find the printers for a specific server on the network.
http://www.delphi3000.com/articles/article_2915.asp
* Streaming COM objects as XML - Alessandro Federici
Quick and dirty example of how to read Type Library information and
generate XML files out of a COM object.
http://www.delphi3000.com/articles/article_2916.asp
* How to get the default printer name - by Philippe Randour
You want to access the default printer but you don't know how to get
its name from the system. This article will show you how.
http://community.borland.com/article/0,1410,28000,00.html
* Top 10 list: using XL to speed Delphi development - by Patrick Foley
This article shows creative ways to use Excel to speed coding and
database development.
http://community.borland.com/article/0,1410,28076,00.html
* Domain authentication with WebSnap - by Gokhan Ergul
Network domain authentication component for WebSnap.
http://community.borland.com/article/0,1410,28036,00.html
* WebServices Made Simple in Delphi 6(Part 2) - by Magesh Puvananthiran
Continuation of a previous article that showed how to write a Web
Services Client using a WSDL file. This article shows how to write a
Web Services Server itself in Delphi 6.
http://www.delphi3000.com/articles/article_2884.asp
* Auxiliary TQuery used with run-time queries - by Fernando Martins
Reducing code replication when using auxiliary TQuery objects.
http://www.delphi3000.com/articles/article_2887.asp
* Garbage Collector for Delphi Applications - by Frederico Pissarra
How to implement a garbage collector in Delphi?
http://www.delphi3000.com/articles/article_2888.asp
* Create + Manage dynamic Forms using Class References - by M Hoffmann
How to dynamicaly create and manage different Forms at runtime in a
global manner?
http://www.delphi3000.com/articles/article_2893.asp
* Priority of an applications main thread - by Simon Grossenbacher
How to change the priority of an applications main thread.
http://www.swissdelphicenter.ch/torry/showcode.php?id=904
* How to get the power status? - by Simon Grossenbacher
http://www.swissdelphicenter.ch/torry/showcode.php?id=903
* How to Drag & Drop multiple items within a TListView? - by Peter Kooi
http://www.swissdelphicenter.ch/torry/showcode.php?id=902
* How to change Screen.Cursor without need to restore? - by KK Gian
http://www.swissdelphicenter.ch/torry/showcode.php?id=895
* "The Big Brother" Delphi code toolkit - by Zarko Gajic
Going undercover: hiding from the task list, disabling task-switch,
removing from the TaskBar, disabling shut down...
http://delphi.about.com/library/weekly/aa022701a.htm
* Using ADO in Delphi 3 and 4 (before AdoExpress) - by Zarko Gajic
Chapter 21 of the free Delphi ADO DB Couse for beginners. How to
import Active Data Objects (ADO) type-libraries in Delphi 3 and 4
to create a wrapper around components that encapsulate the
functionality of ADO objects, properties and methods.
http://delphi.about.com/library/weekly/aa121101a.htm
Tutorials
=========
* Learn your way around XML - by Irina Medvinskaya
A simple introduction to XML, when to use it and a glossary of terms.
http://www.techrepublic.com/article.jhtml?id=r00820011213med01.htm
* Writing And Controlling Automation Servers In Delphi - by Brian Long
This tutorial explores how to control Automation servers and how to
write them in Delphi.
http://www.blong.com/Articles/Automation%20In%20Delphi/Automation.htm
* More Automation In Delphi, an ICon UK 2000 paper - by Brian Long
This follows on Writing And Controlling Automation Servers In Delphi.
http://www.blong.com/Conferences/IConUK2000/DelphiMoreAutomation/
More%20Automation%20In%20Delphi.htm
* Another crash course in SQL - by TechRepublic
Shows you how to run a query that pulls information from two tables
that share a common "key" field.
http://www.techrepublic.com/article.jhtml?id=r00320011204jed01.htm
* A TCP/UDP primer - by Francois Piette
Most people don't know which protocol to choose between TCP and UDP
when they begin to work with TCP/IP. And when they have chosen,
they begin to have some problems because it doesn't work as
expected. This primer explains in easy words the pros and cons for
each one in the context of the freeware TWSocket component for
Delphi and C++Builder.
http://www.eurodata.lv/index.php?cat=253
* A crash course in SQL - by TechRepublic
A short introductory to SQL for complete beginners.
http://www.techrepublic.com/article.jhtml?id=r00320010717jed01.htm
* SQLcourse.com
Unique SQL tutorial not only provides easy-to-understand SQL
instructions, but allows you to practice what you learn using online
SQL interpreter. You will receive immediate results after submitting
your SQL commands. You will be able to create your own unique tables
as well as perform selects, inserts, updates, deletes, and drops.
http://www.sqlcourse.com
* Free-Ed.Net
Massive site of free courses and tutorials with subjects including
Delphi, HTML, Javascript, SQL, TCPIP and Windows.
http://free-ed.net
Other Links
===========
* Resources for Software Architects - by Bredemeyer Consulting
Software architecture is getting a lot of attention. Is it just the
silver bullet du jour? This site organizes a variety of resources to
help you deepen & expand your understanding of software architecture
and the role of the architect.
http://www.bredemeyer.com/index.html
* Pascal Gebruikers Groep
The only well-known organization of Dutch-speaking Pascal/Delphi/
Kylix users. 2000+ members. Activities, CDs, Blaise newsletter, etc.
http://www.hcc-pgg.nl
________________________________________________________________________
If you haven't received the full source code examples for this issue,
you can get them from http://www.latiumsoftware.com/en/file.php?id=p30
________________________________________________________________________
This newsletter is provided "AS IS" without warranty of any kind. Its
use implies the acceptance of our licensing terms and disclaimer of
warranty you can read at http://www.latiumsoftware.com/en/legal.php
where you will also find a note about legal trademarks. Articles are
copyright of their respective authors and they are reproduced here with
their permission. You can redistribute this newsletter as long as you do
it in full (including copyright notices), without changes, and gratis.
________________________________________________________________________
Main page: http://www.latiumsoftware.com/en/pascal/delphi-newsletter.php
Group home page: http://groups.yahoo.com/group/pascal-newsletter/
Subscribe/join: pascal-newsletter-subscribe@yahoogroups.com
Unsubscribe/leave: pascal-newsletter-unsubscribe@yahoogroups.com
Problems with your subscription? eds2008 @ latiumsoftware.com
________________________________________________________________________
Latium Software http://www.latiumsoftware.com/en/index.php
Copyright (c) 2001 by Ernesto De Spirito. All rights reserved.
________________________________________________________________________
|