Category Archives: Delphi

Delphi stuff to read but not gotten around to March 2013

http://podgoretsky.com/ftp/Docs/Delphi/D5/dg/packcomp.html http://webcache.googleusercontent.com/search?q=cache:0F0aoNui5HwJ:podgoretsky.com/ftp/Docs/Delphi/D5/dg/packcomp.html+&cd=1&hl=en&ct=clnk&gl=uk (Google Cache of Above) http://etutorials.org/Programming/mastering+delphi+7/Part+II+Delphi+Object-Oriented+Architectures/Chapter+10+Libraries+and+Packages/

Get application / file version information.

function GetVersion2(const theFileName: string): string; var VerInfoSize: DWORD; VerInfo: Pointer; VerValueSize: DWORD; VerValue: PVSFixedFileInfo; Dummy: DWORD; begin Result := ”; VerInfoSize := GetFileVersionInfoSize(PChar(theFileName), Dummy); if VerInfoSize = 0 then Exit; GetMem(VerInfo, VerInfoSize); GetFileVersionInfo(PChar(ParamStr(0)), 0, VerInfoSize, VerInfo); VerQueryValue(VerInfo, ‘\’, Pointer(VerValue), VerValueSize); with VerValue^ do begin Result := IntToStr(dwFileVersionMS shr 16); Result := Result + ‘.’ +… Read More »

Storing application data in Windows XP and higher

uses ShlObj; function GetSpecialFolder(const CSIDL: integer) : string; var RecPath : PWideChar; begin RecPath := StrAlloc(MAX_PATH); try FillChar(RecPath^, MAX_PATH, 0); if SHGetSpecialFolderPath(0, RecPath, CSIDL, false) then result := RecPath else result := ”; finally StrDispose(RecPath); end; end; And I call it with GetSpecialFolder(CSIDL_APPDATA) Where the list of CDISL is defined here. GetSpecialFolder(CSIDL_APPDATA) returns C:\Users\username\AppData\Roaming in Windows List of CDISL… Read More »

Delphi Validating UK postcodes

http://www.daniweb.com/software-development/pascal-and-delphi/threads/276733/postcode-validation http://www.ml-consult.co.uk/foxst-39.htm function ValidPostcode(anInput: String): Boolean; var iSpacePos, I: byte; sInward, sOutward: String; begin Result := False; if (anInput = EmptyStr) then Exit; anInput := UpperCase(anInput); iSpacePos := Pos(‘ ‘, anInput); if iSpacePos = 0 then Exit; sInward := Copy(anInput, iSpacePos + 1, 3); sOutward := Copy(anInput, 1, iSpacePos – 1); if StrToIntDef(sInward[1], -1) =… Read More »

How to Sort a ListView

When you are working with a TListView component and want to sort the items based on a custom criteria, you can use the following idea… Suppose you have assigned numbers for the TListItem Caption property and need to sort the ListView when displayed in a report-style. To use custom sorting handle the OnCompare event. If… Read More »

Require a password login into your Delphi Application

unit login; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TLoginForm = class(TForm) LogInButton: TButton; pwdLabel: TLabel; passwordEdit: TEdit; procedure LogInButtonClick(Sender: TObject) ; public class function Execute : boolean; end; implementation {$R *.dfm} class function TLoginForm.Execute: boolean; begin with TLoginForm.Create(nil) do try Result := ShowModal = mrOk; finally Free; end;… Read More »

Delphi & Crystal Reports – Steves way

Choose Type Library “Crystal Report Control” (version 5.2 on my system) – CRYSTL32.OCX Gives me TCrystalReport If you get a complaint during compling saying it can’t find Crystal_TLB go to the PROJECT OPTIONS, click Delphi Compiler then add “E:\My Programs\Delphi2010\[packages]\TCrystalReport” to Search Path.

Using Automation with Crystal Reports and Delphi

In order to use the automation features in Crystal Reports 8.0 and higher, you must first import the type libraries into Delphi. 1. From the Delphi IDE main menu, go to Project | Import Type Libary. 2. Highlight ‘Crystal Report 8 Active X Designer Run Time Libary’. 3. In the Class Names box, change the… Read More »

TListView info

This info is C orientated but you can figure it out! Start a new application with its default form From the Win32 tab of the Component Palette, double-click the ListView control. Change the Height of the ListView1 control to 200 and its Width to 350 Double-click an empty area on the form and implement the… Read More »