Autor Beitrag
theChaoS
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 38



BeitragVerfasst: Do 19.03.09 18:55 
Hallo ich versuche Grade mein Formular dazu zu bringen das es auf ein Signal hin in der Taskleiste blinkt. Allerdings nur dan wen es nicht "sichtbar" ist d.H. nicht grad das Programm ist was angekligt ist.

Das blinken realisire ich mit einem Timer der eine WinAPI Funktion auffruft
ausblenden Delphi-Quelltext
1:
2:
  FlashWindow(Handle, True);            
  FlashWindow(Application.Handle, True);

aber wie krig ich den dazu nur zu blinken wen das Formular NICHT ausgewählt wurde (und auffhört wen es ausgewählt wurde ^^) ???

Moderiert von user profile iconNarses: Delphi-Tags hinzugefügt
Regan
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 2157
Erhaltene Danke: 72


Java (Eclipse), Python (Sublimetext 3)
BeitragVerfasst: Mo 13.04.09 18:09 
Moin,

ich würde dir folgende Variante empfehlen. Habe ich auch schon selbst probiert und funktioniert:
ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
type
  TFlashWInfo = record
    cbSize : LongInt;
    hWnd : LongInt;
    dwFlags : LongInt;
    uCount : LongInt;
    dwTimeout : LongInt;
  end;

var
  flashing: Boolean;
{...}
procedure TForm1.Timer1Timer(Sender: TObject);
begin
  if (GetForeGroundWindow()<>Form1.Handle) then
    begin
      FWinfo.cbSize := 20;
      FWinfo.hwnd := Application.Handle;
      FWinfo.dwflags := FLASHW_ALL;
      FWinfo.ucount := 5;
      FWinfo.dwtimeout := 0;
      Flashing := True;
      FlashWindowEx(FWinfo);
    end
  else if (Flashing) then
    begin
      FWinfo.cbSize := 20;
      FWinfo.hwnd := Application.Handle;
      FWinfo.dwflags := FLASHW_STOP;
      FWinfo.ucount := 0;
      FWinfo.dwtimeout := 0;
      FlashWindowEx(FWinfo);
      Flashing := false;
    end;
end;

//I have also put some code in the Form's onPaint event to stop the flashing:

procedure TForm1.FormPaint(Sender: TObject);
begin
  if (Flashing) then
    begin
      FWinfo.cbSize := 20;
      FWinfo.hwnd := Application.Handle;
      FWinfo.dwflags := FLASHW_STOP;
      FWinfo.ucount := 0;
      FWinfo.dwtimeout := 0;
      FlashWindowEx(FWinfo);
    end;
end;

Infos zu den dwflags:
Zitat:

FLASHW_STOP = 0 // Stop flashing
FLASHW_CAPTION = 1 // Flash the window caption
FLASHW_TRAY = 2 // Flash the taskbar button
FLASHW_ALL = 3 // Flash both the window caption and taskbar button
FLASHW_TIMER = 4 // Flash continuously, until the FLASHW_STOP flag is set
FLASHW_TIMERNOFG = 5 // Flash continuously until the window
// comes to the foreground


#Quelle

MfG
Regan
theChaoS Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 38



BeitragVerfasst: Sa 18.04.09 21:17 
Ahhh den Post hab ich ja follkommen vergessen ;D

naja egla meine Lösung is schon ca. 3 Wochen allt ^^ aber funktionirt recht gut.
Ich post das hier mal falls jemmand nach einer antwort sucht ;D

also:
ich hab mir 2 Timer geschnapt
Nummero 1 hab ich auf 1 ms speed gestellt (1 ^^) dan hab ich das ding mit folgenden code bestückt
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
if GetForegroundWindow<>Form1.Handle then     
begin
    timer2.enabled:=true;
end
  ELSE
begin
    timer2.Enabled:=false;
end;

Also ich hab einfach verglichen ob das Fenster im Vordergrund meins ist ansonsten löst der timmer den zweiten timmer aus der
ausblenden Delphi-Quelltext
1:
2:
  FlashWindow(Handle, True);            
  FlashWindow(Application.Handle, True);

Dann das Fenster zum Blinken brinngt ^^
Der zweite timmer sollte nicht zu schnell eingestellt sein sonst siht man den effekt nicht