Hallo
Du könntest
Delphi-Quellcode:
IF indent = 0 THEN
BEGIN
Setforegroundwindow(aWnd);
sleep(200);
END;
durch ersetzen
Delphi-Quellcode:
IF indent = 0 THEN
WHILE NOT Setforegroundwindow(aWnd) DO
BEGIN
Application.ProcessMessages;
END;
allerdings muß das Fenster natürlich gefunden werden, sonst
gibt es eine Endlosschleife. Als eleganten Zusatz
(und zur Sicherheit!) kannst Du z.B. die Schleife ja nach
ca. 750ms oder so abbrechen ...
Bedenke, der Fokus Deiner App verschwindet trotzdem solange,
bis das Fenster durch Setforegroundwindow gesetzt wurde.
Auszug aus dem
PSDK:
Zitat:
The SetForegroundWindow function puts the thread that created the specified window into the foreground and activates the window. Keyboard input is directed to the window, and various visual cues are changed for the user. The system assigns a slightly higher priority to the thread that created the foreground window than it does to other threads.
Syntax
BOOL SetForegroundWindow( HWND hWnd
);
Parameters
hWnd
[in]
Handle to the window that should be activated and brought to the foreground.
Return Value
If the window was brought to the foreground, the return value is nonzero.
If the window was not brought to the foreground, the return value is zero.
...