Delphi Tip: Updating "Same-type" Components by Scott Wehrly
This month's Delphi tip is an oldie, but a goodie. We've received a few questions on this topic in the message boards lately so we thought we would take this space this month to show you how to update a large number of components having the same type and similar characteristics.
If you have a large Form with many components on it, and you wish to assign all of the components of a certain type the same property, you may find that you have to code the same assignment line for every component on the form that meets your need.
There is a way to streamline this process using the Components array on the Form. This is a Delphi collection object (available with any descendant of TComponent), that lists all of the components contained on the Form.
Here is a code example that demonstrates how you could disable all of the buttons on a Form that are TButton components:
procedure TForm1.DisableAllButtons;
var
x : integer;
begin
for x := 0 to (Form1.ComponentCount - 1) do
begin
if (Form1.Components[x] is TButton) then
TButton(Form1.Components[x]).Enabled := False;
end;
end;
In this code example, all of the labels on the form will be assigned the same caption. The labels all have the same characteristic - that is, their object names are all "Label##" where "##" is the numeric suffix automatically assigned by the component editor when the TLabel is dropped on the Form:
pprocedure TForm1.SetAllCaptions;
var
x : integer;
begin
for x := 0 to (Form1.ComponentCount - 1) do
begin
if (Form1.Components[x] is TLabel) then
if (Copy(TLabel(Form1.Components[x]).Name,1,5) = 'Label') then
TLabel(Form1.Components[x]).Caption := 'Hi!';
end;
end;
This month I'm going to cover the ASP.NET file extensions. Where appropriate, I've also included a mention of the ASP equivalent.
ASAX - The Global.asax file, also known as the ASP.NET application file, is an optional file that contains code for responding to application-level events raised by ASP.NET or by HttpModules The ISAPI uses the System.Web.HttpForbiddenHandler to prevent direct requests to this file. This is the ASP.NET equivalent of the global.asa file
ASCX - Used for custom User Controls. When a page is executed with an
ASCX reference, ASP.NET uses this extension to process the request. The ISAPI uses the System.Web.HttpForbiddenHandler to prevent direct requests to this file.
ASHX - Custom HttpHandler implemented as a file rather than a separate class.
ASMX - Files with these extensions contain the WebService processing directive and serves as the addressable entry point for XML Web services.
ASPX - Handles requests for ASP.NET requests. This is the ASP.NET equivalent to the .ASP extension.
AXD - Used to handle Trace requests (for debugging purposes).
REM - Used to handle .NET remoting.
SOAP - Also used in remoting and handling soap requests.
config, .cs, .licx, .vb, .csproj, .vbproj, .vsdisco, .webinfo, .resx, resources are all source code files. The ISAPI uses the System.Web.HttpForbiddenHandler to prevent direct requests to these files.
For additional ASP.Net-related information, please read ourASP.NET FAQ.
OO/UML: Aggregation versus Composition by Mike Prestwood
I've been getting a lot of questions about the distinction between aggregation and composition lately. Both deal with part-of relationships and are extremely important concepts to understand.
Let's start with a few defitions from the UML 1.4 glossary:
Aggregation - A special form of association that specifies a whole-part relationship between the aggregate (whole) and a component part.
Composition - A form of aggregation which requires that a part instance be included in at most one composite at a time, and that the composite object is responsible for the creation and destruction of the parts.
Aggregation ("has a" relationship) In an aggregation relationship, the part may be independent of the whole but the whole requires the part. An aggregation relationship is indicated in the UML with an unfilled diamond and a line as follows:
Composition ("uses a" relationship) A composition relationship, also known as a composite aggregation, is a “stronger” form of aggregation where the part is created and destroyed with the whole. A composition relationship is indicated in the UML with a filled diamond and a line as follows:
Notice that with both types of aggregation, the diamond is located on the side of the line pointing to the aggregate class which represents the "whole" in an aggregation (whole-part) relationship.
Shareable Aggregation A shareable aggregation denotes a weak ownership. That is, the part may be included in several aggregate "owner" classes. For example, a part class such as a spark plug may have several ownership or aggregate classes. For example, a car, motorcycle, boat, and lawn mower may use the same type of spark plug. This, of course, is a desirable design in both engines and software.
Here is a psuedo code example of both:
Aggregation Example ("has a"):
class SparkPlug {
//...
}
class Engine {
private
SparkPlug1 = new SparkPlug();
SparkPlug2 = new SparkPlug();
//...
}
Composition Example ("uses a"):
class Gas {
//...
}
class Engine {
public
Start(SomeGas : Gas);
//...
}
A Data Normalization Primer - Part 2 By Cliff Suttle
Is Your Data Normal? Hi and welcome back to Cliff’s Corner. Last month we started talking about data normalization. If you missed that article, or would like to reread it before continuing, click here (put link here). The information presented here is a continuation of the last article. In today’s column, we will continue our quest for perfect data.
Paradox: Using Paradox Libraries to Store Temporary Information by Juan Soto
Abstract: In this second and final article on Paradox libraries, we will discuss using libraries to store temporary information that can be used by any Paradox form, script or even other libraries. We will also discuss other methods for storing temporary information and provide suggestions as to when each should be used.
There are times when you will need to store temporary information for use by scripts or forms in your application. One example might be storing the current user's name, password or title across multiple forms and/or scripts. How can two or more forms share information when each is a world onto itself?
You may know Xavier Pacheco, co-author of the Delphi Developer's Guide, versions 1-6. His company, Xapware Technologies, Inc. is about to release a new software life cycle management tool. This month, Xapware Technologies is releasing a new software project management system, called Active! Focus. Active! Focus is a life cycle management tool that is designed to help all developers and team members from the smallest basement shop to the largest consulting environments, offering simplicity, sophisticated features, and extreme affordability all in one package.
Active! Focus accelerates and simplifies the software design process across an entire team. Managing team resources, requirements analysis, change response, and risk assessment is easily handled in its common-sense user interface. Active! Focus promotes team efficiency :advanced reporting enables at-a-glance checking of project health, while straightforward risk mitigation assists in dealing with project hazards. Expert online advisor content helps team members grasp tasks and requirements. Active! Focus enables teams to manage their time and resources effectively, driving development success! Additional information is available at www.xapware.com.
"Our goal is to enable the entire development team to take advantage of cutting-edge project management features without spending a month learning the system and a bucket of money to buy it," said Thomas Theobald, marketing manager of Xapware Technologies. "We know teams need these tools - we wanted to make sure they could obtain and begin using Active! Focus easily."
Xapware is offering a 10% discount off its already-reduced introductory pricing for Active! Focus licensing to all existing Prestwood community members until December 31st, 2002.Simply ask for the Prestwood Community Discount to take advantage of this limited-time offer!
Prestwood Request Support Form NewFor our support account customers (formally Gold Support), we have created a new Request Support Form. This new form allows you to more easily request support while giving you better control over working parameters. Call us or use this form to submit a support request. You'll find the new form at:
If you have any open issues you would like help with, use the above form. This includes Borland Delphi (all versions), Paradox, Access, VB, ASP, C++, code reviews, testing, etc.
Thank you for your continued support of Prestwood Software!
NEW MODERATOR: Angel Please welcome Angel as a new moderator of the Delphi areas. Angel will make a great addition to the Delphi moderator team. His contributions have already added to the body of knowledge available here.
Rank Titles! Back by Popular Demand Ranks are back! The more you post, the higher your Starfleet rank. Our rank titles are based on Star Trek's Starfleet Officer Ranks. I know, I know, it's a bit geeky, but what the heck.
Add a Custom Avatar to your Posts You can use a picture of you as a custom Avatar (a graphic representation of you). Send any photo at any resolution to mike_p@prestwood.com and he'll edit and post the image. Clear face shots work best. Our mugs help make this message board more of a community and more personal.
Graemlins There Back! Inline graemlins are back! And, we've added the following extra graemlins just for us developers. Click here to try a few.
Boxhead
Ashamed
Boxed In
Foot In Mouth
Soap Box
Worried
Yikes
Geek
Alert
My Two Cents
Pizza
Coffee
Bug / Defect
Bang Head
Bomb
Think
...and for those that are in the know, these two graemlins were added:
Beard
No Beard
New Features and Fixes!
Jump to New Posts link - Located at the top of each topic - when clicked, it takes users to the posts in that topic that were made after their last visit to the board. Also known as the "blue arrow".
"Topic moved" icon - indicates if a topic was moved rather than closed.
"Report Post" link - allows users to mail the forum moderator and board administrator about a post he or she feels is inappropriate.
New email preference for users - Registered members may mail others using the mail form.
Users can choose whether to see other user avatars or not.
Updated the search feature to use less memory and search more accurately.
Numerous defect fixes...
Wanted - Paradox 9 Power Prg Books! We still have a high demand for my book titled, "Paradox 9 Power Programming" by Mike Prestwood.
We'll pay you...
$24 - New, never used
$20 - Used, no marks
$16 - Used, with marks, but very useable
You must pay for your own shipping to us, so your net profit within the U.S. will be around $15 to $20 (unless you have multiple copies).
Title: Corel Paradox 9 Power Programming Author: Michael A. Prestwood Publisher: Osborne/McGraw-Hill ISBN: 0-07-211936-5 EAN: 9780072119367 UPC: 783254030534
How to proceed Send your book to Attention Mike Prestwood, Prestwood Software, 7525 Auburn Blvd. #8, Citrus Heights, CA 95610. If we can sell the book as new, we'll send you a check for $24 (for each book). Otherwise, we'll send you a check for either $20 or $16 (depending on condition).
If you have questions, please email me at mike_p@prestwood.com or call me at 1-916-726-5675 x205.
Download the Paradox 10 Trial Version If you've never tried Paradox or WordPerfect, now's your chance to try them for FREE.
Here's what's included:
WordPerfect® 10
Quattro® Pro 10
Corel® Presentations™ 10
CorelCENTRAL™ 10
Paradox® 10
The download is hefty (170 MB), but if you have access to a T1 or a fast cable modem you should be able to complete the download in less than a half hour.
Author Contributions Wanted! If you would like to write an article for our monthly newsletter, contact us today. This is a great opportunity to get published. Our monthly newsletter is distributed to over 9,000 software developers world wide.
Michael A. Prestwood President & CEO Prestwood Software 7525 Auburn Blvd #8 Citrus Heights, CA 95610 Office: 1-916-726-5675 x205 Fax: 1-916-726-5676 Email: mike_p@prestwood.com Web: http://www.prestwood.com
Scott Wehrly Programmer Analyst / Delphi Team Leader Borland Certified Professional Prestwood Software swehrly@prestwood.com www.prestwood.com
Juan Soto Senior Project Manager PC Experts 5759 W. Henderson Suite 302 Chicago, IL 60634 Email: juan@pcexperts.com
Evan Egalite egalitev@oit.edu Evan is available for remote work through Prestwood Software at $60 per hour.
About Prestwood Software Prestwood Software, a leader in software development process, specializes in end-to-end software development for the Internet, Windows, Linux, and the Palm OS. This includes custom application development, products, and industry contributions. Prestwood also offers static web site development and page layout, domain registration, hosting, and promotion. Prestwood product offerings include a Writing Suite, PrestoEdit, ATIS, and Workbench.
This newsletter was sent to 9,551 email addresses. Each month (and only once a month) we deliver original content to our opt-in eMagazine subscription list. In addition to keeping up with the latest at Prestwood.com, the focus of our newsletter is on leading and emerging technologies. In addition to delivering original content monthly to your email, we use our monthly giveaway as an incentive for staying on this e-mail list.