Click to See Complete Forum and Search --> : Re-paint all controls when dialog box is visible


Cedric Dostal
June 3rd, 1999, 12:29 PM
I'd like to know how to do to re-paint all controls in a dialog box when this one is visible (and when PC is processing) after having been hidden.
For example, I create a Dialog Box with CStatic, CEdit..... and CProgressCtrl controls and, from this dialog box,Icall a function Process([function parameters],CProgressCtrl* poProgress)
{
for(i = 0;i < 10000;i++)
{
.
.
.
poProgress->OffsetPos(1);
}
}

When the dialog box is hidden and re-shown, only the progression of the CProgressCtrl is redrawn.
I'd like all the other controls to be redrawn.
Thanks.

Sergio Acosta
June 4th, 1999, 01:04 AM
You have to use multithreading to do processing and having the controls process their messages at the samen time. Use AfxBeginThread(MyProcess, pParams) to create a "worker thread" (that will do the process) instead of call your MyProcess() function. You just have to encapsulate the paramenters you pass to MyProcess in a single class or sctructure. And you have to define your process function like this:

UINT MyProcess(LPVOID pParam)




For example:

Instead of :

...
MyProcess(int a, int b, CSomeClass c);
...



It'll be:

//Definitions:

UINT MyProcess(LPVOID pParam);

structure
{
int a;
int b;
CSomeclass c;
}MyParamStructure;



And when starting the processing:

...
MyParamStructure ps;
ps.a = a;
ps.b = b;
ps.c = c;

AfxBeginThread(MyProcess,&ps);
...