![]() |
OnExit erigniss wird nicht ausgelöst beim deaktiven Fenster
Hallo.
TEdit.Color soll geändert werden, wenn das Focus das Feld verlässt. Kein Problem dachte ich mir dafür gibt es die Eigeschnaft. TEdit.OnExit(Sender); Das passiert aber nicht, wenn das TForm den Fokus verliert. z.B. Fenstergröße 100x100 wenn ich außerhalb dieses Fensterdrücke wir verliert das Fenster den Focus aber die Funkton TEdit.OnExit(Sender) wird nicht ausgelöst. Warum? :shock: |
Re: OnExit erigniss wird nicht ausgelöst beim deaktiven Fens
Weil das Edit auf der Form den Fokus behält. Aktivierst du das Fenster wieder, dann hat das Edit immernoch den Fokus. Das OnEnter/OnExit ist ja schliesslich kein Notify für ein Systemweiten Fokus (geschweige denn applikationsweiten Fokus).
|
Re: OnExit erigniss wird nicht ausgelöst beim deaktiven Fens
das habe ich mir schon gedacht. Wie kann ich das Problem lösen? Wenn das Fenster deaktiviert ist dann soll das E-Feld anders markiert werden.
TForm.onDeaktiv funktioniert nur dann wenn ich das Fenster schließe. :| |
Re: OnExit erigniss wird nicht ausgelöst beim deaktiven Fens
Hi,
ich habe mal ein Beispiel für eine Lösung mit einer extra Unit. Einfach ins Projekt aufnehmen und ausprobieren. Muss sicher für eigene Ansprüche noch angepasst werden.
Delphi-Quellcode:
Cu, Frank
unit EditColorHandler;
interface Uses Forms, Classes, Controls, Graphics, StdCtrls; Const _ActiveColor = $009BF5FD; _DefaultColor = clWhite; type TEditColorHandler = class(TObject) private FActiveControl: TWinControl; FActive: Boolean; procedure SetActive(const Value: Boolean); public procedure doActiveControlChange(Sender: TObject); property Active: Boolean read FActive write SetActive; end; Var AppEditColorHandler: TEditColorHandler; implementation procedure TEditColorHandler.doActiveControlChange(Sender: TObject); begin if Assigned(FActiveControl) and FActiveControl.HandleAllocated and (FActiveControl is TEdit) then TEdit(FActiveControl).Color := _DefaultColor; FActiveControl := Screen.ActiveControl; if FActiveControl is TEdit then TEdit(FActiveControl).Color := _ActiveColor; end; procedure TEditColorHandler.SetActive(const Value: Boolean); begin if FActive <> Value then begin FActive := Value; if FActive then Screen.OnActiveControlChange := doActiveControlChange else Screen.OnActiveControlChange := nil; end; end; initialization AppEditColorHandler := TEditColorHandler.Create; AppEditColorHandler.Active := True; finalization AppEditColorHandler.Free; end. |
Re: OnExit erigniss wird nicht ausgelöst beim deaktiven Fens
TTimer
IF not TForm.Active Then TEdit.Color := clWindow else e_TEdit.Color := clYellow; WANN funktioniert das Ereigniss ONDeATIV? :wall: |
Alle Zeitangaben in WEZ +1. Es ist jetzt 00:53 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz