Hi
I've been trying to find out why the following code's output is delayed 'till all the processing is completed. I see the first line in the ListBox but then the rest don't appear till the end.
void CAddDialog::OnOK()
{
STARTUPINFO startup;
PROCESS_INFORMATION procinfo;
CString command, fullname;
BeginWaitCursor();
for(int index1=0; index1<array1.GetSize(); index1++)
{
m_listbox.AddString("ZIPPING " + theFilePath + "\\" + array1[index1].sourcename);
m_listbox.Invalidate();
m_listbox.UpdateWindow();
::ZeroMemory(&startup, sizeof(startup));
startup.cb = sizeof(startup);
startup.dwFlags = STARTF_USESHOWWINDOW ;
startup.wShowWindow = SW_HIDE; // hidden console window
command.Format("\"c:\\Program Files\\PKWARE\\pkzipc\\pkzipc\" -add \"%s\\%s.zip\" -overwrite \"%s\\%s\"", theLibPath, array1[index1].zipname, theFilePath, array1[index1].sourcename);
LPTSTR cmd = command.GetBuffer(command.GetLength() + 1);
BOOL started = ::CreateProcess(NULL, // command is part of input string
cmd, // (writeable) command string
NULL, // process security
NULL, // thread security
TRUE, // inherit handles flag
0, // flags
NULL, // inherit environment
NULL, // inherit directory
&startup, // STARTUPINFO
&procinfo); // PROCESS_INFORMATION
if(!started) {
DWORD err = ::GetLastError(); // preserve across CloseHandle calls
SetDlgItemText(IDC_LIBPATH,cvError(err));
}
DWORD waitresult;
do{
m_listbox.Invalidate();
m_listbox.UpdateWindow();
waitresult = WaitForSingleObject(procinfo.hProcess, 100);
}while(waitresult == WAIT_TIMEOUT);
// Close process and thread handles.
CloseHandle( procinfo.hProcess );
}
}
I've been trying to find out why the following code's output is delayed 'till all the processing is completed. I see the first line in the ListBox but then the rest don't appear till the end.
void CAddDialog::OnOK()
{
STARTUPINFO startup;
PROCESS_INFORMATION procinfo;
CString command, fullname;
BeginWaitCursor();
for(int index1=0; index1<array1.GetSize(); index1++)
{
m_listbox.AddString("ZIPPING " + theFilePath + "\\" + array1[index1].sourcename);
m_listbox.Invalidate();
m_listbox.UpdateWindow();
::ZeroMemory(&startup, sizeof(startup));
startup.cb = sizeof(startup);
startup.dwFlags = STARTF_USESHOWWINDOW ;
startup.wShowWindow = SW_HIDE; // hidden console window
command.Format("\"c:\\Program Files\\PKWARE\\pkzipc\\pkzipc\" -add \"%s\\%s.zip\" -overwrite \"%s\\%s\"", theLibPath, array1[index1].zipname, theFilePath, array1[index1].sourcename);
LPTSTR cmd = command.GetBuffer(command.GetLength() + 1);
BOOL started = ::CreateProcess(NULL, // command is part of input string
cmd, // (writeable) command string
NULL, // process security
NULL, // thread security
TRUE, // inherit handles flag
0, // flags
NULL, // inherit environment
NULL, // inherit directory
&startup, // STARTUPINFO
&procinfo); // PROCESS_INFORMATION
if(!started) {
DWORD err = ::GetLastError(); // preserve across CloseHandle calls
SetDlgItemText(IDC_LIBPATH,cvError(err));
}
DWORD waitresult;
do{
m_listbox.Invalidate();
m_listbox.UpdateWindow();
waitresult = WaitForSingleObject(procinfo.hProcess, 100);
}while(waitresult == WAIT_TIMEOUT);
// Close process and thread handles.
CloseHandle( procinfo.hProcess );
}
}