Autor Beitrag
alias5000
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2145

WinXP Prof SP2, Ubuntu 9.04
C/C++(Code::Blocks, VS.NET),A51(Keil),Object Pascal(D2005PE, Turbo Delphi Explorer) C# (VS 2008 Express)
BeitragVerfasst: Fr 03.03.06 19:15 
Hi!
Ich mach jetzt hier schon ne Weile an meinem Programm rum, bei dem folgendes wohl nicht ganz funtzt:

Ich merke mir über Application.OnActivate und OnDeactivate, ob die Anwendung den Fokus hat oder nicht (boolean Variable, iss ja logisch :wink: )

Blöderweise funktioniert dies irgendwie nicht, obwohl der entscheidende Codeteil sowas von richtig ist...

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
procedure TMainForm.ApplicationEvents1Activate(Sender: TObject);
begin
AppActivated := true;
MainForm.OnAppRestore(Sender);
end;

procedure TMainForm.ApplicationEvents1Deactivate(Sender: TObject);
begin
Main.AppActivated := false;
end;


Es ist einfach so, dass die Variable AppActivated irgendwie bei einer Abfrage trotz fehlendem Anwendungsfokus immer true ist. Die Variable wurde auch schon öfters gesetzt, kann also nicht sein, dass sie einen undefinierten Startwert trägt.


Jetzt halt die Frage, ob ihr noch ne andere Lösung kennt, z.B., ob man mit der Windows API abfragen kann, ob die Anwendung den Fokus hat.

Danke!

Gruß alias5000

_________________
Programmers never die, they just GOSUB without RETURN
netspy
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 75



BeitragVerfasst: Fr 03.03.06 19:26 
Reicht dir nicht die Eigenschaft 'Active' vom Hauptformular?
alias5000 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2145

WinXP Prof SP2, Ubuntu 9.04
C/C++(Code::Blocks, VS.NET),A51(Keil),Object Pascal(D2005PE, Turbo Delphi Explorer) C# (VS 2008 Express)
BeitragVerfasst: Fr 03.03.06 20:32 
niente
Es geht darum, herauszufinden, ob die Anwendung, den Fokus hat und nicht das Hauptformular.
Das ist genau deswegen so wichtig, da die Hauptfunktionen nicht auf dem Hauptformular sind, allerdings sowohl das Hauptformular, also auch die zusätzliche Form meistens beide angezeigt werden, aber halt nur meistens.

Bisher hat meine PSDK-Recherche nix ergeben, aber ich hab ehrlich gesagt auch keinen wirklichen Schimmer, nach was ich suchen soll...(vllcht find ich ja noch was)

Gruß alias5000

_________________
Programmers never die, they just GOSUB without RETURN
netspy
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 75



BeitragVerfasst: Fr 03.03.06 22:02 
Dann teste doch einfach, ob bei einem der beiden Formulare Active gleich True ist. Ansonsten sollte Application.Active auch reichen.
alias5000 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2145

WinXP Prof SP2, Ubuntu 9.04
C/C++(Code::Blocks, VS.NET),A51(Keil),Object Pascal(D2005PE, Turbo Delphi Explorer) C# (VS 2008 Express)
BeitragVerfasst: Fr 03.03.06 22:16 
ja das muss ich mal testen :)
aber nicht mehr heute

_________________
Programmers never die, they just GOSUB without RETURN
alias5000 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2145

WinXP Prof SP2, Ubuntu 9.04
C/C++(Code::Blocks, VS.NET),A51(Keil),Object Pascal(D2005PE, Turbo Delphi Explorer) C# (VS 2008 Express)
BeitragVerfasst: Sa 25.03.06 18:10 
Also Problem ist gelöst, es wurde einfach zur falschen Zeit ein SetFocus bei einer Koponente gesetzt.
Danke für die Hilfe!

_________________
Programmers never die, they just GOSUB without RETURN