Link to home
Start Free TrialLog in
Avatar of RAMCIT
RAMCIT

asked on

Timer Freezes (frozen) when user right clicks on title bar

Hello Experts,

We have a VB6 app that uses a timer that we use to track how long a user has been in that form.  This time is used for performance evaluation reasons so it must be as precise as possible.  Now, our crafty users have figured out two ways to stop the timer.  I have been able to eliminate the first way, but the second method has me stumped.  Here are the two ways to stop a timer:

1. The user left clicks and holds down on any of the buttons in the Control Box (Minimize, Maximize or Close) and the timer stops.  They then move the mouse away from the control box buttons and release the left mouse button; the timer resumes right from where it left off.

2. The user right clicks and holds down mouse button over any area of the title bar.  The timer stops and when they release, the timer resumes right from where it left off.

To correct the first problem, I simply set the Control Box property to false.  Now, I can't figure out how to correct the second problem.

I realize that I could just record the start time somewhere, then record the end time, do some math and voila, I have the time spent in the form.  But I really would like to know if there is a way to make an "unstoppable" timer.

Oh yeah, the user is also able to stop the timer by left clicking and holding the Close (X) button on any message box that appears.

Any help or ideas would be greatly appreciated.

Thanks!

RAMCIT
ASKER CERTIFIED SOLUTION
Avatar of cquinn
cquinn
Flag of United Kingdom of Great Britain and Northern Ireland image

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
Hi. Instead of timer, why don't you just use starting and ending time,
then substract the first from the other?
On Form's load event - get the start time
On Form's unload event - get the end time...

or something like this?
Avatar of vinnyd79
vinnyd79

Or use SetTimer / KillTimer API's:

http://support.microsoft.com/?kbid=180736
don't think you can do it may be you should hide the title bar too
Hi!

Put the timer on a new separate form. To call this form Load it from your main form, set the visible properity False.

Yuo can put there code to the timer call caption update on the form you have user with the mouse on the title bar.
Private Sub Timer1_Timer()
Form1.Label1.Caption = Now
End Sub

Remember unload this form when program end's.

Matti
Avatar of RAMCIT

ASKER

Everyone,

Thanks for the quick, and great, replies!!  Here are the responses:

cquinn:
That is actually pretty cool, but not exactly what I was looking for.  I need for the user to be able to see an actual ticking timer so they know how much time they have spent on a call.  Since the user will be occupied performing other tasks and talking to customers, I cannot display a start time and have them figure out how much time they have been on a call.  Your method is great for getting an exact time, but I also need them to see it real time; it's a psychological thing.

Julian_K:
I had already thought of that; I even stated it in the question.  I need an unstoppable timer.

vinnyd79:
I already tried the SetTimer/KillTimer API; It doesn't work.  The user is still able to stop the timer.

EDDYKT:
I cannot hide the title bar as well because then the user cannot move the form around the screen.  They use other apps and on occasion need to move the main app to see something behind it.

Matti:
Your solution, or a variation of it, might be the best work around if an unstoppable timer is not possible.  I can place the timer on another form with the border property set to None.  I can then show/hide it along with the load/unload events in the main form.  Not sure if it will work but I will give it a "last resort" shot.


Thanks again to everyone who replied.  I am not accepting anyone's answer right now because I want to see if it is possible to keep the timer going somehow.  It seems that all processes stop when the user clicks and holds the title bar of any form in the program.  I would think that there has to be a work around.

Thanks!

RAMCIT
Change the timer on the form to show the calculation from the GetTickCount cals every second - it doesn't matter if they stop the timer - it doesn't interfere with the calculated time, just stops it being displayed for a while - when it restarts it will jump forward to show the actual elapsed time

The following puts the number of seconds into the form caption

Private Sub Timer1_Timer()
Me.Caption = FormatNumber(GetElapsedTime(ttSeconds), 2) & " seconds"
End Sub
Avatar of RAMCIT

ASKER

cquinn, you are absolutely correct.  Sorry about that, I am half asleep.  Somehow I missed it.  It does exactly what I need it to do; an unstoppable clock.  Thank you!!!!
>>I cannot hide the title bar as well because then the user cannot move the form around the screen.  They use other apps and on occasion need to move the main app to see something behind it.


Anyway it is not true
Avatar of RAMCIT

ASKER

Hey EDDYKT,

I see that accessing the API it is possible to move a window without a title bar, however, I do not think that it is practical.  A window without a border gets very confusing to find when you have other windows open.  There is a reason that windows have a border and a title bar.  Additionally, your reply does not answer the question that I posted which was basically 'how can I create an unstoppable timer'.

Thanks anyways,

RAMCIT
Well I'm not argue anything.

The way you mention i don't think it can be done.

Also you already mention

>>I realize that I could just record the start time somewhere, then record the end time, do some math and voila, I have the time spent in the form.  But I really would like to know if there is a way to make an "unstoppable" timer.


I think you already know that is the best solution for you.

>>Additionally, your reply does not answer the question that I posted which was basically 'how can I create an unstoppable timer'.

My answer:don't think you can do it may be you should hide the title bar too

What's wrong on that?
Never mind. Just comments

8->
Avatar of RAMCIT

ASKER

Hey EDDYKT,

Thanks for the comments, I really appreciate it.  And just for FYI purposes:

>>The way you mention i don't think it can be done.

What I was looking to do can be done.  The solution proposed by cquinn was exactly what I was looking for.  His solution creates an 'unstoppable' timer.  The user can click anywhere they want and the timer will visually stop, but it keeps on ticking in the background.  So when the user releases the mouse button, all of the time elapsed while they were holding the mouse button will be added to the time displayed.  This is an unstoppable timer.


>> I think you already know that is the best solution for you.

It is a great solution with one flaw, it does not display a ticking timer.

>>My answer:don't think you can do it may be you should hide the title bar too
>>What's wrong on that?

There is nothing wrong with hiding the toolbar; I actually do that for certain situations.  I just mentioned that it does not answer my question.

Thanks again for your time.  I consider all comments helpful.

RAMCIT