• Timer Event

    Author
    Topic
    #465393

    Hi

    I need to add a timer event on a form.
    I use a PDF control and need to refresh it every hour or so.
    The PDF control looks at a specific PDF document in a network folder.
    If I change the PDF document and want the users to see it without intervention, I have to go to each machine and restart the application.
    This would be more beneficial if a timer could refresh the PDF code so If I change the PDF Doc it would load.

    The PDF doc is on the server called “PDFViewer.pdf”, its just a word doc with workshop information really, so if I change the doc the users can see anything I want them to.
    I’ve looked at a couple of examples on the web but not much success.
    I have a .CTL called “Inactive.ctl” but I cant register it, maybe someone has a good example or something I can use.
    The above “Inactive.ctl” is ideal which only triggers a change on form inactivity.

    Viewing 2 reply threads
    Author
    Replies
    • #1196752

      What are you using for a programming environment?

      If it’s any form of VB or any .Net environment, adding a timer control to the same form that hosts the PDF control and placing the refresh code in the timer event handler should be trivial.

    • #1196909

      Hi Mark

      Apologies, the project is VB6.

      The timer doesn’t seem too much of an issue, but it’s the inactivity that is important.
      I can set the timer to fire and refresh every hour or so but I don’t want the refresh if the user is using the form.

      I found this example:
      http://www.vb-helper.com/howto_inactive_timeout.html Inactive
      Which is ideal for my purpose, but I just can’t register the control and the instructions are not forthcoming.
      Maybe I’m missing something, any help would be very very useful.

      Again, thanks for the reply.

    • #1197453

      Ah, getting an obstinate ActiveX control to register properly, that’s a whole other kettle of fish. If using this ‘Inactive’ timer is your only solution, I’m afraid I can’t help much.

      Meanwhile, a couple of thoughts that may yield a workaround allowing you to dispense with this fancy timer. I assume we’re dealing with a simple program with a single form and fairly little beyond the PDF control and this form stays active more-or-less all the time (hence you have to do all this refreshing). If I’m missing something, enlighten me.

      Thought 1: Never refresh unless requested by the user. In your timer event, poll the file and look for a change (i.e. Date Last Modified). Place a refresh button on the form and turn it some garish color (red on an orange background always irritates) when a change is detected. Do your actual reload in the button click event.

      Thought 2: Make your own decision on what constitutes ‘inactive’. Track click events on *every* control and decide if things are idle enough only when time has elapsed (say 5 minutes) when *nothing* has been clicked on, or the form is minimized, or something similar. Reading the system timer is fairly easy in VB6 as memory serves. Just account for midnight rollover.

      Thought 3: If you can poll the file itself and check for any actual change, refresh whether the form is active or not but *only* when the PDF has actually been updated. Would the effect be all that unpleasant?

      My memory of the VB6 APIs is a bit faded. I’m afraid I drank the cool aid and migrated to .Net some time ago. But I think all of the above would be easier than wrestling with an alien ActiveX control and you wouldn’t have to worry about a piece of code in your application that you can’t vouch for.

      Good luck. Let me know how it goes.

    Viewing 2 reply threads
    Reply To: Timer Event

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: