vb.net – 如何确定winform上的不活动

前端之家收集整理的这篇文章主要介绍了vb.net – 如何确定winform上的不活动前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我有一个winform,显示在我的应用程序的顶部.我想要的是将表单设置为20%不透明度,如果它在一段时间内处于非活动状态.现在我点击按钮时会运行类似的事件,表单的大小会发生变化.我在执行转换时使用计时器设置窗体不透明度.我现在可以使用类似的代码来设置不透明度,如果表单上有不活动,我只是不知道如何检测不活动.

这就是我所拥有的.

  1. Private Sub btnShowForm_Click(sender As Object,e As EventArgs) Handles btnShowForm.Click
  2.  
  3. 'This procedure runs when the btnShowForm
  4. 'button is clicked. The procedure maximizes the size
  5. 'of the form,hides the left right button and displays the button
  6. 'to expand the form. It also moves the comboBox down.
  7. 'It calls the viewButtons function to hide and
  8. 'display the right buttons.
  9. 'The procedure also uses a timer to set the fade in and out the
  10. 'form when is min or max
  11.  
  12. Me.Height = 126
  13.  
  14. Me.Opacity = 0.2 'About 20%
  15. timNavigationPage.Interval = 100 'about one-tenth of a second
  16. timNavigationPage.Start() 'Start the timer
  17.  
  18.  
  19. cmbViewDataSheets.Location = New Point(741,89)
  20.  
  21.  
  22. viewButtons(False,True)
  23.  
  24. End Sub
  25.  
  26. Private Sub timNavigationPage_Tick(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles timNavigationPage.Tick
  27.  
  28. 'Initialize the timer to fade form.
  29.  
  30. Dim x As Double = 0.075
  31.  
  32. If Me.Opacity <= 1 Then
  33. Me.Opacity += x 'increment opacity with 7.5%
  34.  
  35. ElseIf Me.Opacity + x > 1 Then
  36. timNavigationPage.Stop() 'Stop the timer then the opacity has reached a 100%
  37.  
  38. End If
  39.  
  40. End Sub
这是一个很棒的 example,使用user32.dll的GetLastInputInfo

猜你在找的VB相关文章