(Ebook - Pdf) Kick Ass Delphi Programming
.pdfthe splash screen is used. } TSplashForm = class(TForm)
CloseBtn: TButton; Image: TImage; DelayTimer: TTimer;
procedure CloseBtnClick(Sender: TObject); procedure Button1Click(Sender: TObject); procedure DelayTimerTimer(Sender: TObject);
private
{Private declarations } public
{Private declarations }
end;
{TSplashDialog is the wrapper that surrounds the TSplashForm.
The form is owned by the TSplashDialog, so it can "automatically" be created, set up, executed and destroyed at any time. The TSplashDialog makes available only those properties used for the splash dialog, then passes them on to the TSplashForm when it
is created. }
TSplashDialog = class(TComponent) private
FAlign : TImageAlign;
FAutoSize : Boolean; FButtonCaption : String; FCaption : String; FDelay : Word; FHasButton : Boolean; FHasDelay : Boolean; FHeight : Word; FPicture : TPicture; FStretch : Boolean; FWidth : Word;
procedure SetCaption(Value : String); procedure SetDelay(Value : Word); procedure SetHasButton(Value : Boolean); procedure SetHasDelay(Value : Boolean); procedure SetHeight(Value : Word); procedure SetPicture(Value : TPicture); procedure SetWidth(Value : Word);
public
constructor Create(AOwner : TComponent); override; destructor Destroy;
function Execute : Boolean; virtual; published
property Align : TImageAlign read FAlign write FAlign; property AutoSize : Boolean read FAutoSize write FAutoSize; property ButtonCaption : String read FButtonCaption
write FButtonCaption; property Caption : String read FCaption write SetCaption; property Delay : Word read FDelay write SetDelay;
property HasButton : Boolean read FHasButton write SetHasButton; property HasDelay : Boolean read FHasDelay write SetHasDelay; property Height : Word read FHeight write SetHeight;
property Picture : TPicture read FPicture write SetPicture; property Stretch : Boolean read FStretch write FStretch;
property Width : Word read FWidth write SetWidth; end;
procedure Register;
implementation
{$R *.DFM}
var
SplashDlg: TSplashDialog;
procedure TSplashDialog.SetCaption(Value : String); begin
if Value <> FCaption then FCaption := Value;
end;
{ Set the value of FHasButton. If the user has specified he wants no button and no delay timer, raise an exception -- without both, the screen has no way to be cleared! }
procedure TSplashDialog.SetHasButton(Value : Boolean); begin
if not Value and not FHasDelay then raise
ESplashConflict.Create('Must have either a button or a delay!') else FHasButton := Value;
end;
{Set the value of FHasDelay, protecting against the anomaly cited above. }
procedure TSplashDialog.SetHasDelay(Value : Boolean); begin
if not Value and not FHasButton then raise
ESplashConflict.Create('Must have either a button or a delay!') else FHasDelay := Value;
end;
procedure TSplashDialog.SetHeight(Value : Word); begin
if (Value <> FHeight) and (Value > 10) then FHeight := Value;
end;
procedure TSplashDialog.SetWidth(Value : Word); begin
if (Value <> FWidth) and (Value > 20) then FWidth := Value;
end;
procedure TSplashDialog.SetDelay(Value : Word); begin
if (Value <> FDelay) and (Value > 0) then FDelay := Value;
end;
begin
Position := poScreenCenter; Caption := FCaption;
Height := FHeight; Width := FWidth;
if FAlign = iaAllAboveButton then begin
if FHasButton then begin
Image.Align := alTop;
Image.Height := ClientHeight - CloseBtn.Height - 15; end
else Image.Align := alClient; end
else Image.Align := TAlign(Ord(FAlign)); Image.AutoSize := FAutoSize; Image.Stretch := FStretch;
if Image.Picture <> nil
then Image.Picture.Assign(FPicture);
if FHasButton then begin
CloseBtn.Caption := FButtonCaption;
CloseBtn.Left := (ClientWidth - CloseBtn.Width) div 2; CloseBtn.Top := ClientHeight - CloseBtn.Height - 10;
end
else CloseBtn.Visible := False;
if FHasDelay then begin
DelayTimer.Interval := FDelay; DelayTimer.Enabled := True;
end;
try ShowModal; finally Free;
end; { try } end; { with }
end;
procedure TSplashForm.CloseBtnClick(Sender: TObject); begin
Close;
end;
procedure Register; begin
RegisterComponents('Ace''s Stuff', [TSplashDialog]); end;
procedure TSplashForm.Button1Click(Sender: TObject); begin
Close;
end;
procedure TSplashForm.DelayTimerTimer(Sender: TObject); begin
Enabled := False; Close;
end;
end.
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.
FIGURE 13.5 The splash screen making a splash at runtime.
End of entry, March 26.
Ace Gets an Answer
“Hello, Helen? Yeah, Baby. Just calling to let you know there’s nothing new. It’s a brick wall. I’ve gone over everything a hundred more times, and I’m right back where I started. No clues whatsoever. I feel absolutely helpless. Some detective I am!...”
“Ace, you know you’re still a good P.I.— one of the best. It just so happens you can’t do this one on your own,” Helen said.
“I suppose you’re right,” he admitted. “I could use a little help.”
“Why don’t you talk to The Author,” Helen suggested. “Remember how he helped you before?”
“Yeah, I suppose you’re right. Guess it’s worth a try. Thanks, Baby. Love you.”
“Love you, too,” she replied.
Ace hung up the phone and grabbed the phone directory. Running his finger down the page, he found the number he was after. He quickly dialed, and the line was as quickly answered.
“Hello, Ace,” said the voice.
“Uh, hello,” Ace replied. “I guess you already know why I’m calling.”
“You’re looking for some answers regarding the theft of your Casebook.”
“Yeah, I’m feeling totally helpless here. I decided to give you a call.”
“I haven’t heard from you in quite some time, Ace,” said the voice. “Not since The Case of the Duplicitous Demo. I gave you some help that night, didn’t I?”
“Oh, yes,” Ace replied. “You reminded me how special I was, and you gave me the courage to keep going. I don’t think I would have made it without your help.”
“I wonder why you never thanked me.”
“Uh, I suppose it was a combination of things,” Ace replied, stalling for time. “Once I had the problem solved, I guess I thought I didn’t need any help from anyone else.” He paused momentarily. “And I didn’t want to bug you. After all, I’m just one of your many characters.”
“One of my favorite characters. I’ve missed hearing from you. Sometimes it
makes me sad when you try to do everything on your own. Remember, you can call on me anytime, day or night. It doesn’t matter how big the problem is—or how small. But as to your question at the moment. You want to know who stole your Casebook.”
“Right. Helen thinks it was Melvin Bohacker and a female accomplice. At first I didn’t think so, but now I’m not so sure. Was it Bohacker who stole the Casebook?”
“There are three possible answers to that question: ‘Yes,’ ‘No,’ and the answer I have for you, ‘Not right now.’”
“But I’ve got to know who took my most valuable possession. I don’t know how I’m going to go on without it. And my reputation with Helen as a P.I. is on the line, as well.”
“Ace, in your case, life is definitely not like a box of chocolates. For you, it’s more like event-driven programming: You see, it’s not only important that an event occurs, it’s equally as important when it occurs. Life is a mystery. And in any mystery, the timing of events is critical. Besides, sometimes you learn more by discovering things than by just being given the answer.”
“So what should I do?” Ace asked plaintively.
“Go to the parking lot and thoroughly search the area near where your car is parked. You’ll find the key that will unlock this whole mystery.”
“Thanks,” Ace replied excitedly. “I won’t forget this.” He was barely able to get the phone back in the cradle before he was out the door.
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.
FIGURE 13.6 A data module at design time.
Listing 13.4 Code for the Data Module Demo
{———————————————————————————————————————————————————}
{ |
Data Module Demo |
} |
{ |
PIZADAT.PAS : Data Module |
} |
{ |
By Ace Breakpoint, N.T.P. |
} |
{ |
Assisted by Don Taylor |
} |
{ |
|
} |
{ This data module contains a simple Table/ |
} |
|
{ Datasource combination that links to a Paradox |
} |
|
{ data table. A calculated field is provided to |
} |
|
{ users of this module. |
} |
|
{ |
|
} |
{ Written for *Kick-Ass Delphi Programming* |
} |
|
{ Copyright (c) 1996 The Coriolis Group, Inc. |
} |
|
{ |
Last Updated 3/27/96 |
} |
{———————————————————————————————————————————————————}
unit PizaDat;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, DB, DBTables;
type
TPizzaData = class(TDataModule) ProductTable: TTable; ProductSource: TDataSource; ProductTableName: TStringField; ProductTablePrice: TCurrencyField; ProductTableCost: TCurrencyField; ProductTablePctProfit: TFloatField;
procedure ProductTableCalcFields(DataSet: TDataSet); private
{Private declarations } public
{Public declarations }
end;
var
PizzaData: TPizzaData;
implementation
{$R *.DFM}
procedure TPizzaData.ProductTableCalcFields(DataSet: TDataSet); begin
ProductTablePctProfit.Value := 100.0 * ((ProductTablePrice.Value - ProductTableCost.Value) /