RE: mfc csreen does not refresh
Do the calculation in an own thread. Then the screen is always up to date.
Thread sounds difficult - but is easy:
///////////////////////////////////
// initialisation in header (.h)
typedef struct {
// User data necessary for the calculation
int nCount; // f.e.
// more user data...
bool bStop; // to stop the thread without using TerminateTread
} struct_tinfTest;
struct_tinfTest *m_ptinfTest;
CWinThread *m_pThread; // pointer to thread-function
HANDLE m_hThread; // handle to thread-function
///////////////////////////////////
// Start the Thread anywhere in your app (.cpp)
m_ptinfTest->bStop = false;
m_ptinfTest->nCount = 700;
m_pThread = AfxBeginThread(TestThread, m_ptinfTest); // start the Thread
m_hThread = m_pThread->m_hThread; // Save Handle to ThreadFunction
///////////////////////////////////
// Thread function (.cpp)
UINT TestThread(LPVOID lpParam) {
struct_tinfTest *pt = (struct_tinfTest*)lpParam;
for (i = 0; i < pt->nCount; i++) {
if (bStop) break;
// calculation
}
return(0);
}
I have a VC6 app that I am trying to develop.
It takes a 700 maps and processes each one individually
the program is set around one big loop
I intend that it should paint all the maps
however it just paints the first and the last map
at the end of the major loop
I have an
Invalidate();
UpdateWindow();
it does not force an update except for the first and last map
If however I do a
Invalidate();
UpdateWindow();
AfxMessageBox("next one",MB_ICONEXCLAMATION|MB_OK);
then I can step through each map - not very attractive given there are
700 maps
I tried to use
Invalidate();
UpdateWindow();
Sleep(5);
but it does not help - the app still displays the first and last map.
I know that as the application is executing that the OnPaint() code is
called but it does not refresh the screen
I want to have the application set up so it will freewheel through all
the maps. The process behind each map takes something like 20 seconds
so there is plenty of time to see the map content.
Questions
========
Can anyone please give me a clue where to start looking?
Where can I find documentation on OnPaint() and other mfc goodies?
thanks
Bruce