|
 |
|
|
The Zen Masters Manual
For coders.
- Program for you!!! Make the application, as you would use it! Any little annoying bug will bug others surely.
- Avoid using modal windows.
Use normal windows everywhere you can (modal windows is the killer of the windows concept, is for fatal errors and things like that).
You can circumvent the topic with this: Put everything in a TPanel or TGroupBox and:
//* Form1:
Form1.GroupBox1.Enabled := False;
Form2.Show;
//* Then:
//* Form2:
Form1.GroupBox1.Enabled := True;
Close;
The form stays resizeable, responsive, it's just the controls you can't access.
- Make objects/forms that interacts data (eg.: a TListView) resizeable! We don't want the user to browse our 100 items in a 200x200 panel when he is running the screen in 1280x1024. The forms should be resizeable in any ordinary case always!
- Retire your .jpgs! Use the .png format, it's not just sharper and larger, but you have the 32 bit option too! Use .jpgs only where you really need the space.
- Please don't add the company name to the Program Files/Start Menu path. It expands the route to double and how do you expect the user to not only remember your program name but the company/author also!?
- Output understandable error messages! Not information like "IRQL_NOT_LESS_OR_EQUAL" (why dashes and uppercase?). If you're using a dialog, you have at least 640x480 space to write down what you want. I mean the solutions!
- On spelling hogs first check the peoples opinion: GoogleFight - Visually vs. visualy, then you can decide which one you think is nicer.
- Don't add stupid limitations to the program, for example like Windows Tray icon hint max. 64 characters!? Shot higher than what seems reasonable...
- Preserve the users predefined settings. For example the temporary folder, the menu background color. I like the black menu with white text. If you change this in your app, you ruin my settings, I maybe even won't be able to see your menu. You are a guest at the users machine, discipline yourself accordingly.
- Name your components! You spare many of headaches in the future.
- How to word wrap hints in Delphi?
Use the characters "/n/n" where you want word wraps in the hints, and then add this function in FormCreate():
procedure TForm1.FormCreate(Control: TObject);
begin
//* Wordwrap hints
WordwrapHints(Self);
end;
procedure TForm1.WordwrapHints(Control: TWinControl);
var
i: Integer;
HintStr: String;
begin
for i := 0 to Control.ControlCount - 1 do begin
try
HintStr := '';
HintStr := (Control.Controls[i] as TObject).Hint;
if HintStr <> '' then begin
HintStr := AnsiReplaceStr(HintStr, ' /n/n ', #13#10);
(Control.Controls[i] as TObject).Hint := HintStr;
end;
try
if (Control.Controls[i] as TWinControl).ControlCount > 0
then WordwrapHints(TWinControl(Control.Controls[i]));
except
//*
end;
except
//*
end;
end;
end;
- How to make an efficient settings code?
Make a class of TAppSettings with a .Load() and .Save() methode, that you can call from anywhere in your code which can be easily extended for .ini file & registry (or even both at the same time). The Filesystem Dialogs library pack contains such a class in FilesystemDialogsDefs.pas/TFileSystemDialogsSettings, see: Filesystem Dialogs or download.
- How to avoid including Forms in a .dll for Application.ProcessMessages?
Use the following code it will save you 100KB of code and no Initialization:
procedure ProcessMessages;
var
Msg : tMsg;
begin
while PeekMessage(Msg, 0, 0, 0, PM_REMOVE) do begin
TranslateMessage(Msg);
DispatchMessage(Msg);
end;
end;
- How to make an efficient thread?
Avoid calling Synchronize(), only call it when you have something to communicate with the main thread. Wise solution is for progress bars to call it only at a speed the user can read (4 times a second is enough).
|
|
|
|
 |
|
|
Recommended components and libraries
3delite's components - some very useful
3delite's Icon Set - 250+ high quality artistic Vista 3D icons
Un4seen - BASS - A basic library if you want to do anything with sound - makes audio tasks really simple
AudioXL - MP3/Audio Tagging Resource - The best ID3v1 and ID3v2 units for Delphi (the author seems to have stopped the development sadly, though - I wrote an email, that I would by the sources but without any response)
Graphics32 Project Homepage - Main.HomePage - The basic if you want to do anything with 2D graphics (TImage etc. class replacement with 32bits as basic)
GraphicEx - The image loader library - The image format extension (yes, supports .png) to be used together with Graphics32 or just on it's own
madCollection - Some very useful components: madExcept, madCodeHook, madKernel, madSecurity and madShell
TntWare Delphi Unicode Controls - Unicode supporting components
The DSPack Project - A package for video playback and audio/video stream handling (that is for "Multimedia Applications using MS Direct Show and DirectX technologies")
Alpha controls - Didn't had time to test it, but looks promising
Syntax Suite - Syntax highlighter components
tmssoftware.com components
delphi.about.com components - Free Delphi components, with source code
TCoolListView - coollistv.zip Download page
Getting info for objects
Pete's Personal Web Site - ThumbDBLib
Virtual Treeview
Welcome to Shell+ Home
Monospace/Fixed Width Programmer's Fonts - Select your coding font (Fixedsys or Bitstream Vera Sans Mono is recommended by me)
Information resources
Delphi - Elsõ lépések - Cikkek - Prog.Hu (Hungarian)
Delphi Basics
Open Source Delphi
Colin Wilson's Delphi 2006 Website
Google Groups: borland.public.delphi.objectpascal
Delphi32.com -- The Premier Source for Delphi Developers!
TGuidEx - Delphi class for manipulating Guid values
Delphi 6 Shell Links > Using IShellLink
Freepascal Lazarus Project - A free Object Pascal application developer environment under development
Borland Delphi - A very good Object Pascal application developer environment
Recommended tools
Turbo Delphi Explorer - A free very good Object Pascal application developer environment
Directory Opus - The programmer's file manager
XN Resource Editor - A freeware utility to view, modify, rename, add, delete and extract resources in 32bit windows executables and resource files (*.res)
Dependency Walker - A free utility that scans any 32-bit or 64-bit windows module (exe, dll, ocx, sys, etc.) and builds a hierarchical tree diagram of all dependent modules
TextPad - The programmer's shareware text editor - can be evaluated freely
Registrar Registry Manager - A registry editor (available as a free trial/lite edition with limited features)
PADGen - To distribute information about your projects for shareware authors
WinHex - Binary (hex) editor for files, disks, and RAM
Wheeler - A free program that enhances the behavior of your mouse wheel
Startup Control Panel - Startup Control Panel is a nifty control panel applet that allows you to easily configure which programs run when your computer starts
Pascal Analyzer & ICARUS - Useful informative reports to clean up the source code
MemCheck - Hunts memory leaks, memory corruption, use of an object after its destroying - essential
|
|
|
|
|
|