.Net Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming Languages - More.Net Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 15th, 2003, 06:54 AM
Pain Pain is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Location: Sheffield, UK
Posts: 94 Pain User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 10
Send a message via ICQ to Pain
Fading forms into and out of sight

Hi guys

I've been working on the 'bells and whistles' of my project, and im trying to get my main form to fade into and out of sight, on a click on the icon which sits in the system tray.

I've set a timer (FaderTimer) to tick ever 100 miliseconds.

The code is as follows:
Private Sub NotifyIcon1_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles NotifyIcon1.MouseDown
FaderTimer.Enabled = True
End Sub

Private Sub FaderTimer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FaderTimer.Tick
If Me.Opacity >= 1 Then
Do Until Me.Opacity = 0
Me.Opacity = Me.Opacity - 0.1
Loop
Else
Do Until Me.Opacity = 1
Me.Opacity = Me.Opacity + 0.1
Loop
End If
FaderTimer.Enabled = False
End Sub

You'd think it would work. However it actually does nothing.
The form initially starts minimised, and no matter how much you click on the system icon, nothing happens.

I've played and tweaked and done all sorts of messing around - i even managed to get the error message to fade in and out!! (just dont ask how!), but cant it to work.

I presume that since the form starts minimised, I need to unminimise it. However the only way I know to do that would be to use Me.Show() -but surely that would bypass the fader completely?

Any ideas?

Cheers guys!

Reply With Quote
  #2  
Old October 15th, 2003, 06:57 PM
oni9 oni9 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Location: Brisbane, Australia
Posts: 50 oni9 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 10
Re: Fading forms into and out of sight

Quote:
Originally posted by Pain
Code:
Private Sub NotifyIcon1_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles NotifyIcon1.MouseDown
  FaderTimer.Enabled = True
End Sub

Private Sub FaderTimer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FaderTimer.Tick
  If Me.Opacity >= 1 Then
    Do Until Me.Opacity = 0
      Me.Opacity = Me.Opacity - 0.1
    Loop
  Else
    Do Until Me.Opacity = 1
      Me.Opacity = Me.Opacity + 0.1
    Loop
  End If
  FaderTimer.Enabled = False
End Sub


try change it to
Code:
private fading as boolean = false 'a class variable
Private Sub NotifyIcon1_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles NotifyIcon1.MouseDown
  fading = Me.Visible
  if not Fading then
    Me.Opacity = 0
    Me.Show()
  end if
  FaderTimer.Enabled = True
End Sub

Private Sub FaderTimer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FaderTimer.Tick
  if fading then
    if Me.Opacity >= 0.1 then
      Me.Opacity = My.Opacity - 0.1
    else
      me.hide()
      FaderTimer.Enabled = False
    end if
  else
    if Me.Opacity <= 0.9 then
      Me.Opacity = My.Opacity += 0.1
    else
      FaderTimer.Enabled = False
    end if
  end if
End Sub


did not test the code, straight typed here.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - More.Net Development > Fading forms into and out of sight

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap