Posts

Set Enter Key to work like Tab Key in Delphi Application

In Delphi Applications, we use Tab Key to move focus from one control to another control. But some user prefer to press Enter key to move focus from one control to another control for speed data entry work. As Delphi does not provide such in-build facility or any in build property to set Enter Key as Tab. So here I will explain how to set Enter key to behave like Tab, and Shift+Enter like Shift+Tab.  But before, I assume that there is no default button on the form. When a form contains a button and whose Default property is set to True then pressing Enter at run-time executes any code contained in the button's OnClick event handler.  So here we will check with different examples for setting Enter key as tab in Edit controls, grid controls and globally on a form.  For all Form controls that ability to focus We can set this functionality for controls like EditBox, Memo, Combo, Listbox,  RadioButton, Checkbox etc and also other controls that have ability to focus. pr

What is #13#10 and #$D#$A in Delphi?

Image
#13#10 and #$D#$A are called as control strings in Delphi which are used to set layout of a string. Both #13#10 and #$D#$A same ASCII codes and used to add new line to a string where the difference is in their representation that #13 is decimal but #$D is hexadecimal . For example, if we want to show a message having 2 lines then we can write following codes. Showmessage('First line' + #13#10 + 'Second line'); Here in above code #13#10 part represents a carriage return + line feed combination. So the message will show as following. Some other control strings that Delphi provide #13 - Carriage return (ASCII) #10 - Line feed (ASCII) #$D - Carriage return (Hexadecimal) #$A - Line feed (Hexadecimal) #0 - NULL #9 - Tab #32 - Space #9 tab display issue is message dialogs In latest Delphi versions #9 tabs does not work properly with message dialogs because Windows ignores tabs on buttons and dialogs. So set UseLa

How to open Windows OS dialog in Delphi ?

Image
Sometime it is required to open common windows dialog like Regional Settings dialog, Date Time Setting dialog, Windows About dialog etc. from our application. So here in this blog I have created a separate unit which having functions that calls WinApi procedures to open windows common dialog. So lets see… Here I created a unit TestWinDialogs and have added function to open windows common dialog. Then I added the unit to a Delphi project. unit TestWinDialogs; interface uses   Windows, Dialogs, Messages,  DDEMan,  ShellAPI, SysUtils, ShlObj, ActiveX; type   TWindowsDialogs = (wdStartMenu,                       wdRecycleBin,                       wdRunFile,                       wdUserManager,                       wdWindowsAboutDlg,                       wdWindowsShutdownDialog,                       wdScreenSaver,                       wdControlPanel,                       wdSystemProperties,                       wdDisplayProperties,                       wdTh

Enumerated Type, Subrange Type and Set Type in Delphi

Image
Enumerated Types An enumerated type defines an ordered set of values by simply listing identifiers that represent the values. This helps to make codes to readable and reliable. Enum variable can store any one value from the list. To declare an enumerated type, we use the syntax:   type typeName = (val1, val2, val3, val4, ...,valn); Where typeName and each val are valid identifiers.  For example, the declaration: type TFileType = (ftPDF, ftDoc, ftXLSX, ftHTML, ftRTF, ftTxt); defines an enumerated type called TFileType, whose identifiers are ftPDF, ftDoc, ftXLSX, ftHTML, ftRTF and ftTxt. Values of identifiers would be 0, 1, 2, 3, 4 and 5 where Ord(ftPDF) returns 0, Ord(ftDoc) returns 1, and so on. When you declare an enumerated type, you are declaring each val to be a constant. So we should be careful that If the identifiers are used for another purpose within the same scope then naming conflicts may occur.  For example, suppose you declare the type: