(Ebook - Pdf) Kick Ass Delphi Programming
.pdfinterface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, WalkStuf;
type
TForm1 = class(TForm) ExitBtn: TButton; Label1: TLabel;
procedure ExitBtnClick(Sender: TObject); private
{Private declarations } public
{Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.ExitBtnClick(Sender: TObject); begin
Close;
end;
end.
Listing 14.6 No Run Demo project file
{———————————————————————————————————————————————————}
{ |
The "No Run" Demo |
} |
{ |
NORUN.DPR : Project File |
} |
{ |
By Ace Breakpoint, N.T.P. |
} |
{ |
Assisted by Don Taylor |
} |
{ |
|
} |
{ An application that demonstrates how to prevent |
} |
|
{ execution if Delphi 2.0 isn't running. |
} |
|
{ |
|
} |
{ Written for *Kick-Ass Delphi Programming* |
} |
|
{ Copyright (c) 1996 The Coriolis Group, Inc. |
} |
|
{ |
Last Updated 4/2/96 |
} |
{———————————————————————————————————————————————————}
program NoRun;
uses
Forms, Dialogs,
NRunMain in 'NRunMain.pas' {Form1}, WalkStuf in 'WalkStuf.pas';
{$R *.RES}
begin Application.Initialize;
{If there isn't a copy of Delphi 2.0 running, display an error message and kill the program. Otherwise, let this application
execute. }
if ModuleSysInstCount('DELPHI32.EXE') < 1
then MessageDlg('Delphi 2.0 must be running to execute this program', mtError, [mbOK], 0)
else begin
Application.CreateForm(TForm1, Form1); Application.Run;
end;
end.
The goal is to kill the application without the user even seeing the main form. So once again, code is added to the project file to accomplish the task. This time the ModuleSysInstCount function from the WalkStuf unit is used to make sure at least once instance of Delphi 2.x (DELPHI32.EXE) is running. If so, the program continues. If not, an error message is displayed.
One note: Because WalkStuf relies on ToolHelp32, this technique will only work with programs running under Win95.
End of entry, April 2.
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.
Shift: TShiftState; X, Y: Integer); begin
DraggingPanel := False; end;
procedure TForm1.ToolbarMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
var
DeltaX : Integer;
DeltaY : Integer; SafetyMargin : Integer; begin
if DraggingPanel then with Toolbar do
begin
DeltaX := X - DragStartX;
DeltaY := Y - DragStartY; if GridSize > MarginSize
then SafetyMargin := GridSize else SafetyMargin := MarginSize;
if (abs(DeltaX) > GridSize - 1) then if DeltaX > 0
then begin
if (ControlPanel.Left - Left) > SafetyMargin then Left := Left + DeltaX
else Left := ControlPanel.Left - SafetyMargin; end
else begin
if (Left + Width) > SafetyMargin then Left := Left + DeltaX
else Left := SafetyMargin - Width; end;
if (abs(DeltaY) > GridSize - 1) then if DeltaY > 0
then begin
if (Form1.ClientHeight - Top) > SafetyMargin then Top := Top + DeltaY
else Top := Form1.ClientHeight - SafetyMargin; end
else begin
if Top + Height > SafetyMargin then Top := Top + DeltaY
else Top := SafetyMargin - Height; end;
end; { with } end;
procedure TForm1.FormCreate(Sender: TObject); begin
GranRBGroup.ItemIndex := 0;
MarginRBGroup.ItemIndex :=0;
OrientRBGroup.ItemIndex := 0; end;
procedure TForm1.GranRBGroupClick(Sender: TObject); begin
case GranRBGroup.ItemIndex of 0 : GridSize := 1;
1 : GridSize := 10;
2 : GridSize := 20; end; { case }
end;
procedure TForm1.MarginRBGroupClick(Sender: TObject); begin
case MarginRBGroup.ItemIndex of 0 : MarginSize := 5;
1 : MarginSize := 10;
2 : MarginSize := 15; end; { case }
end;
procedure TForm1.ExitSBClick(Sender: TObject); begin
Close;
end;
procedure TForm1.OrientRBGroupClick(Sender: TObject); begin
case OrientRBGroup.ItemIndex of 0 : OrientToolBar(otHorizontal); 1 : OrientToolBar(otVertical); end; { case }
end;
procedure TForm1.OrientToolbar(Direction : TDirection); begin
with Toolbar do begin
Left := 20;
Top := 20;
case Direction of otHorizontal : begin
Width := (4 * ExitSB.Width) + 20; Height := ExitSB.Height + 10; ExitSB.Top := 6;
ZoomInSB.Top := 6;
ZoomOutSB.Top := 6; LEDSB.Top := 6;
ExitSB.Left := 11;
ZoomInSB.Left := ExitSB.Left + ExitSB.Width; ZoomOutSB.Left := ZoomInSB.Left + ZoomInSB.Width; LEDSB.Left := ZoomOutSB.Left + ZoomOutSB.Width; end;
otVertical : begin
Width := ExitSB.Width + 10;
Height := (4 * ExitSB.Height) + 20; ExitSB.Left := 6;
ZoomInSB.Left := 6;
ZoomOutSB.Left := 6;
LEDSB.Left := 6;
ExitSB.Top := 11;
ZoomInSB.Top := ExitSB.Top + ExitSB.Height; ZoomOutSB.Top := ZoomInSB.Top + ZoomInSB.Height; LEDSB.Top := ZoomOutSB.Top + ZoomOutSB.Height; end;
end; { case } end; { with }
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 14.5 Floating a Delphi toolbar.
End of entry, April 3.
Ace Gets the Goods
As the Delphi Avenger glanced up from the Casebook, it was obvious that something had gone awry. The room had slowly filled with a thick carpet of fog that now hugged the floor like a Basset Hound on its day off. A brilliant white light emanated from the cloud, illuminating everything in the room with an eerie cast. The Avenger drew in a quick breath of air, a breath that stung the nostrils with the numbing cold of carbon dioxide. Something was very, very wrong. Then suddenly, from across the room there came a violent explosion, as the rickety door blew off its hinges and crashed inward to the floor. In the open doorway, illuminated from behind by the neon bug zapper in the hallway, stood a triumphant Ace Breakpoint!
* * *
The odor that permeated the seedy little apartment was unmistakable, a veritable snack food smorgasbord. I crossed the room powerfully, knowing I had not only solved this case, but that I had wrested complete control of the story from The Third Person. Three giant steps, and I had closed the gap between myself and the pathetic creature that cowered against the opposite wall—the now-defeated entity that once dared to call itself the Delphi Avenger.
“Breakpoint!” Bohacker hissed, dropping my Casebook on the floor. “How did you know?”
“Easy,” I snarled. “From the very beginning of this case, I knew something was amiss. It just took me a while to realize the “miss” was you… Miss Bohacker!” I shouted, as I tore the false mustache from her upper lip.
“Cursors!” she spat through clenched teeth. She quickly scrutinized me from head to toe, then back again, like a wild animal trapped in a corner. The look of defeat was gone, and in its place was a twisted smile that quite unnerved me. “Yes, it’s me,” she grinned. “Melvin Bohacker’s evil twin sister, Mevlyn.”
A chill ran down my spine. Suddenly I felt like I was playing a scene in a very bad “B” movie. How did I get myself into these situations? I just shook my head.
“Sure,” she said disdainfully. “Be Mr. High and Mighty. But imagine for just one minute what your life would be like, spending every day of your childhood following in Melvin Bohacker’s footsteps.”
And following his nutritional guidelines, as well, I mused, noticing the mass of Twinkie and HoHo wrappers strewn all over the apartment. But strangely, I did feel a twinge of empathy. I encouraged her to resume her confession.
“He was exactly eight minutes older,” she said. “So he got all the good stuff. I got whatever was left. And when it came time for college, there was only enough money to send one of us. So of course it was Melvin who went off to
school, while I stayed home. I probably would have starved to death, if I hadn’t started the designer clothes business.”
“Wait a second,” I said. “You mean you’re the owner of Bohacker Industries? The people who make Bohacker Blues jeans?”
“You hadn’t made the connection?” she asked wryly. “Then you’re also not aware that my company produces the Purely Prophet designer line for your little friend, Muffy Katz.”
“Why, you must be worth a bundle!” I exclaimed.
“Oh, yes—I have a net worth of several million. Which is fine, I suppose—if you’re merely interested in money. But Melvin is the one who got all the love. He got the accolades. He’s the one who got the college education. And he’s the one who went on to become one of the most esteemed and revered members of the entire scientific community—a Windows 95 programmer.”
Her eyes burned with hatred. “Since childhood, I’ve been a dysfunctional, codependent victim, and I’ve sworn I would get even with Melvin, no matter how long it took. Then a few weeks ago, it became obvious,” she said, staring dreamily off into the distance. “I would steal your Casebook, and armed with the secrets it contains, I would become the best Windows programmer in the world—better even than Melvin. And certainly better than you.”
She stood silently for several seconds, then turned back to continue the confession. “At the same time,” she said thoughtfully, “I could frame Melvin for the robbery. I called him earlier today, to torment him and then lure him out of town tonight, so everyone would think he had taken it on the lam. It was a perfect plan. But something went wrong. Evidently I underestimated you.”
“You forgot I used to be a detective,” I replied. “And you left a trail of clues so transparent that even an MIS manager from Bayport could have followed them.”
“Like the glove?” she asked. “Losing it was an accident. I thought of trying to get it back. But even so, it should have pointed to Melvin, not me.”
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.