About Delphi Programming Tips - 2005
Delphi tips from the free About Delphi Programming newsletter.
More tips by year: 2008 | 2007 | 2006 | 2005 | 2004 | 2003 | 2002 | 2001 | 2000 | 1999
More tips by year: 2008 | 2007 | 2006 | 2005 | 2004 | 2003 | 2002 | 2001 | 2000 | 1999
Using TFilterComboBox with TShellTreeView
To filter the files in the shell tree view, by file extension, the TShellTreeView can be used with the TFilterComboBox ("Win31" palette).
To filter the files in the shell tree view, by file extension, the TShellTreeView can be used with the TFilterComboBox ("Win31" palette).
How to Play a Sound When the Mouse Enters a (Delphi) Component
All descendants of Delphi's TComponent send a CM_MOUSEENTER and CM_MOUSELEAVE messages when the mouse enters and leaves the bounds of the component. You will need to write a message handler for the respective messages if you wish to respond to them - and play a sound, for example, when the mouse "enters" the component.
All descendants of Delphi's TComponent send a CM_MOUSEENTER and CM_MOUSELEAVE messages when the mouse enters and leaves the bounds of the component. You will need to write a message handler for the respective messages if you wish to respond to them - and play a sound, for example, when the mouse "enters" the component.
Delphi IDE (Code Editor) Keyboard Shortcuts
Following is a short list of convenient editor keyboard shortcuts for the default keybinding that is shipped with Delphi 2006.
Following is a short list of convenient editor keyboard shortcuts for the default keybinding that is shipped with Delphi 2006.
How to Detect the Start Move/Resize, Move and Stop Move/Resize events of a Delphi Form
If you want to detect when a user starts resizing and moving a Delphi form, and when the move (or resize) operation is finished, you need to handle a few Windows messages: WM_ENTERSIZEMOVE, WM_MOVE and WM_EXITSIZEMOVE. Here's how...
If you want to detect when a user starts resizing and moving a Delphi form, and when the move (or resize) operation is finished, you need to handle a few Windows messages: WM_ENTERSIZEMOVE, WM_MOVE and WM_EXITSIZEMOVE. Here's how...
How to Convert a Bitmap to a Cursor using Delphi code
Let's say you have a bitmap (BMP) image you would like to convert to a cursor and use in your Delphi application. Here's how...
Let's say you have a bitmap (BMP) image you would like to convert to a cursor and use in your Delphi application. Here's how...
How to Convert an amount of Milliseconds to a TDateTime Value
When doing lengthy operations in your Delphi applications, you might want to display the time passed to the user. If GetTickCount is used to measure the time passed in milliseconds you need to a function to convert milliseconds to days, hours, minutes and seconds.
When doing lengthy operations in your Delphi applications, you might want to display the time passed to the user. If GetTickCount is used to measure the time passed in milliseconds you need to a function to convert milliseconds to days, hours, minutes and seconds.
How to Parse a Delimited String Into a String List (Delphi)
There are many times when you need to split a Delphi string into an array of strings by using a character as a separator. Delphi provides several methods to parse a string, but you might find that neither one does exactly what you need. Here's how to write a "ParseDelimited" method of your own.
There are many times when you need to split a Delphi string into an array of strings by using a character as a separator. Delphi provides several methods to parse a string, but you might find that neither one does exactly what you need. Here's how to write a "ParseDelimited" method of your own.
How to Drag and Drop Image Files to a Timage Delphi control (from Windows Explorer)
Let's say you need to "open" you Delphi application to the Windows - allowing it to accept files dragged from the Windows Explorer. Here's how to accept dragging (and dropping) an image file onto a TImage...
Let's say you need to "open" you Delphi application to the Windows - allowing it to accept files dragged from the Windows Explorer. Here's how to accept dragging (and dropping) an image file onto a TImage...
How to Break a Long Menu into Columns in a Delphi application
Most applications have some kind of menu to help users select an action in a program. When adding sub-items to a menu, you migth want to break menu items into columns. Here's how to create multi-column menus in Borland Delphi.
Most applications have some kind of menu to help users select an action in a program. When adding sub-items to a menu, you migth want to break menu items into columns. Here's how to create multi-column menus in Borland Delphi.
How to change the default Windows printer from Delphi code
Here's how to change the default Windows printer if you know the printer's name ...
Here's how to change the default Windows printer if you know the printer's name ...
How to remeber Delphi form controls position and size
If you enabled a user to move and resize form controls (at run time), you have to ensure that control placement is somehow saved once the form is closed and that each control's position is restored once the form is created / loaded.
If you enabled a user to move and resize form controls (at run time), you have to ensure that control placement is somehow saved once the form is closed and that each control's position is restored once the form is created / loaded.
How to set the progress bar position using mouse
If you want to enable the users of you Delphi application to set the position of the progress bar using mouse, you can use the next trick...
If you want to enable the users of you Delphi application to set the position of the progress bar using mouse, you can use the next trick...
UDP Makes a Difference (UDP vs. TCP)
Everybody is quite familiar with TCP. Most do know UDP and think its an inferior protocol, as it does not ensure that the data bytes sent will arrive at the other site. Thus, UDP imposes less network overhead than TCP and gives the programmer more freedom and more labor by forcing him to deal with the security of the data transport himself.
Everybody is quite familiar with TCP. Most do know UDP and think its an inferior protocol, as it does not ensure that the data bytes sent will arrive at the other site. Thus, UDP imposes less network overhead than TCP and gives the programmer more freedom and more labor by forcing him to deal with the security of the data transport himself.
How to create a shaking window using Delphi code
Whether you want to shake your Delphi application forms just for fun or to attract a user attention it's up to you :) Here's a simple code to shake a window provided a window's handle...
Whether you want to shake your Delphi application forms just for fun or to attract a user attention it's up to you :) Here's a simple code to shake a window provided a window's handle...
How to place a TEdit inside a TListBox to simulate inplace editing of ListBox items
By design, a TListBox component displays a collection of items (string values) in a scrollable list. Items of a ListBox cannot be edited directly from "inside" the ListBox. If you ever needed to enable inplace editing of ListBox strings, here's a trick to place an ordinary TEdit inside a ListBox.
By design, a TListBox component displays a collection of items (string values) in a scrollable list. Items of a ListBox cannot be edited directly from "inside" the ListBox. If you ever needed to enable inplace editing of ListBox strings, here's a trick to place an ordinary TEdit inside a ListBox.
How to enable editing of a document in TWebBrowser
If you need to enable a user to change the contents of a document (web page) displayed by the TWebBrowser component, use the next trick...
If you need to enable a user to change the contents of a document (web page) displayed by the TWebBrowser component, use the next trick...
The role of the "AOwner" parameter in the Create constructor of Delphi components
Delphi must be destroying the objects, but how does it know when were through with them? Who ownes the component you create at run-time?
Delphi must be destroying the objects, but how does it know when were through with them? Who ownes the component you create at run-time?
How to focus a specific cell (by field name) in a DBGrid Delphi component
Here's a simple trick to set the input focus to a specific cell of a TDBGrid component. Given the DBGrid's active row and field name (or the column index) the cell receives the input focus and becomes active.
Here's a simple trick to set the input focus to a specific cell of a TDBGrid component. Given the DBGrid's active row and field name (or the column index) the cell receives the input focus and becomes active.
How to click-and-select a line in TMemo Delphi component
Here's how to select a row (line) of text in a TMemo Delphi control.
Here's how to select a row (line) of text in a TMemo Delphi control.
How to start your favorite application directly from the Delphi IDE
borland delphi ide tool custom menu item start no leave add program application tip steps
borland delphi ide tool custom menu item start no leave add program application tip steps
Get the full HTML from the TWebBrowser Delphi component
When using the TWebBrowser component you might want to grab the full HTML source code from the page being displayed by the component. Here's how
When using the TWebBrowser component you might want to grab the full HTML source code from the page being displayed by the component. Here's how
TForm.Create(?) Nil, Self or Application?
When creating Delphi objects dynamically, that inherit from TControl, such as a TForm (representing a window) in Delphi application, the constructor "Create" expects an Owner parameter. Should you use "nil", "self" or "Application"? Find here...
When creating Delphi objects dynamically, that inherit from TControl, such as a TForm (representing a window) in Delphi application, the constructor "Create" expects an Owner parameter. Should you use "nil", "self" or "Application"? Find here...
How to Convert Pixels to Milimeters (Delphi code)
If you need to convert pixel value to milimeters (inches, centimeters, etc.) use the code provided here.
If you need to convert pixel value to milimeters (inches, centimeters, etc.) use the code provided here.
How to create a Console mode application Without a console window using Delphi
How to create an invisible NO GUI Delphi application running in the background: create a console mode application then "remove" the console from the application.
How to create an invisible NO GUI Delphi application running in the background: create a console mode application then "remove" the console from the application.
Get the list of events with attached event handlers (Delphi for Win32)
In Delphi for Win32 OOP, an event of an object might be handled by one method (event handler). Here's how to get the list of those events of an object, that have a handler attached...
In Delphi for Win32 OOP, an event of an object might be handled by one method (event handler). Here's how to get the list of those events of an object, that have a handler attached...
Setting a multi-line Caption for a TLabel (at design-time)
You *cannot* specify multi-line text for a TLabel at design-time, using Object Inspector. One trick to add more lines of text for a Caption property of a TLabel, at design time, is to edit the Form's .DFM file directly. Here's how.
You *cannot* specify multi-line text for a TLabel at design-time, using Object Inspector. One trick to add more lines of text for a Caption property of a TLabel, at design time, is to edit the Form's .DFM file directly. Here's how.
Universal solution to formating values for SQL statements (issued from Delphi code)
When working on database applications using dbGO (ADO) over SQL Server or MS Access, you might be having troubles formating the SQL string expression used in various INSERT, UPDATE or SELECT statements.
When working on database applications using dbGO (ADO) over SQL Server or MS Access, you might be having troubles formating the SQL string expression used in various INSERT, UPDATE or SELECT statements.
How to move the mouse cursor to the focused control when the form is displayed (from Delphi code)
If you want to move the mouse cursor to the control with the (input) focus, you can use the next code in the form's OnCreate event handler ...
If you want to move the mouse cursor to the control with the (input) focus, you can use the next code in the form's OnCreate event handler ...
How to get the selected text from a Memo control
If you need to know what portion of the text a user selected in a TMemo (or TEdit) Delphi component, right after the selection was made, you can use the next code in the OnMouseUp event...
If you need to know what portion of the text a user selected in a TMemo (or TEdit) Delphi component, right after the selection was made, you can use the next code in the OnMouseUp event...
How to add leading zeroes to a number
Here's how format a number to a string by adding an amount leading of zeroes, in Delphi.
Here's how format a number to a string by adding an amount leading of zeroes, in Delphi.
How to clear the graphics in a TImage Delphi control
If you need to clear the image contained in the TImage Delphi control, at run time, you'll find that *no* method exist for such a simple task...
If you need to clear the image contained in the TImage Delphi control, at run time, you'll find that *no* method exist for such a simple task...
How to exchange Bitmap images between two TImageList components
If you need to send a bitmap image from one TImageList component to another, you can use the next code...
If you need to send a bitmap image from one TImageList component to another, you can use the next code...
What does #13#10 stand for, in Delphi code?
You've certainly seen "#13#10" many times in Delphi source code. If you are wondering what those character stand for, here's the answer...
You've certainly seen "#13#10" many times in Delphi source code. If you are wondering what those character stand for, here's the answer...
How to set the DataSource property to several db-aware controls in one call
If you need to change the DataSource property of many data-aware controls that do not have a common ancestor you can use Delphi's RTTI (run-time type info) and call only one procedure. Here's how...
If you need to change the DataSource property of many data-aware controls that do not have a common ancestor you can use Delphi's RTTI (run-time type info) and call only one procedure. Here's how...
Fixing the RadioButtonList ASP.NET Web Server control - adding Attributes to Items
Here's the fixed RadioButtonList, the one that actually renders its items attributes (by overriding the Render method and making sure each Item attributes are rendered)...
Here's the fixed RadioButtonList, the one that actually renders its items attributes (by overriding the Render method and making sure each Item attributes are rendered)...
How to handle system time change using Delphi code
If you need to react when system date time has changed you can handle the WM_TimeChange Windows message...
If you need to react when system date time has changed you can handle the WM_TimeChange Windows message...
How to Split and Merge Files using Delphi code
A two handy Delphi methods to split a large file into smaller pieces with defined size - and to merge those files back.
A two handy Delphi methods to split a large file into smaller pieces with defined size - and to merge those files back.
Enabling Cassini to use Client-Side Validation in ASP.NET
When using Cassini to debug ASP.NET applications you might encounter some problems if you are using client-side validation from Web Server Validator controls. Here's a quick fix.
When using Cassini to debug ASP.NET applications you might encounter some problems if you are using client-side validation from Web Server Validator controls. Here's a quick fix.
How to Sort a TListView Delphi component
When you are working with a TListView Delphi component and want to sort the items based on a custom criteria, you can use the following idea...
When you are working with a TListView Delphi component and want to sort the items based on a custom criteria, you can use the following idea...
How to Enable the Refresh button on a DBNavigator for ReadOnly Datasets
In Delphi database applications, when using the TDBNavigator component with read-only datasets, the Refresh button is disabled by design. Here's how to re-enable the DBNavigator's Refresh button.
In Delphi database applications, when using the TDBNavigator component with read-only datasets, the Refresh button is disabled by design. Here's how to re-enable the DBNavigator's Refresh button.
Delphi Programming Tips 285 - 288
Delphi tips: Moving the focus to the next edit control when MaxLength characters have been reached. How to handle the TMaskEdit's internal "Invalid input value. Use escape key to abandon changes" error in Delphi. Logging Exceptions in Delphi Applicaions. Placing a Delphi Form inside a TabSheet of a TPageControl.
Delphi tips: Moving the focus to the next edit control when MaxLength characters have been reached. How to handle the TMaskEdit's internal "Invalid input value. Use escape key to abandon changes" error in Delphi. Logging Exceptions in Delphi Applicaions. Placing a Delphi Form inside a TabSheet of a TPageControl.
Delphi Programming Tips 277 - 280
Delphi tips: HoHow to allow column resize but disable movement (in TDBGrid). Fixing the "Duplicate resource" error. How to (bulk) import data from an ASCII (.txt) file into a DB using ADO and only one INSERT statement. Fixing the CheckBoxList ASP.NET Web Server control - adding Attributes to Items.
Delphi tips: HoHow to allow column resize but disable movement (in TDBGrid). Fixing the "Duplicate resource" error. How to (bulk) import data from an ASCII (.txt) file into a DB using ADO and only one INSERT statement. Fixing the CheckBoxList ASP.NET Web Server control - adding Attributes to Items.
Delphi Programming Tips 281 - 284
Delphi tips: Fixing the ListBox (and DropDownList) ASP.NET Web Server control - adding Attributes to Items. How to cancel the TDBNavigator button click. Fixing the "Transaction ... an object is in a zombie state" error in Delphi ADO database applications. Raising TPageControl's OnChagning and OnChange events from code.
Delphi tips: Fixing the ListBox (and DropDownList) ASP.NET Web Server control - adding Attributes to Items. How to cancel the TDBNavigator button click. Fixing the "Transaction ... an object is in a zombie state" error in Delphi ADO database applications. Raising TPageControl's OnChagning and OnChange events from code.
