Click to See Complete Forum and Search --> : urgent:refreshing dialog


June 15th, 1999, 06:02 AM
i have written a dialog based application
if i open another program (eg. WORD) over my program while it is running,and then close WORD again, my program doesnt re-paint.

Q. How can i get my program to refresh when the focus isnt on it but it is in view?

thanks in advance
J

Roger Allen
June 15th, 1999, 07:25 AM
Normally I would expect your dialog to re-draw, but it may not do so under certain circumstances. Are you doing processing work in your main application thread, as doing so would not allowed qued messages like WM_PAINT (WM_PAINT messages seem to be given low priority by windows) to not be executed until your code stops what it is doing and enteres the idle loop.
If this is the case, I would recommend adding a Peek and Dispatch message loop to your running code to allow other messages to be processed.
An example of this code is :

MSG msg ;
while (::PeekMessage(&msg, NULL, 0, 0, PM_NOYIELD | PM_REMOVE))
{
::TranslateMessage(&msg) ;
::DispatchMessage(&msg) ;
}




HTH


Roger Allen

June 15th, 1999, 09:24 AM
Thanks for that, yes processing takes place in the main thread (there was no way around this). where should i put the

MSG msg ;
while (::PeekMessage(&msg, NULL, 0, 0, PM_NOYIELD | PM_REMOVE))
{
::TranslateMessage(&msg) ;
::DispatchMessage(&msg) ;
}
code?, i tried putting it in an OnShowWindow(BOOL bShow, UINT nStatus)
function, im not sure wher to go from here and dont know what code i should add to the above segment.

help?
J

Jason Teagle
June 15th, 1999, 09:29 AM
The code should go in the middle of your processing which is taking up the time - because your intense processing is preventing messages from being processed, it also prevents WM_SHOWWINDOW from getting through (and all other messages), which is why it still doesn't work. Basically, what we are attempting to do here is get your intense processing to ease up every now and then and allow some messages through.

Roger Allen
June 15th, 1999, 09:52 AM
A word of warning :

When you put this in your main processing loop, if the main processing was set off by a menu item selection, then it can be selected again and you could have multiple instances of the same procedure running, so you may have to disable certain menu items in your application at the start of your main processing algorithm to stop this from happening.

Good luck....




Roger Allen

June 15th, 1999, 10:43 AM
I have the menu disabled.

would it be alright to call this code in multiple places?, because there are a few area's of the main process algorthim that could cause a delay that could cause the problem.

thanks
J