Link to home
Start Free TrialLog in
Avatar of sacul
sacul

asked on

Form Opacity

Hello Experts,

I have a simple question. Is there a way to set the opacity on a windows form based on its focus? I have an app with multiple forms and I would like to set the opacity to 60% if the form is out of focus and then re-set it to 100% again once it gain focus. Is this doable?

Thank you,
Zac
ASKER CERTIFIED SOLUTION
Avatar of Kinger247
Kinger247

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Kinger247
Kinger247

Thats the forms Gotfocus/Lostfocus events.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of sacul

ASKER

Hello,

I have never used the Timer before. Can you explain how I can use it? I will up the points a bit for the extra effort.

Thank you,
Zac
Do you really want a timer ?  looks a bit drastic to me.
IMHO, I'd stick to just having it semi visible.
The timer control has a tick event in which you add the loop code.
I would have thought that anyone would can be bothered to change the opacity of the form when it loses or regains focus is someone who cares about the "user experience" and would want to see a fade up or down.
Thats fine on systems that can handle it :)
But never asume all can. Otherwise you'll create a negative user experience.
Avatar of sacul

ASKER

Hello,

This app is only for the IT team at our company and we all make sure we have the meanest machines :)

I am curious though,how do I use a timer?
you create a timer like this:

    Private WithEvents TMR As New Timers.Timer

start it like this:

        TMR.Interval = 1000      '//-- 1 second intervals.
        TMR.Enabled = True        

and catch the events like this:

    Private Sub TMR_Elapsed(ByVal sender As Object, ByVal e As System.Timers.ElapsedEventArgs) Handles TMR.Elapsed
        '//-- your code
    End Sub

and stop the timer like this:

TMR.Enabled = False
And there I thought that Mr. Kinger thought the timer was a bit drastic.
It is, but thats not the question ! :)

As long as you know your target audience can handle it then its fine ;)

and its Friday ....
Avatar of sacul

ASKER

Hello,
Sorry for the delay in answer. I still have trouble using the Gotfocus/Lostfocus I try to handle it but it seems to give me grief. If I have a form that with a click of a button opens up another form, I should be able to get and lose focus between the forms right? I am just not sure how to handle the GotFocus/LostFocus event.

Thank you,
Zac
Avatar of sacul

ASKER

Hello,

I will re-ask the question about how to use GetFocus/LostFocus.


Thank you for all the help.

Zac