Make a screen blink / flash to alert user

妖精的绣舞 提交于 2019-12-10 15:25:10

问题


Using .NET 3.5 Winforms, How would i make the entire screen flash/blink between red and white for just a second.

I have a big screen that's only meant to show status on monitored equipment. I would like it to flash as a notification to users when an event occurs that they should be looking at.

Thank you


回答1:


Use what tbischel has suggested. Here is some sample code for the timer.

Private TickCount As Integer = 0
Private Const NUMBER_OF_SECONDS As Integer = 1

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
    Me.BackColor = If(Me.BackColor = Color.White, Color.Red, Color.White)
    TickCount += 1

    If TickCount >= NUMBER_OF_SECONDS * 1000 / Timer1.Interval Then
        Timer1.Stop()
        Me.BackColor = Color.Gray
        Me.TopMost = False
        Me.WindowState = FormWindowState.Normal
    End If
End Sub

It will alternate between Red and White and whatever interval you specify for your timer. It will stop after how ever many seconds you give it. When it is done it sets the color to grey, removes the .TopMost flag and sets the WindowState back to normal.

Having said that; it's really annoying :)




回答2:


you could create a blank maximized form with the FormBorderStyle set to FormBorderStyle.None, and set the background color on a timer.



来源:https://stackoverflow.com/questions/5943841/make-a-screen-blink-flash-to-alert-user

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!