Results 1 to 8 of 8

Thread: [2005] How to set applications opacity to 75% after application is inactive for 30sec

Hybrid View

  1. #1
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: [2005] How to set applications opacity to 75% after application is inactive for 30sec

    Quote Originally Posted by Lerroy_Jenkins
    Can you please expand on that code a little penagate? I dont understand what is happening.
    The KeyPreview property of the form allows it to receive keyboard events before its controls do.
    AddHandler is a VB.NET statement used to attach an event handler to a particular event.

  2. #2
    Hyperactive Member
    Join Date
    Dec 2004
    Posts
    326

    Re: [2005] How to set applications opacity to 75% after application is inactive for 30sec

    Code:
    Dim isActive As Boolean = True
    Dim tick As Integer = 0
    
    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
            If tick = 30 Then
                ChangeStatus()
            Else
                tick = tick + 1
            End If
        End Sub
    
        Private Sub ChangeStatus()
    
            If isActive = False Then
                isActive = True
                Timer1.Enabled = True
                Me.Opacity = 1
                tick = 0
            Else
                Timer1.Enabled = False
                isActive = False
    
                Me.Opacity = 0.25
    
            End If
        End Sub
    
    'Two resetTicks sub for different control signatures
        Private Sub ResetTick(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs)
            tick = 0
            If isActive = False Then
                ChangeStatus()
            End If
        End Sub
    
        Private Sub ResetTick(ByVal sender As System.Object, ByVal e As System.EventArgs)
            tick = 0
            If isActive = False Then
                ChangeStatus()
            End If
        End Sub
    
        Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            Me.KeyPreview = True
            AddHandler Me.KeyPress, AddressOf ResetTick
            AddHandler Me.Click, AddressOf ResetTick
    
            For Each c As Control In Me.Controls
                AddHandler c.Click, AddressOf ResetTick
            Next
        End Sub
    Thank you Penagate for teaching me something

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width