Delphi Sample Source Code
- Printer
-
VCL
How to Retrieve Printer Information in Delphi: Using DeviceCapabilities, LOGPIXELSX, and Related Techniques
A detailed guide on retrieving printer resolution, paper sizes, and printable areas in Delphi. Includes practical examples using DeviceCapabilities, GetDeviceCaps, LOGPIXELSX, and DMPAPER constants to improve the accuracy and reliability of printing operations.
-
VCL
How to Perform Printing in Delphi: Practical Examples Using TPrinter, Canvas, and TextOut
A detailed guide to outputting text and images to a printer in Delphi, using TPrinter and Canvas. Includes practical source code examples for TextOut, TextRect, bitmap printing, and other essential printing techniques.
- Advanced Usage
-
VCL
Parallel Programming with the TTask Class — Delphi Source Code Collection
A practical guide to parallel programming with the TTask class, explained through sample source code for prime number detection.
- Windows API
-
VCL
Retrieving the Display (Monitor) Scaling Settings in Windows — Delphi Source Code Collection
A sample-based explanation of how to retrieve the display scaling settings in Windows using Delphi.
-
VCL
How to Create a Custom On‑Screen Touch Keyboard in Delphi keybd_event and IME Control Supported
A detailed guide on creating a custom on‑screen (touch‑enabled) keyboard in Delphi, including keybd_event usage, IME control, and CreateParams configuration. Also covers how to handle cases where the default Windows on‑screen keyboard does not appear.
-
VCL
How to Control Clipping and Window Shapes in Delphi Using Regions Guide to CreateRectRgn and CreateEllipticRgn
A detailed guide on using Regions in Delphi (rectangular, elliptical, and polygonal) to perform image clipping and modify window shapes, complete with sample code using APIs such as CreateRectRgn and CreateEllipticRgn.
-
VCL
Creating a Resident Task Tray Application in Delphi Preventing Multiple Instances and Handling TaskbarCreated
A step‑by‑step guide to building a resident task tray application in Delphi, complete with source code. Covers preventing multiple instances, handling TaskbarCreated, processing WM_QUERYENDSESSION, and other techniques for creating a stable Windows background application.
-
String Conversion in Delphi Using LCMapStringEx: Half‑Width/Full‑Width, Hiragana/Katakana, Uppercase/Lowercase
A practical guide to using the Windows API LCMapStringEx in Delphi to convert strings between half‑width and full‑width characters, hiragana and katakana, and uppercase and lowercase. Includes clear explanations and sample code to help you implement reliable text‑conversion features in your applications.
-
VCL
Dragging Windows and Panels in Delphi: How to Use ReleaseCapture and SC_MOVE
A guide to moving forms and TPanels by mouse drag in Delphi’s VCL environment. This article explains how to implement window dragging using the Windows API functions ReleaseCapture and SendMessage(SC_MOVE), along with practical handling of TMouseButton events.
-
VCL
Get the Full Path of Windows Special Folders in Delphi | SHGetSpecialFolderPath Guide
Learn how to retrieve the full path of Windows special folders—such as Desktop, My Documents, and Application Data—using the SHGetSpecialFolderPath API in Delphi. Includes clear explanations and practical sample code.
-
VCL
Opening Windows Explorer with the ShellExecute API in Delphi | Practical Code Examples
Learn how to open Windows Explorer from Delphi using the ShellExecute API—either by opening a specific directory or highlighting a selected file. This guide includes clear explanations and practical sample code.
-
VCL
How to Create a Startup Shortcut (.lnk) in Delphi | Windows Auto‑Launch Implementation Guide
Learn how to create a shortcut (.lnk file) in the Windows Startup folder using Delphi to automatically launch your application at login. This guide explains the process with clear sample code using IShellLink and IPersistFile.
-
VCL
Improving Image Scaling Quality in Delphi with StretchBlt and SetStretchBltMode (HALFTONE)
Learn how to improve image scaling quality in Delphi using the StretchBlt API together with SetStretchBltMode(HALFTONE). This guide explains the differences from TCanvas.StretchDraw, how to work with HDCs, and includes practical sample code.
-
VCL
Controlling Windows with SetWindowPos in Delphi | Z-Order, Topmost, and SWP Flags Explained
Learn how to use the Windows API SetWindowPos in Delphi to control window position, size, and Z-order. Includes examples for topmost windows (HWND_TOPMOST), sending windows to the back (HWND_BOTTOM), non-activating updates (SWP_NOACTIVATE), and a clear overview of common SWP flags
-
VCL
Retrieving Process Lists and Forcibly Terminating Processes — Delphi Source Code Collection
A practical guide showing how to retrieve a process list in Delphi using the QueryFullProcessImageNameW API and forcibly terminate processes with the TerminateProcess API, complete with sample source code.
- TCanvas(TBitmap)
-
VCL, FMX
Drawing on the Delphi Canvas|Sample Code for Shapes and Text Rendering with TBitmap and TCanvas (VCL/FMXL)
A complete guide to drawing shapes and text on the Delphi Canvas using TBitmap and TCanvas. Includes VCL and FMX sample code, FillRect and TextRect usage, TBitmap settings, integration with TImage, and geometric pen techniques.
-
VCL, FMX
Rotate a TBitmap Image and Draw It on a Canvas (VCL & FMX) – Delphi Source Code Examples
Explains how to rotate a TBitmap image around any point at any angle and draw it on a Canvas in both VCL and FMX, with clear Delphi sample source code.
- TDirect2DCanvas
-
VCL
Direct2D Canvas Rendering in Delphi: Controlling Anti-Aliasing and Alpha Blending
A practical guide to using Delphi’s TDirect2DCanvas to implement anti‑aliased rendering and alpha‑blend transparency control. This article explains how to improve the quality of RoundRect and line drawing through proper settings, and includes examples of exporting bitmaps using TImage.
- GraphicEx
-
VCL
How to Display PSD Files in Delphi Installing and Using the GraphicEx Library
To display Photoshop PSD files in Delphi, the GraphicEx library is a practical solution. This article explains how to download and configure GraphicEx, and provides sample source code for rendering PSD images in TImage. It also covers reading layer information and saving bitmaps.
- PDFium
-
VCL
Using PDFium in Delphi: PDF Rendering, Text Extraction, and Image Conversion with Sample Code
A detailed guide on how to use PDFium in Delphi to render PDF files, extract text, and convert pages to images. Includes download sources for the required DLLs and libraries, implementation steps for VCL applications, and complete sample code. Verified to work with Delphi 12 CE
- Registering a System‑Wide Hotkey in Windows
-
VCL
Registering Global Hotkeys in Delphi with RegisterHotKey — Handling WM_HOTKEY and Window Control Examples
Explains how to register system-wide global hotkeys in a Delphi VCL application using the RegisterHotKey API. Covers handling WM_HOTKEY messages, managing IDs with GlobalAddAtom, bringing windows to the front with SetWindowPos, and includes practical code examples.
- Drag-and-Drop Files
-
VCL
How to Receive Drag-and-Drop Files in Delphi VCL — WM_DROPFILES and DragQueryFile Implementation Examples
A detailed guide on how to receive files and folders dragged from Explorer into a Delphi VCL application using WM_DROPFILES and DragQueryFile. Includes sample code, message handling with ApplicationEvents, and methods for displaying dropped files in a ListBox.
-
FMX
Handling Drag-and-Drop Files in Delphi FMX — Implementing WM_DROPFILES and DragQueryFile
Explains how to receive files and folders dragged from Windows Explorer into a Delphi FMX application using WM_DROPFILES and DragQueryFile. Includes sample code, replacing the Window Procedure with CallWindowProc, and displaying dropped items in a ListBox.
- drag file from a Delphi application to Windows Explorer
-
VCL
How to Drag and Drop Files in Delphi VCL — TOleDragPanel and DoDragDrop Implementation Examples
A step-by-step guide to implementing file drag-and-drop in Delphi VCL using the TOleDragPanel class and the DoDragDrop API. Includes sample code demonstrating integration with Windows APIs such as ILCreateFromPath and QueryContinueDrag, along with examples of handling OnDrop events.
- Webview4Delphi
-
VCL
Using the Browser Speech Recognition API from Delphi with WebView4Delphi (WebView2) – Delphi Source Code Collection
A step-by-step guide showing how to use the browser SpeechRecognition API from Delphi via WebView4Delphi (WebView2), complete with sample source code.
-
VCL
Using the Browser Geolocation (GPS) API from Delphi with WebView4Delphi (WebView2) – Delphi Source Code Collection
A step-by-step guide showing how to use the browser Geolocation (GPS) API from Delphi via WebView4Delphi (WebView2), complete with sample source code.
- Windows Service Application
-
VCL
Creating a Service Application in Delphi
Explains how to create a service application that starts automatically when the OS boots, even without user logon, and how to register the service in Windows using sample source code.
- Network
-
VCL, Windows API
Sending Ping Requests in Delphi (IcmpSendEcho API)
How to Send Ping Requests in Delphi Using the IcmpSendEcho API
-
VCL
Parsing JSON Responses from REST APIs in Delphi — Implementing a Zip Code Lookup Using TRESTClient and TJsonObject
This article explains how to perform REST API communication in Delphi and parse JSON responses using TJsonSerializer, TJsonTextReader, and TJsonObject. Through an implementation example using the ZipCloud API, it demonstrates how to use TRESTClient, TRESTRequest, and TRESTResponse, along with important considerations when handling different JSON structures
-
Sending GET and POST Requests with Delphi’s TNetHTTPClient and Retrieving Web Content
This article explains how to use Delphi’s TNetHTTPClient to send GET and POST requests to a web server and handle cookies, with sample source code.
- ZXing.Delphi (Scanning QR codes and Code39 barcodes)
-
VCL
How to Read QR Codes from a Webcam in Delphi|Complete Guide Using ZXing.Delphi + DSPack
A comprehensive, step‑by‑step guide to reading QR codes and barcodes from a webcam in Delphi using ZXing.Delphi and DSPack. Includes form design, component setup, event handling, and full source code examples to help you implement scanning quickly and reliably.
- DSPack
-
Installing DSPack: A Delphi Library for Easily Working with DirectShow
A guide to installing DSPack, a Delphi library that makes DirectShow (for handling webcams and creating videos) easy to use.
- Hardware
-
VCL
Reading Illuminance (Lux) from a Light Sensor (VCL) — Delphi Source Code Collection
A sample‑based explanation of how to read illuminance (in lux) from a PC equipped with a light sensor using Delphi.
-
VCL
Reading and Writing NFC Cards (NXP NTAG215) with PaSoRi and Delphi – Windows Sample Code Collection
This article explains how to read and write NFC cards (NXP NTAG215) using PaSoRi (RC-S380) and Delphi in a Windows environment (winscard.dll and ScardTransmit), with sample code included. While UID can be retrieved from other IC cards as well, this article focuses specifically on NTAG215.
-
VCL
Delphi NFC Programming with PaSoRi (RC-S3800): Read and Write Strings and URLs
Step-by-step guide to using Delphi with the PaSoRi RC-S3800 NFC reader. Learn how to read and write strings, URLs, and UID data from IC cards, with complete source code examples and execution instructions.
-
VCL
Play Microphone Audio in Near Real Time
A step‑by‑step explanation with sample Delphi source code showing how to play microphone audio to the speakers in near real time.
-
VCL
Create a Voice Changer in Delphi FFT + Pitch Shifting Sample Code
Explains how to capture microphone input in Delphi, apply FFT‑based pitch shifting, and play the processed audio in real time. Includes full source code.
-
VCL
Record Microphone Audio in Delphi and Save as a WAV File
Create a Delphi application that records microphone audio using waveIn and saves it as a WAV file. Includes complete source code and explanations.
-
VCL
Retrieving SMART Data in Delphi|How to Check SSD/HDD Health Status
A step‑by‑step guide on how to retrieve SMART data from SATA‑connected SSDs and HDDs using Delphi, including sample source code. Supports checking drive health status and reading attribute values.
-
VCL
How to Retrieve SMART Information from NVMe SSDs in Delphi|Health Log & IOCTL Usage Example
A guide to retrieving SMART information (Health Information Log) from NVMe‑connected SSDs using Delphi. Includes an implementation example using IOCTL_STORAGE_QUERY_PROPERTY for storage diagnostics on Windows.
-
VCL
Wake-on-LAN in Delphi Send Magic Packets to Power On Remote PCs
Learn how to send Wake-on-LAN (WOL) magic packets in Delphi to power on remote PCs. Includes a simple example and full source code. -
VCL
Reading Aloud the Entered Text — Delphi Source Code Collection
A sample‑based explanation of how to create an application that reads aloud (speaks) the text entered by the user.
-
VCL
Retrieving Keyboard, Mouse, and Joystick Input
A sample‑based explanation of how to obtain the current state of the keyboard, mouse, and joystick (gamepad) controllers—essential for game development.
-
VCL
Playing a Sound at a Specified Frequency in Delph
A step‑by‑step sample showing how to play a tone at a specified frequency using Winapi.Windows.Beep in Delphi.
-
VCL
Playing MIDI Sounds in Delphi — A Practical Guide to midiOutShortMsg
A practical guide to playing MIDI sounds in Delphi using midiOutShortMsg, including note on/off, program changes, chords, and fully working sample code.
- Algorithms and Miscellaneous Topics
-
FFT in Delphi: Fast Fourier Transform Tutorial with Window Functions and Analysis Code
Learn how to implement FFT (Fast Fourier Transform) in Delphi with complete sample code. Covers Hanning, Hamming, Blackman–Harris window functions, amplitude and frequency analysis, and handling real and imaginary components. Ideal for signal processing and spectrum analysis in Delphi.
-
Implementing a UTF‑8 to UTF‑16LE Conversion Function in Delphi
Delphi can convert UTF‑8 to UTF‑16LE using TEncoding.UTF8.GetString, but it fails when invalid byte sequences are present. This article explains a safer conversion method that handles malformed UTF‑8 as gracefully as possible, with complete source code.
- FMX 3D
-

FMX
Building a 3D Simulator in Delphi FMX — Controlling a Drone‑Like Object with Viewport3D
This guide explains how to build a 3D simulator in Delphi FMX using , including how to control a drone‑like object in a 3D space. It covers coordinate handling, movement logic, and includes practical example code.
