I am writing a chat in Delphi using the client <-> server <-> client scheme. The task is as follows: you need to make the application blink when it is minimized and there is a new message , and only in this case. The problem is the same: the application does not blink. In neither case. Here is the code (Receiving a new message and turning on the blink timer (minimized is a global variable, the main operation with which in Timer4)

procedure TForm2.ClientSocket1Read(Sender: TObject; Socket: TCustomWinSocket); begin begin if minimized = 0 then Timer3.Enabled := False else Timer3.Enabled := True; Listbox1.Items.Add(Socket.ReceiveText); end; end; 

Timer3:

 procedure TForm2.Timer3Timer(Sender: TObject); var i:integer; begin if minimized = 0 then begin Timer3.Enabled := False; end; FlashWindow(Handle, True); FlashWindow(Application.Handle, True); end; 

Timer4:

 procedure TForm2.Timer4Timer(Sender: TObject); begin if IsIconic(Application.Handle) then begin minimized := 1; end else begin minimized := 0; end; end; 
  • Perhaps you just do not notice a single blink. Try using FlashWindowEx. In addition, the use of flashing for two windows at once is undesirable. Analyze the Application.MainFormOnTaskbar property and, depending on this, trigger the blinking or Form2.Handle or Application.Handle. - kami
  • Addition: timer 4 - redundant. The test carried out in it can be elementarily implemented in timer 3 and dispense with a global variable. - kami

1 answer 1

For blinking windows in the taskbar there are specials. function - FlashWindowEx

You can also play a sound, flash icon in the system tray, a pop-up window with a message, etc.