|
Paradox Table File Recovery
tvDMX TP-Links BYRONref.com book reference database
"The Ambitions of a Restless People"
email: rb@randybeck.com. |
PROGRAMMING NOTES
I put a few items of interest to Delphi programmers here, and will be adding more periodically.
The Versatility of TPanelHere's a tip for relatively new Delphi programmers that may also be worth reviewing for those who've been at it for so long that they just hadn't stopped to look. This will be obvious to a lot of you reading this, in which case you can scroll down. It's something I wish I had paid more thought to when I was first working in Delphi. When creating a form, it's common to grab visual components and manually place them right on the form. That's how most of the lessons and examples show you to do it, and it's usually just fine. But it's not so good if you've got a big form, particularly if you're going to add fields to it later. Get into the habit of using TPanels when you design forms, and pay close attention to which ones Align with the client or the top, bottom, right, or left. (Align is a property in the TPanel component.) Aligning all the panels above, below, and beside each other is the reason I bring this up. You'll want them all interconnected. Then put your controls on the panels. If you do this correctly, you'll be able to resize the form without buttons scrolling out of view. The result is a form that's easier to go back to and add fields. Set the bevels to bvNone when you don't want the separate panels to be noticable, which is in most cases. Don't forget to set each panel's caption to a blank. Panels are essential for resizable forms with a lot of fields. This one uses panels within panels:
Several panels at the bottom remain fixed in place, and many more at the top also remain fixed. The largest area is one big panel with a grid inside it. It has Align set to alClient so that this is the region that changes size when the form is resized or zoomed. For that example panels are more-or-less essential. Of less importance, I also did something like it in my little BDE checker program. It only needed a simple dialog box but it's made with several panels so that I could adjust the size while programming (although the user can't). QuestionBox (see the post below) uses a lot of panels but it differs slightly in that it was designed to allow hiding any of the lower buttons if they aren't used. It didn't matter on that form that the buttons scroll out of view in design time because the height is determined later. This may not seem so important for forms that aren't going to be resized by the user, but you'll be glad anyway when you as a programmer need to modify it later.
--
function QuestionBox()I was hesitant to upload this one because I would think Delphi should already have something like it. They already have several dialog boxes for asking a question or displaying an error message. This function works along those lines. QuestionBox asks a question and lets the user pick from up to five options: function QuestionBox(AQuestion,AResponses: string) : integer;
AQuestion is simply a string with the question you ask:
You can insert line feeds with the ^J character like this:
AResponses is one string holding up to five responses separated by apostrophes (" The responses may also include "&" to indicate hotkeys.
It returns the numbers 1 through 5, based on the option selected,
or 0 if the user cancelled or pressed Esc.
Note: You can have up to five responses. The dialog box's caption is "Question" but it can be modified at the global variable QuestionBoxCaption. The height of the question area can be modified at QuestionBoxPanelHeight. Download QUESUNIT.zip
(2,171 bytes) --
Unit BDEreset;This is for programmers still using the Borland Database Engine and who have encountered the inevitable Vista problems with their Delphi programs.
As you ought to know by now, the BDE defaults to placing its NET DIR
in the root directory (" BDEreset will check the NET DIR location, and move it into the common AppData folder if necessary. I haven't yet concluded that this is the best location, but I'm keeping it there for now. You may revise the source if you think otherwise. Note: My first thought was to use the Windows Temporary folder, but I realized this may cause trouble if the user changes. This unit must be declared at the top of the uses declarations so it will be initialized before other units. It will not work properly if the BDE is initialized first. The NET DIR location is checked (and fixed if necessary) during the unit's initialization process. Once the unit has been added at a suitable position in your project, you don't need to do anything else with it. Download BDEreset.pas
(4,868 bytes) -- Note: I received a note on the About Delphi board that says it can't detect the application directory with limited user permission. I'm caught off guard by this, as I had thought that common AppData would work fine, but it makes sense given that the unit actually creates a new folder under that one. It now uses the folder that the BDE is in. -- July-2-2008
Unit MyInfo;This unit has nine functions to return information about the user's PC. I try to limit this page to items that may be hard to find elsewhere. Although some of this stuff has become easier to find, the first one is not.
In other words, copying files to this location will cause
Windows to tell the user there are files waiting to be burned to the CD.
If you need a way to backup files to a CD, this may be one solution.
AFAIK, this won't work on Windows versions prior to XP Service Pack 2
in which case it will return an empty string.
My experience has been that WindowsRegisteredOwnerName will return a usable value about 75% of the time, and WindowsRegisteredOrganizationName will return a value less than 10% of the time. Business PC's seem to return a value less often than home systems, but your results will probably vary from mine.
They will always have a trailing backslash ("\") even if the registry entry didn't supply one. This allows you to append a filename without worrying about a backslash, like this:
The information is only retrieved from the registry once. It is stored in local variables for subsequent calls to these functions. Download MyInfo.pas
(6,182 bytes) --
function PxBuild()This unit contains a procedure to easily create Paradox tables with optional index files. Here is a sample usage:
Success := PxBuild(Database1.Handle, 'Example1.db',
Each field must be defined by field name and type, followed by
an optional asterisk (" The NewSItem function is also included in this unit. Some programmers may recognize it from the old Turbo Vision days. Download PxBuildr.pas
(7,433 bytes) --
TEncryptionStream = class(TFileStream)The primary benefit of TEncryptionStream is that it may be quickly substituted for a TFileStream, without having to change anything else in your programs. The encryption is not world-class by any means (in fact, it's extremely weak), but it may be your only encryption option when using a third-party tool that works with streams. It will perform a very simple encryption as it reads or writes the data. It's a quick enhancement that keeps most users from prying without major hassles on your part. You'll need to run this stream on your data (a simple demo program included with the .ZIP file may be used for this purpose). Then replace any use of that file on TFileStream with TEncryptionStream. I recommend that programmers who use this should change the value of the global constant DefaultEncryptionCode. And if you want something a little more secure, you can rewrite the Encode and Decode methods. You'll notice that the encryption is performed one byte at a time, and that this severely limits the degree of sophistication that may be possible. But any serious method (like DES) would add more rules to how this stream may be used, and that wasn't my intent. Download Encoders.zip
(1,839 bytes) --
Paradox Table File Recovery...
|