Tag Archives: windows messages

Receive Windows Messages In Your Custom Delphi Class – NonWindowed Control/Object

Windows messages are a key ingredient in communication between Windows and (your) application and also in communication between (two) applications.

Even without your knowledge Windows messages are being posted and handled by forms in your application.

For example, when the user closes the form in your application, the WM_CLOSE message is sent to the window/form and the form gets closed (if you do not react programmatically).

For an application to receive a Window message, the application must provide a *window* a message will be sent to. In normal situation this window is the (main) form in your application. You write a procedure to handle a specific message, like WM_NCHitTest, and you are done.

BUT, what if you do NOT have a window to receive a message? What if you want to handle messages in your custom class derived from TObject?
Continue reading

Setting MaxLength for TListView’s Edit Control (Plus: Forcing Edit Mode Using a Keyboard Shortcut)

TListView Edit Item CaptionThe TListView Delphi control displays a list of items in a fashion similar to how Windows File Explorer displays files and folders.

The ReadOnly property of a List View, determines whether the user can modify the caption of an item. When ReadOnly is false, the OnEditing and OnEdited events occur when the user begins and finishes editing the list item, respectively.

At run time the user can click the selected item to enter the edit mode. Actually, two clicks (not double click) are needed: a click on an item to select it and then a second click to go to edit mode.

Here’s how to initiate the edit mode by a keyboards shortcut and also how to limit the number of characters for the TListView’s editor control.

Continue reading