Hello again all. I finally have everything working almost mostly thanks to you guys but I have run into a problem and I am stumped. Basically what I am trying to do is load and display a progress box from a dll file, and then return to loop on a function while updating the function. The problem that I have is in order to make sure that the ProgressBox is displayed I loop waiting for the HWND. In code this is what I am doing:

void ShowProgressDialog(FunctionParams* f)
{
fparams=f;
hThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)CreatePrgWindow, (LPVOID)fparams, 0, &dwThreadId);
while (fparams->hwnd==0) ;
}

It goes into a infinite loop at the end and never comes out. (I do set the fparams->hwnd in the CreatePrgWindow). However like a good little programmer when I was testing this I had:

void ShowProgressDialog(FunctionParams* f)
{
fparams=f;
hThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)CreatePrgWindow, (LPVOID)fparams, 0, &dwThreadId);
while (fparams->hwnd==0)
cout << "waiting..." << endl;
}

and this worked fine I got maybe about 10 waitings and the code continues. Any ideas why this is and how I can fix this? Is this possibly a optimization thing and without the cout the compiler thinks that the loop does nothing? I have tried several different combos such as:

while(fparams->hwnd==0)
if (f->hwnd!=0) break;

and

for (int i=0; fparams->hwnd==0; i++)

both just lock into the loop. I am truly lost here and would appreciate any help.