Is there an alternative to the OnChange event that is raised on any action in Delphi?

From the Delphi XE documentation:-

Note: OnChange only occurs in response to user actions. Changing the Text property programmatically does not trigger an OnChange event.

Are there any other events available for TComboBox that are raised when any change happens (by the user or programmatically)? When changing the ItemIndex property of the TComboBox no event is raised.

Answers


The combo box control is sent a CM_TEXTCHANGED when the text is modified. The VCL control chooses not to surface an event here, but you could. There's many ways to do so. Here I illustrate the quick and dirty interposer class:

TComboBox = class(Vcl.StdCtrls.TComboBox)
  procedure CMTextChanged(var Message: TMessage); message CM_TEXTCHANGED;
end;

procedure TComboBox.CMTextChanged(var Message: TMessage);
begin
  inherited;
  Beep;
end;

Naturally you would want to do this in a less hacky way in your production code.


Need Your Help

Calling an overridden and frozen function

javascript

I'm building a security framework which injects a javascript file which will always be executed first, and blocks some functions to be executed.

Combine two columns in one column

mysql sql

I have column 1 and column 2, and want to combine them into column 3 of the same table. If the column 2 is null then display column 1 value, if column 1 is null, them display column 2 data. If both...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.