Posts

Showing posts from 2019

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: