Board index » delphi » TCustomForm.ActiveChanged doesn't fire every time when ActiveControl changes

TCustomForm.ActiveChanged doesn't fire every time when ActiveControl changes

I try using the protected method TCustomForm.ActiveChanged to get notified
when ActiveControl changes, but it is only fired if i change the active page
in a pagecontrol. Changing the focus of controls in a tabsheet never fires
this method.

Here is the code :

type
  TForm1 = class(TForm)
    .
    .
    .
    protected
      procedure ActiveChanged; override;
  end;

implementation

procedure TForm1.ActiveChanged;
begin
  inherited;

  if assigned (ActiveControl) then StatusBar1.SimpleText :=
ActiveControl.Name;
end;

 

Re:TCustomForm.ActiveChanged doesn't fire every time when ActiveControl changes


Quote
In article <8ub7ek$2mr$0...@news.t-online.com>, Michael Adamovic wrote:
> I try using the protected method TCustomForm.ActiveChanged to get notified
> when ActiveControl changes, but it is only fired if i change the active page
> in a pagecontrol. Changing the focus of controls in a tabsheet never fires
> this method.

The focus tracking code in the forms unit is complex and seems to
be inconsistent in some parts, perhaps due to changes made from one
Delphi version to another. If you want to track focus changes use either the
Screen.onActiveControlchange event or add a handler for the CM_FOCUSCHANGED
message to the form.

Peter Below (TeamB)  100113.1...@compuserve.com)
No e-mail responses, please, unless explicitly requested!

Re:TCustomForm.ActiveChanged doesn't fire every time when ActiveControl changes


Thank you very much.

Normally I watch out for other possibilities to get what I need, but in this
case I couldn't imagine that another component, in this case TScreen,
handles focus changing in a form.

Michael Aaamovic

Peter Below (TeamB) <100113.1...@compuXXserve.com> schrieb in im
Newsbeitrag: VA.00006243.00ee7...@antispam.compuserve.com...

Quote
> In article <8ub7ek$2mr$0...@news.t-online.com>, Michael Adamovic wrote:
> > I try using the protected method TCustomForm.ActiveChanged to get
notified
> > when ActiveControl changes, but it is only fired if i change the active
page
> > in a pagecontrol. Changing the focus of controls in a tabsheet never
fires
> > this method.

> The focus tracking code in the forms unit is complex and seems to
> be inconsistent in some parts, perhaps due to changes made from one
> Delphi version to another. If you want to track focus changes use either
the
> Screen.onActiveControlchange event or add a handler for the
CM_FOCUSCHANGED
> message to the form.

> Peter Below (TeamB)  100113.1...@compuserve.com)
> No e-mail responses, please, unless explicitly requested!

Other Threads