Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:

(Ebook - Pdf) Kick Ass Delphi Programming

.pdf
Скачиваний:
284
Добавлен:
17.08.2013
Размер:
5.02 Mб
Скачать

To access the contents, click the chapter and section titles.

Kick Ass Delphi Programming

Go!

Keyword

(Publisher: The Coriolis Group)

Author(s): Don Taylor, Jim Mischel, John Penman, Terence Goggin

ISBN: 1576100448

Publication Date: 09/01/96

Search this book:

Go!

Introduction

----------- What's on the CD-ROM

About the Authors

CHAPTER 1—32-Bit Console Applications

Console Applications

Filters

Console Applications and Delphi

Hello, Delphi

Saving a Program Template

Console Input and Output

Filter Programs in Delphi

Your Basic Filter Program

Processing the Command Line

Command Line Options

A Reusable Command Line Parser

Testing the CmdLine Unit

A Note on Program Structure

Reading and Writing Files

Using the Filter Template

A Critique

CHAPTER 2—Drag and Drop the Windows Way

Drag and Drop the Windows Way

What to Do with Windows Code?

Responding to Windows Messages

Custom Controls

Subclassing

Defining the Interface

Implementing the New Interface

Subclassing Revisited

The Elusive Drag and Drop Server

CHAPTER 3—32-Bit Delphi DLLs—When, Why,

How

What’s a DLL and Why Do I Want One?

How Do I Do It?

Building a DLL

Calling DLL Functions

Linking DLLs at Runtime

Where Windows Looks for DLLs

DLLs: Disadvantages and Cautions

Creating Forms in DLLs

Coding for Flexibility

Creating the Text Editor

Sharing Memory Between Applications

The DLLProc Variable

Movin On!

CHAPTER 4—The Delphi Winsock Component

What Is Winsock?

Dissecting WSock

Running the Resolver Application

What’s My Name?

What’s the Address?

What’s Your Name?

Getting the Name Asynchronously

Who’s at This Address?

Canceling a WSAAsync Operation

Resolving Ports and Services

Finding the Service

Resolving Protocols

To Block or Not

CHAPTER 5—Shopper: An FTP Client Component

Are You Being Served?

The Shopper Component

Displaying Output

Putting Shopper to Work

Odds and Ends

CHAPTER 6—3D Fractal Landscapes

Bending and Dividing

The Shared Edges Problem

A Triangular Array

Bending

Draw, Then Display

Generating and Displaying the Landscape

The Project() Routine

Outline Mode

Filled Mode

Rendered Mode

Create Your Own Worlds

CHAPTER 7—Problems with Persistents, and Other Advice

Reading to Write?

Reasonable Workarounds

A Little Perspective

Using RDTSC for Pentium Benchmarking

Drag-and-Drop Rectangles for a Delphi Listbox

Making String Collections More List-Like

Letting Delphi Applications Set Up Themselves

Using INHERITED with Redeclared Properties in Delphi Taking Snapshots of the Screen with Delphi

Delphi RadioGroup Buttons You Can Disable

CHAPTER 8—Animated Screen Savers in Delphi

Secrets of the Main Form

Adapting to the Environment and the User

Idle Work

Animation

Callback Functions

Configuration

A Color ComboBox

The Project File

CHAPTER 9—The Shadowy Math Unit

Three Good Reasons to Use the Math Unit

Dynamic Data and Static Declarations

Creating TDBStatistics

Defining the Component’s Tasks

Getting Access to the Data

Storing Data Locally

Extracting data

Making the Data Available

Test Driving the DBStatistics Component

Bugs in the Math Unit

Poly: The Function That Got Away

Filling the Pascal Power Gap

Math Unit Function Summary

Trigonometric Functions and Procedures

Arithmetic Functions and Procedures

Financial Functions and Procedures

Statistical Functions and Procedures

CHAPTER 10—Dynamic User Interfaces

An Example “UI-It-Yourself” Application

Building-in a “Delphi” for Your Users

Moving Controls

Re-sizing Controls

Responding to the Popup Menu

Abandoning Changes

Changing the Tab Order at Runtime

Changing Other Properties

Changing Control Fonts at Runtime

Changing Properties in an Object Inspector

Saving Component Changes Made at Runtime

Snag: Components with Components as Properties Alternate Paths to a Stream

Toward More Flexible User Interfaces

CHAPTER 11—Hierarchical Data in Relational

Databases

One-to-Many Hierarchies

Simple Recursive Hierarchical Data

Class TQuery as a Detail DataSet

Nested Recursive Hierarchical Data

Hierarchy Navigation

Displaying the Data

Using the Data

Finding Rows

Using Hierarchical Data in Queries

Referential Integrity and Circular References

Using SQL

Solving the Problem of Arbitrary Nesting

Using Stored Procedures

The TreeData Components

TreeData Property Management

TreeData Component Internals

TreeDataComboBox

TreeDataListBox

TreeDataOutline and TreeDataUpdate

End Note

CHAPTER 12—The Oracle Vanishes

An Evening at the Office

An Urgent Plea

The Disappearance

At the “Sleeveless Arms”

Doing the Old ‘Drag/Drop’

Kind of a Drag

Dropping the Payload

Packing Paradox and dBASE Tables

The Packing Demo

Back at Ace’s Office

Different Strokes

Playing a .WAV File

Some Sound Advice

A Disconcerting Discovery

CHAPTER 13—A Revelation in the Mud

Resizing Forms

Making a Splash

Ace Gets an Answer

Making Data Global to an Application

An Exciting Discovery!

Taking Win95 for a Walk

Just Say “Cheese”

The WalkStuf Unit

Stepping Out

CHAPTER 14—The Oracle Returns

Sharing Event Handlers

Taking a First Run

Down a Crooked Path

Just One More Thing…

Using Memory Files

Before the Beginning

Preventing Program Execution

Floating Toolbars

Ace Gets the Goods

Epilogue

CHAPTER 15—An Age-Old Problem

Facing the Situation

Specifying the Problem

Designing the DLL

Startup Code

Signals from a Semaphore

Shutdown Code

Examining the DLL Routines

Creating the Sender Component

Creating the Receiver Component

Subclassing the Owner Window

Other Interesting Stuff

Creating a Receiver Demo

Creating a Sender Demo

A Rude Awakening

Index

Products | Contact Us | About Us | Privacy | Ad Info | Home

Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc.

All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited. Read EarthWeb's privacy statement.

To access the contents, click the chapter and section titles.

Kick Ass Delphi Programming

Go!

Keyword

(Publisher: The Coriolis Group)

Author(s): Don Taylor, Jim Mischel, John Penman, Terence Goggin

ISBN: 1576100448

Publication Date: 09/01/96

Search this book:

Go!

-----------

Introduction

Way, way back in the mid-to-late 80s, the Pascal programming language was the target of a systematic slander attack by C and (later) C++ partisans, who got the ear of the media and said “Pascal is a kiddie language” so often that the media chowderheads took their word for it.

Most of these people knew nothing of Pascal, or perhaps took a college-level course in it from other chowderheads who considered drop-in code portability the sole virtue in all computer science. So the Pascal taught in schools is typically castrated Pascal that can’t do much more than iterate arrays and talk to the command line. C is no more portable than Pascal, but…c’mon, already: The whole issue is ridiculous because portability is and always was a myth. Quick, you C gurus: Write me a single, library-free C program that will locate the text cursor to 0,0 on any C implementation on any platform. See what I mean? No es posible. Arguing about portability is about as useful as discussing where UFOs come from.

A better measure of a language is how much it can accomplish—and how productive it makes the programmer. There was a time when C++ had a slight edge in power. But then Borland got hold of Pascal and added everything of value that C++ had. The “kiddie language” now had typecasts, pointers, objects, inline assembly, special hooks for Windows, the “woiks.” Those of us who used Pascal immediately leapt on the additional features, and before you knew it there were hordes of highly sophisticated applications everywhere you looked, all written in Borland Pascal.

Sometimes you can’t win. The C++ guys snorted and looked the other way, and the media chowderheads still call Pascal a kiddie language. It got so bad that a lot of commercial software vendors were afraid to admit that their applications were written in Pascal.

So Borland did the right thing. They dumped the P-word. Delphi, when it happened, stood on its own merits. It wasn’t a language. It was a lean, mean, program-building machine. The sheer depth of the Delphi product is astonishing—you can wander for months in the help system and not see the same entry twice.

The potential in all that power was slow to be understood. We’re only now starting to appreciate what you can do in Delphi. This book is meant to be a compendium of truly advanced Delphi techniques—stuff you can’t do in a kiddie language, and stuff that isn’t a cakewalk even in C++. It’s proof, now and for all time, that Delphi goes all the way down to the metal and back in creating professional applications for Windows as good as anything you can create in any language you can name.

Having lost the P-word to kick around, the media chowderheads have begun repeating a new mantra, that anything you can do in Delphi takes five or six times as long in C++. It’s gotten so bad I’ve heard tell of MIS shops where managers are forbidding the use of C++ and replacing it with Delphi and Visual Basic.

Hey, pass the chowder. There may yet be justice.

Jeff Duntemann KG7JF

Scottsdale, Arizona

July, 1996

Products | Contact Us | About Us | Privacy | Ad Info | Home

Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc.

All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited. Read EarthWeb's privacy statement.

To access the contents, click the chapter and section titles.

Kick Ass Delphi Programming

Go!

Keyword

(Publisher: The Coriolis Group)

Author(s): Don Taylor, Jim Mischel, John Penman, Terence Goggin

ISBN: 1576100448

Publication Date: 09/01/96

Search this book:

Go!

-----------

What’s on the CD-ROM

The CD-ROM in this book exists primarily to carry the code listings for the projects developed in the book. However, there’s so much room on a CD-ROM that we’ve added a lot of additional material that we felt might be useful to you as a Delphi programmer.

All of the projects have been tested on a 32-bit Windows operating system, either Windows 95 or Windows NT. Some will also work under Windows 3.x, but some may not. When a choice had to be made, we chose the 32-bit side of things.

If you have trouble getting one of the project executables to run, recompile it under Delphi 2. (Not all projects will compile under Delphi 1.) Make sure you have database aliases set up for projects that require them.

Listing File Updates

Every so often a source code file may have to be updated. It isn’t always a matter of bugs. Sometimes, an author will send us an update that improves the code or adds new features, even if no bugs are involved. So check now and then! Typically, we’ll provide an updated ZIP for the project in question rather than an update of the entire CD-ROM.

Book disk update files are available most easily through ftp, from:

ftp://ftp.coriolis.com/pub/bookdisk

There will be subdirectories for many books there. Look for a subdirectory name corresponding to KickAss Delphi. That’s where the update files will be.

The CD-ROM Directory Structure