make dialog responsive even if it is running a time consuming calculation
-
hi guys i have a dialog based application, when i run a time consuming operation, the dialog box hang, becas unless the operation completes my dialog box wont have any focus or will nt be able to recieve any message. Example: i have a listctrl where i add 10000 records, so unless all records are added my dialog will nt respond. where as while those records being added i want my dialog box to be responsive, i cant let the user to wait till the operation gets over, any idea, there is a code sample called backgroundtask dialog here CP, i dont want that way. Swarup
-
hi guys i have a dialog based application, when i run a time consuming operation, the dialog box hang, becas unless the operation completes my dialog box wont have any focus or will nt be able to recieve any message. Example: i have a listctrl where i add 10000 records, so unless all records are added my dialog will nt respond. where as while those records being added i want my dialog box to be responsive, i cant let the user to wait till the operation gets over, any idea, there is a code sample called backgroundtask dialog here CP, i dont want that way. Swarup
-
hi guys i have a dialog based application, when i run a time consuming operation, the dialog box hang, becas unless the operation completes my dialog box wont have any focus or will nt be able to recieve any message. Example: i have a listctrl where i add 10000 records, so unless all records are added my dialog will nt respond. where as while those records being added i want my dialog box to be responsive, i cant let the user to wait till the operation gets over, any idea, there is a code sample called backgroundtask dialog here CP, i dont want that way. Swarup
Doing your lengthy process on a separate thread is the recommended way to go. If you don't want to use multiple threads, then your lengthy process needs to periodically pump all Windows messages so the UI will remain responsive. Here's an example MFC message pump (implemented in the application class)
void CMyWinApp::PumpWaitingMessages()
{
MSG msg;
while ( ::PeekMessage( &msg, NULL, 0, 0, PM_NOREMOVE ) )
{
if ( !PumpMessage( ) )
{
//::PostQuitMessage(0);
break;
}
}
}A Win32 message pump could be something like
MSG msg;
while ( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) )
{
TranslateMessage( &msg );
DispatchMessage( &msg );
}Note that you'll want to disable any UI components that you don't want the user to mess with during the lengthy process. Mark
Mark Salsbery Microsoft MVP - Visual C++ :java: