Repaint during prolonged task 
Author Message
 Repaint during prolonged task

Does anyone know how to force the screen to repaint during a prolonged
processing loop ?

I'm searching a database engine while printing lines generated from filtered
queries.
it may take many minutes to generate enough for one page. It seems that the
CDC.EndPage() forces the repainting OK, but I need to do it more frequently.
My innermost Get loop is executed sufficiently frequently, so if I could
force a repainting there it would be fine. The effect of not repainting is
that other applications (eg explorer, print control) when dragged across the
screen leave unpainted areas.

I have tried:
  while (::PeekMessage(&msg,NULL,0,0,PM_NOREMOVE) )
         AfxGetThread() -> PumpMessage();

and:
  while ( ::PeekMessage(&msg,NULL,WM_PAINT,WM_PAINT,PM_NOREMOVE) )
         ::DispatchMessage(&msg);

and:
  while ( ::PeekMessage(&msg,NULL,WM_PAINT,WM_PAINT,PM_NOREMOVE) )
       ::SendMessage(NULL, msg.message, msg.wParam, msg.lParam);

The last of which hangs the application.

I presume the problem is due to WM_PAINT's  staying in the message queue or
to Dispatch/SendMessage's inability to force repainting while the
application is in a loop.

The application is MFC-based, VC6, single threading.
I have a typical abort procedure in place getting its cancel message from a
modeless dialog which is PeekMessaging - PumpMessaging to get its abort
button read. This seems to be alright as its used elsewhere in other
non-time-intensive printing tasks, although obviously it's not getting read
here, but that's not the main problem. It is the screen non-repainting which
I need to resolve.

Can anyone tell me how to do it?

Thanks,

David.



Wed, 26 Sep 2001 03:00:00 GMT  
 Repaint during prolonged task
David:

I would have thought that some version of the PeekMessage/PumpMessage idea would
do what you want. Where are you putting this code?

But if you are only concerned about WM_PAINT messages, can you not just call
UpdateWindow() in your inner loop? If the update region is empty this will have
no effect, but if it is not it will cause a repaint (I think, could be wrong
...).

HTH,

David Wilkinson

====================

Quote:

> Does anyone know how to force the screen to repaint during a prolonged
> processing loop ?

> I'm searching a database engine while printing lines generated from filtered
> queries.
> it may take many minutes to generate enough for one page. It seems that the
> CDC.EndPage() forces the repainting OK, but I need to do it more frequently.
> My innermost Get loop is executed sufficiently frequently, so if I could
> force a repainting there it would be fine. The effect of not repainting is
> that other applications (eg explorer, print control) when dragged across the
> screen leave unpainted areas.

> I have tried:
>   while (::PeekMessage(&msg,NULL,0,0,PM_NOREMOVE) )
>          AfxGetThread() -> PumpMessage();

> and:
>   while ( ::PeekMessage(&msg,NULL,WM_PAINT,WM_PAINT,PM_NOREMOVE) )
>          ::DispatchMessage(&msg);

> and:
>   while ( ::PeekMessage(&msg,NULL,WM_PAINT,WM_PAINT,PM_NOREMOVE) )
>        ::SendMessage(NULL, msg.message, msg.wParam, msg.lParam);

> The last of which hangs the application.

> I presume the problem is due to WM_PAINT's  staying in the message queue or
> to Dispatch/SendMessage's inability to force repainting while the
> application is in a loop.

> The application is MFC-based, VC6, single threading.
> I have a typical abort procedure in place getting its cancel message from a
> modeless dialog which is PeekMessaging - PumpMessaging to get its abort
> button read. This seems to be alright as its used elsewhere in other
> non-time-intensive printing tasks, although obviously it's not getting read
> here, but that's not the main problem. It is the screen non-repainting which
> I need to resolve.

> Can anyone tell me how to do it?

> Thanks,

> David.



Wed, 26 Sep 2001 03:00:00 GMT  
 Repaint during prolonged task
If the code you tried

Quote:
>  while (::PeekMessage(&msg,NULL,0,0,PM_NOREMOVE) )
>         AfxGetThread() -> PumpMessage();

doesn't help, I think you have a lot of "blocking" function calls,
maybe when you retrieve your result set from the database.
The only way here is to divide your application into two threads:
one will retrieve info from the database and another will be
responsible for dispatching and processing messages.
To do this create one more thread and move the code that fetches
data from DB into the thread's function.
Hope this helps.

--
Dima Shamroni
Abirnet Ltd., Memco Software Inc., R&D Dept.

AbirNet provides the next generation in network protection and Internet and
Intranet intrusion and abuse protection. AbirNet provides Windows 95 and
NT-based software that provides no-overhead see-it-all filtering, blocking,
alerting, logging, and scanning.
Take a test drive of SessionWall-3 today - go to www.AbirNet.com or ask
about SessionWall-3 at (817) 251-7000 or (800)245-1688.



Wed, 26 Sep 2001 03:00:00 GMT  
 Repaint during prolonged task
Call AfxGetMainWnd()->UpdateWindow to enforce a window update. This can be
called anytime and will bypass the message loop.

Greeting,
Arjen de Blok.

Quote:

>Does anyone know how to force the screen to repaint during a prolonged
>processing loop ?

>I'm searching a database engine while printing lines generated from
filtered
>queries.
>it may take many minutes to generate enough for one page. It seems that the
>CDC.EndPage() forces the repainting OK, but I need to do it more
frequently.
>My innermost Get loop is executed sufficiently frequently, so if I could
>force a repainting there it would be fine. The effect of not repainting is
>that other applications (eg explorer, print control) when dragged across
the
>screen leave unpainted areas.

>I have tried:
>  while (::PeekMessage(&msg,NULL,0,0,PM_NOREMOVE) )
>         AfxGetThread() -> PumpMessage();

>and:
>  while ( ::PeekMessage(&msg,NULL,WM_PAINT,WM_PAINT,PM_NOREMOVE) )
>         ::DispatchMessage(&msg);

>and:
>  while ( ::PeekMessage(&msg,NULL,WM_PAINT,WM_PAINT,PM_NOREMOVE) )
>       ::SendMessage(NULL, msg.message, msg.wParam, msg.lParam);

>The last of which hangs the application.

>I presume the problem is due to WM_PAINT's  staying in the message queue or
>to Dispatch/SendMessage's inability to force repainting while the
>application is in a loop.

>The application is MFC-based, VC6, single threading.
>I have a typical abort procedure in place getting its cancel message from a
>modeless dialog which is PeekMessaging - PumpMessaging to get its abort
>button read. This seems to be alright as its used elsewhere in other
>non-time-intensive printing tasks, although obviously it's not getting read
>here, but that's not the main problem. It is the screen non-repainting
which
>I need to resolve.

>Can anyone tell me how to do it?

>Thanks,

>David.



Fri, 28 Sep 2001 03:00:00 GMT  
 Repaint during prolonged task
Hi

I am a beginer. I am using a CDialogBar in the MainFnm of a MDI application.
I would like to pass some data from the DialogBar to CMyDoc, I tried to get
a pointer of CMyDoc dynamically using GetActiveDocument(), or set a CMyDoc
pointer as a member of CMainFnm, neither worked. I consulted the Inside VC++
book, the Mike Blaszczak book, the Beck Zaratian Book and the Jeff Prosise
book, still not getting a way out. Mike's book hinted it could be a problem
with MDI applications but did not show solution.

Any suggestions to the solution or other reference are greatfully
appreciated

Gong Yang



Fri, 28 Sep 2001 03:00:00 GMT  
 Repaint during prolonged task
Thanks for your advice.

  while (::PeekMessage(&msg,NULL,0,0,PM_NOREMOVE) )
         AfxGetThread() -> PumpMessage();

  does in fact work.
As you both suggested,  it wasn't being called as frequently as intended,
and having fixed this it works fine.

David.



Sat, 29 Sep 2001 03:00:00 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Repaint during prolonged task

2. Repaint during prolonged task

3. Tell Windows 2000 to Refresh / Repaint the Task Bar

4. How can I stop toolbar repaints in NT during resize

5. Repainting CFormView during heavy processing

6. VS.NET hangs when doubleclicking tasks during build

7. Quitting process choosing End Task in the Task Manager

8. Dialog app - no task on task bar???

9. Removing the task button from the task bar

10. Read/Write Properties During Design Time, but Read-Only During Run-Time

11. How to avoid flicker (repaint of entire screen and other programs) during tab-updates.

12. Windows repainting

 

 
Powered by phpBB® Forum Software