| Autor |
Beitrag |
Andreas H.
Hält's aus hier
Beiträge: 12
|
Verfasst: Mo 05.12.05 07:46
Hallo,
kurz und knapp: wie kann ich fetstellen, ob meine Anwendung (Form1:TForm) den Fokus verliert. Ich möchte dann die Anwendung schließen.
Ereignisse, wie TForm1.FormDeactivate werden nicht ausgelöst.
Ich setze die Personal-Edition von Delphi ein.
Gruß Andreas
|
|
digi_c
      
Beiträge: 1905
W98, XP
D7 PE, Lazarus, WinAVR
|
Verfasst: Mo 05.12.05 08:15
OnDeactivate wird aufgerufen, wenn das Fenster abgebaut wird, sprich vor dem schließen.
Das sauberste wäre eine Windowsmessage abzufangen, wie die beim Fokusverlust heißt, weiß ich nicht.
Oder du baust einen Timer, der beim Erreichen eines Zeitlimits deine App schließt. Und der Timer wird zurückgesetzt wenn sich die Maus bewegt oder ein Controll den Fokus verliert...
|
|
Andreas H. 
Hält's aus hier
Beiträge: 12
|
Verfasst: Mo 05.12.05 10:18
Der Timer wäre keine Lösung. Die Anwendung soll nur geschlossen werden, wenn sie den Fokus verliert.
|
|
digi_c
      
Beiträge: 1905
W98, XP
D7 PE, Lazarus, WinAVR
|
Verfasst: Mo 05.12.05 12:38
Wie gesagt per Windows Message. Da bist du im Win32API Topic am sichersten aufgehoben.
|
|
alias5000
      
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)
|
Verfasst: Mo 05.12.05 12:53
vllcht hilft dir das weiter, ich habs aus der Platform SDK von Microsoft.
| Zitat: |
WM_ACTIVATE Notification
--------------------------------------------------------------------------------
The WM_ACTIVATE message is sent to both the window being activated and the window being deactivated. If the windows use the same input queue, the message is sent synchronously, first to the window procedure of the top-level window being deactivated, then to the window procedure of the top-level window being activated. If the windows use different input queues, the message is sent asynchronously, so the window is activated immediately.
Syntax
WM_ACTIVATE
WPARAM wParam
LPARAM lParam;
Parameters
wParam
The low-order word specifies whether the window is being activated or deactivated. This parameter can be one of the following values. The high-order word specifies the minimized state of the window being activated or deactivated. A nonzero value indicates the window is minimized.
WA_ACTIVE
Activated by some method other than a mouse click (for example, by a call to the SetActiveWindow function or by use of the keyboard interface to select the window).
WA_CLICKACTIVE
Activated by a mouse click.
WA_INACTIVE
Deactivated.
lParam
Handle to the window being activated or deactivated, depending on the value of the wParam parameter. If the low-order word of wParam is WA_INACTIVE, lParam is the handle to the window being activated. If the low-order word of wParam is WA_ACTIVE or WA_CLICKACTIVE, lParam is the handle to the window being deactivated. This handle can be NULL.
Return Value
If an application processes this message, it should return zero.
Remarks
If the window is being activated and is not minimized, the DefWindowProc function sets the keyboard focus to the window. If the window is activated by a mouse click, it also receives a WM_MOUSEACTIVATE message.
Notification Requirements
Minimum DLL Version None
Header Declared in Winuser.h, include Windows.h
Minimum operating systems Windows 95, Windows NT 3.1
See Also
Keyboard Input Overview, DefWindowProc, SetActiveWindow, WM_MOUSEACTIVATE, WM_NCACTIVATE
--------------------------------------------------------------------------------
© 2005 Microsoft Corporation. All rights reserved.
|
du müsstest die Message dann nur noch mit Delphi-Quelltext 1: 2: 3: 4:
| interface ... Procedure Deactivate; message WM_ACTIVATE; ... |
einbinden. aber achtung! WM_ACTIVATE kommt beim Aktivieren und Deaktivieren. Wie du's unterscheiden kannst siehst du ja oben.
Ich hoffe dir hilfts weiter
_________________ Programmers never die, they just GOSUB without RETURN
|
|
Andreas H. 
Hält's aus hier
Beiträge: 12
|
Verfasst: Mo 05.12.05 13:41
Hi,
hört sich gut an! Und gleich was gelernt!
Werde es gleich probieren. Danke
Andreas
|
|
|