
They become useful when you want to call a Windows API function that is not supported by Delphi. In Delphi, you seldom need to use handles directly, since they are hidden inside forms, bitmaps, and other Delphi objects.

In other words, a handle is an internal code you can use to refer to a specific element handled by the system, including a window, a bitmap, an icon, a memory block, a cursor, a font, a menu, and so on. This doesn't apply only to functions operating on windows other Windows API functions have as their first parameter a GDI handle, a menu handle, an instance handle, a bitmap handle, or one of the many other handle types.

Many Windows API functions, in fact, have a handle as the first parameter. From that point on, your application can ask the system to operate on window number 142-moving it, resizing it, reducing it to an icon, and so on. The system informs you that the window you are working with is window number 142, for example. For example, when you work with a window (or a Delphi form), the system gives you a handle to the window. In Windows, a handle is a reference to an internal data structure of the system. Handle data types are implemented as numbers, but they are not used as such. The name of this data type is THandle, and the type is defined in the Windows unit as: Instead, we'll look at a few elements of Delphi's interaction with the operating system and a couple of techniques that Delphi programmers can benefit from.Īmong the data types introduced by Windows in Delphi, handles represent the most important group.


You would only want to take this approach for very special cases, such as the development of new Delphi components based on unusual API calls, and I don't want to cover the details. Nonetheless, programmers who want to use some special techniques not supported by the VCL still have that option in Delphi. The cover of the 4th edition of Essential Pascal,ĭelphi provides a complete encapsulation of the low-level Windows API using Object Pascal and the Visual Component Library (VCL), so it is rarely necessary to build Windows applications using plain Pascal and calling Windows API functions directly.
