Articles Index
Is Your 32bit Delphi Applications Running On x86 (Win 32) OR x64 (Win 64)?
While I have Delphi XE 2 (supporting native x64 development) I am still compiling some of my applications as 32-bit applications (waiting for some 3rd party to move to x64). Having my x86 (32-bit) application running on various Windows versions - I need a way to know if my 32 bit application is running on Windows x86 (32-bit) or x64 (64 bit). Here's how to programmatically detect if your 32bit Delphi application is running on 32-bit or 64-bit Windows
ShellControls (TShellTreeView, TShellListView) In Delphi XE2
Delphi X2 has Vcl.Shell.ShellCtrls.pas but the Shell Controls package is not installed by default. There's ShellCtrls.pas in the samples folder (as before) - use it to manually install the package. What compiled (DCU) version of "shellctrls.pas" is used by Delphi?
Set Of Strings in Delphi - Mimic The Functionality of "set of string"
In Delphi, sets or set types allow you to do set type operations like union, intersection and difference on a set of ordinal values. A set is a collection of ordinal values. The values in a set have no order and it makes no sense to have a value twice (or more times) in a set. Since strings are not ordinal types you cannot have set of string declarations. Or, can you?
Implementing StartsText With SubText As Pattern
How to determine if a substring begins another string in Delphi? Easy: use StartsText (StartsStr, Pos, ...). How to determine if a pattern-like substring begins another string in Delphi? Easy: use regular expression!
Implementing the OnBeforeCreate and OnAfterCreate Events for Delphi Forms
The TForm's OnCreate event is called when the form is created. Usually, you would write an OnCreate event handler to perform special processing when the form is created - such as setting any startup information (initial control property values, for example) for form operation. If you are using VFI you might need to have code that executes after all OnCreate event handler has been called for all inherited forms. Here's how.
Simple File Encryption/Decryption in Delphi
File encryption is a process that makes (your) files protected in a way that they cannot be viewed by others. The most common use of file encryption is to protect your private files, documents and informations. Encrypted files are protected from "unauthorized" viewing until you decrypt them. Delphi 2010 added simple file encryption and decryption functions.
Number Of Occurrences Of A SubString Within a String
The SubStringOccurences custom Delphi function returns the number of occurrences of a sub string within another string. If you need to know how many times a path delimiter appears in a file/folder path you can use the SubStringOccurences funtion.
Implementing MaxLength For Delphi's TListView Edit Control
The ReadOnly property of a List View, determines whether the user can change the contents of the control - caption of an item. Since using TEdit we (Delphi developers) are used to have the MaxLength property. Here's how to limit the number of characters a user can enter into the ListView's editor control.
How to Check if a Given File Name is Valid Using Delphi
If you have an application that operates on the file system and one of the tasks of the application is creating or manipulating files you might need to check if a given file name is valid - will Windows allow your code to save a file using the specified file name. A custom Delphi function IsFileNameValid does the validation.
How to Implement the OnCreate event for a Delphi TFrame object
A frame, like a form, is a container for other components. Frames can be nested within forms or other frames, and they can be saved on the Component palette for easy reuse. Once you start using frames, you'll note there's no OnCreate event you can use to initialize your frames. Here's how to mimic the OnCreate event for Delphi frames.
Hide, Slide And Fade Away Controls On A Delphi Form
In most complex form designs you would have some panels that a user can make visible or hidden. Maybe some controls on some other container controls should be made invisible due to some reasons. A simple Panel1.Visible := false; will make a panel invisible, but why not make it more eye candy by providing a hiding animation. The AnimateWindow API function enables you to produce special effects when showing or hiding windows.
Select Single IXMLNode / TXmlNode Using XPath In Delphi's XmlDom
In Delphi, the XPath implementation in included in the xmldom.pas unit. Here's how to wrap XPath's selectNode into IXMLNode.SelectNode to get a node that matches the provided XPath's node path.
Select XML Nodes Into IXMLNodeList Using XPath In Delphi's XmlDom
In Delphi, the XPath implementation in included in the xmldom.pas unit. Here's how to wrap XPath's selectNodes into IXMLNode.SelectNodes to get a collection of XML nodes into IXMLNodeList.
Create Manifest for Vista UAC if Not Running Under Administrative Rights
By programmatically editing the Windows Registry, using the TRegistry object, you can you can "automagically" start your Delphi programs whenever Windows launches. On Vindows Vista, UAC will stop you from altering the Registry if a user runing the application does not have administrative rights. Learn how to create an application manifest file to request admin execution level. Automate the process of creating manifest files using a simple (source included) Delphi application.
Add Your Delphi Application as Item to Windows Explorer Folder Shell Menu
When a users right-clicks on a folder in Windows Explorer (and TShellTreeView not to forget) a context popup appears. Beside standard items you can add an item for your application. When a user click the item - your application gets started and you can send it (as a parameter) the folder selected.
Custom Hints For Each Tab in Delphi's TTabSet or TTabControl
For TTabSet and TTabControl there's only "one" Hint property you can set and this hint will appear for the control - not taking into account the selected tab or alike. Here's how to have different hints when the mouse hovers over a specific tab of the tab control.
Faking HideSelection Property for a TCheckListBox
When using the TCheckListBox control, in most cases I am only interested in what items are checked. The Checked[index] property indicates which items are checked. Am not interested in the selected item nor I want the visual indication of which item is selected when focus shifts to another control.
Remove Automatic Accelerator Keys For Delphi Menu Item
By default the AutoHotkeys property of a Delphi TMainMenu or TPopupMenu has the value of maAutomatic. This will add the & sign to the menu item Caption. What if you need to compare the value of the Caption string to some hard coded value (the expected Caption value set at design time)?
Loading XML / DTD in TXMLDocument - DTD Is Prohibited!
Delphi 2010 (and Delphi XE) uses MSXML 6 as the default DomVendor for the TXMLDocument. DomVendor (property) specifies the DOM implementation to use for parsing and manipulating the XML document. In MSXML 6, the ProhibitDTD property specifies whether to prohibit (true) or allow (false) the inclusion of a DTD in the XML document. Default value for ProhibitDTD is true. Here's a quick fix.
Handling Mouse Wheel Messages For The TImage Delphi Control
TGraphicControl descendant controls do not receive mouse wheel messages in Delphi. TImage is one such control. Here's how to expose the OnMouseWheel event handler for the TImage Delphi control. What's more how to handle mouse wheel messages for any TControl descendant.
How to Access a TRadioButton from a TRadioGroup - Disable, Change Font, etc.
Here's how to access a specific radio button either by Index or by Caption. When you "grab" the TRadioButton you can disable it, change its color, etc...
What is "var Form1:TForm1" in Delphi Form's Unit Interface section?
When you add a new form to a Delphi project, a form and its associated unit is included in the application. There's a global variable "Form1" in the interface section - what is it used for?
Is Some (Delphi) TControl Under the Mouse?
Sometimes knowing what is the control directly under the mouse is not enough. Here's how to check if the mouse is over some Delphi TControl descendant even if is covered by its child controls.
Auto Select All The Text For TCustomEdit On Mouse Click
Delphi's T(Custom)Edit AutoSelect property determines whether all the text in the edit control is automatically selected when the control gets focus. What we want is that AutoSelect works not only when the control is tabbed into BUT also when the edit control receives the input focus as a result of a mouse click into the control. Here's how.
Run Your Delphi Application in Full Screen - Implement "F11 - Full Screen"
Running in full screen, where an application UI covers the entire screen, over the TaskBar and any Desktop/Tool bars, is handy when a user has a limited screen size (netbooks) or when you just want more to be visible by the broswer or the Windows Explorer. Here's how to implement full-screen mode in your Delphi applications.
