Back to the principal form!

05-31-2005, 06:28 AM

I try but i can't do it. After some minutes in a form without any mouse move going back to the principal form.

Anyone can help me?

Thanks a lot!

05-31-2005, 06:52 AM
Have a timer control on the child form.
Define some time frame.
Reset the counter in the mousemove event of the form.
In the timer event check the counter.

Option Explicit

Private m_lStartTime As Long

Private Sub Form_Load()
' intialize counter offset
m_lStartTime = Timer
End Sub

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
' re-intialize counter offset
m_lStartTime = Timer
End Sub

Private Sub Timer1_Timer()
Dim lEndTime As Long

lEndTime = Timer
If lEndTime - m_lStartTime > 5 Then
' more then 5 secs of inactivity
Unload Me
' show time left
Me.Caption = 5 - Int(lEndTime - m_lStartTime)
End If
End Sub

06-01-2005, 04:13 AM

I try the code below and i understand that! But it still don't work 100%. See the problem:

1 - I have a from1 link to form2 link to form3, etc.
2 - Each form have a background picture and a label
3 - The goal is if no mouse move in form2 or form3...etc going back to form1
4 - The code works great if the mouse pointer is over the label. If there is over the form, it dosen't works!

I try to re-initialize the timer in the label, i try to delete the label,... but nothing! Where is the mistake?

Thanks a lot!

06-03-2005, 05:52 AM

I try many ways but i can't find a way... One thing i'm sure: the timer re-initialize on mouse move its iqual than the end time. So i can not reinitialize on mouse move!

Can anyone help me!


06-05-2005, 07:25 AM

Thanks to the Flyguy! The code works great! I finnaly found my error: i miss to unload the form before starts to show another one. I just unload the form behind and that's it!


EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum