By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,872 Members | 2,333 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,872 IT Pros & Developers. It's quick & easy.

Screen Saver

Ali Rizwan
100+
P: 927
Hi
I want to do something like screensaver.
If there is no mouse movemeent for a while then a form will appear.
I m using vb6.
Thanx
Sep 3 '07 #1
Share this Question
Share on Google+
2 Replies


QVeen72
Expert 100+
P: 1,445
Hi,

First Declare one FormLevel Variable (at the top of form's Code window). Add a "Timer Control", Make Forms property KeyPreView =True ;
Set Timer's Interval =1000 ( 1 second)
and use this code

Expand|Select|Wrap|Line Numbers
  1. Dim ETime As Long
  2.  
  3. Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  4.     ETime = 0
  5. End Sub
  6.  
  7. Private Sub Form_KeyPress(KeyAscii As Integer)
  8.     ETime = 0
  9. End Sub
  10.  
  11. Private Sub Timer1_Timer()
  12.     ETime = ETime + 1
  13.     If ETime >= 300000 Then
  14.         ' 300000 = 5 Mins Change this Accordingly
  15.         Timer1.Enabled = False
  16.         ETime = 0
  17.         frmScreenSaver.Show 1
  18.     End If
  19. End Sub
  20.  

In Unload /Terminate event of frmScreenSaver:
Make : Form1.Timer1.Enabled =True


REgards
Veena
Sep 3 '07 #2

Ali Rizwan
100+
P: 927
Hi,

First Declare one FormLevel Variable (at the top of form's Code window). Add a "Timer Control", Make Forms property KeyPreView =True ;
Set Timer's Interval =1000 ( 1 second)
and use this code

Expand|Select|Wrap|Line Numbers
  1. Dim ETime As Long
  2.  
  3. Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  4.     ETime = 0
  5. End Sub
  6.  
  7. Private Sub Form_KeyPress(KeyAscii As Integer)
  8.     ETime = 0
  9. End Sub
  10.  
  11. Private Sub Timer1_Timer()
  12.     ETime = ETime + 1
  13.     If ETime >= 300000 Then
  14.         ' 300000 = 5 Mins Change this Accordingly
  15.         Timer1.Enabled = False
  16.         ETime = 0
  17.         frmScreenSaver.Show 1
  18.     End If
  19. End Sub
  20.  

In Unload /Terminate event of frmScreenSaver:
Make : Form1.Timer1.Enabled =True


REgards
Veena
Thanks for this code its easyone why not it comes into my mind.
my mind is too slow i have to change battery.
thanxxxxx
Sep 4 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.