|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Refresh form so 'not responding' does not appearThe VB6 form processing data for updating db takes too long, so I included a
progress bar for informing user for the status. If user moves to other programs and then back to my program, form is not refreshed while theoretically progress bar is updated and 'not responding' may be given. How can refresh form so progress bar is refreshed when is updated ? I am refreshing form every time I update progress bar. Thanks a lot in advance. "chris" <ch***@discussions.microsoft.com> wrote in message Presumably you're running the updating code in a closed loop and you are news:CF99E34C-CBB6-4866-8F31-73262016C835@microsoft.com... > The VB6 form processing data for updating db takes too > long, so I included a progress bar for informing user for > the status. If user moves to other programs and then back > to my program, form is not refreshed while theoretically > progress bar is updated and 'not responding' may be given. > How can refresh form so progress bar is refreshed when > is updated ? I am refreshing form every time I update > progress bar. updating the progress bar periodically within that loop? If so then place a DoEvents in the loop, which will fix the "not responding" problem. You should not update the progress bar nor use DoEvents more often than nenessary, so if you are currently doing it at every iteration of the loop then perhaps you might consider adding an extra variable to hold the time of the last update, so that within the loop you can check the elapsed time since the time of the last update and only perform another update if a specific time period has elapsed, updating the contents of the variable to the new current time as you do so. Half a dozen times per second should be plenty. If the loop is fast running (if it executes tens of thousands of times per second or more) then use a timer that is quick to check, so that the minimum amount of the overall time is spent checking it each time. Some timers take a microsecond or more to check whereas others take just ten nanoseconds or so. On my machine, for example, GetTickCount is the fastest, taking just 10 nanoseconds, which is twice as fast as timeGetTime, twenty times faster than the VB Timer function and over a hundred times faster than QueryPerformanceCounter. The resolution of GetTickCount is easily high enough for your purposes, and it is very quick, so that is what I suggest you use if the loop is very fast running. Mike Yes, my loop may be executed 5 million times or more, depending on the data
to be read and updated. I increase progress bar by 1 (max is 100), so is executed 100 times, use variable for counting data read, divide data to be read by 100. I included DoEvents in this procedure, so it will also be executed 100 times. Thanks a lot. "chris" <ch***@discussions.microsoft.com> wrote in message Add a DoEvents statement somewhere. Depending on exactly what you're doing, news:CF99E34C-CBB6-4866-8F31-73262016C835@microsoft.com... > The VB6 form processing data for updating db takes too long, so I included > a > progress bar for informing user for the status. If user moves to other > programs and then back to my program, form is not refreshed while > theoretically progress bar is updated and 'not responding' may be given. > > How can refresh form so progress bar is refreshed when is updated ? I am > refreshing form every time I update progress bar. > you might need more than one. What's happening is that your app is busy doing the db update (and whatever else). Screen redraws are a very low priority so if your app is busy (for example, in a loop) while you need to update forms or other screen elements, you need to specifically grant Windows time to do that. The Refresh method of forms and controls frequently is not sufficient whereas DoEvents gives Windows the time in needs to do other things besides just refresh a specific form or control. However, you don't want to overdo your use of DoEvents either because it could cause whatever you're doing to take longer (sometimes considerably longer). -- Mike
How to get special Appdata folder
VB6 runtime is supported on Windows 7 Printing PictureBox Contents ListBox color FYI: MS UK VB6 Usage survey/poll - update What am I doing wrong Crash during compile Shared MS Fax Problem getting the date of a running EXE file Add objects already on form to Groupbox |
|||||||||||||||||||||||