-
December 20th, 2002, 01:31 PM
#1
CProgressCtrl problem
How do I get the stdout to fill in the step in a progress bar. Here is what I have so far.
Code:
CProgressCtrl *m_pFileProg = (CProgressCtrl *)GetDlgItem(IDC_FILEPROG);
STARTUPINFO SUInfo;
PROCESS_INFORMATION PInfo;
SUInfo.cb = sizeof SUInfo;
SUInfo.lpReserved = NULL;
SUInfo.lpDesktop = NULL;
SUInfo.lpTitle = NULL;
SUInfo.dwX = 0;
SUInfo.dwY = 0;
SUInfo.dwFlags = NULL; //If I uncomment this, the output is a command prompt showing nothing /*STARTF_USESTDHANDLES;*/
SUInfo.cbReserved2 = 0;
SUInfo.lpReserved2 = 0;
SUInfo.hStdOutput = PInfo.hProcess;
//sBatchEncode is a CString containing the executable command and it's arguments
CreateProcess(NULL, (LPTSTR)((LPCTSTR)sBatchEncode),NULL,NULL, FALSE//TRUE if I uncomment the above, NORMAL_PRIORITY_CLASS, NULL, NULL,&SUInfo, &PInfo);
//Currently the output on the command prompt is 0%....25%....50%....75%....100%....
SetDlgItemText(IDC_STATIC_CONVERTFILE,"Processing " + sInFile);
WaitForSingleObject( PInfo.hProcess, INFINITE );
CloseHandle(PInfo.hProcess);
CloseHandle(PInfo.hThread);
}
How do I current the CProgressCtrl to show the process steps?
Am I using CreateProcess correctly or should I use something else to accomplishing what I want to do?
Been trying to figure this out and need help.
Mike@spb
-
December 20th, 2002, 04:31 PM
#2
How do I current the CProgressCtrl to show the process steps?
[code]
// initialize progress control
m_pFileProg ->SetRange(myminimum, mymaximum);
...
Where you report progress...
m_pFileProg->SetPos(SomewhereBetweenMinAndMax);
Am I using CreateProcess correctly or should I use something else to accomplishing what I want to do?
Does it do what you want now? What are you trying to do?
-
October 9th, 2019, 02:29 AM
#3
Re: CProgressCtrl problem
I have issue with the function call:
Code:
DOF_m_fault_progress.SetPos(100);
There is a slight delay before the progress bar updates to 100%.
Any idea why this issue occurs.
Before setting the progress bar to 100 I am setting it to 10-20-40-50-75 % and they seem to be working fine.
I have set the range to 1 to 100 as shown in the below function call:
Code:
DOF_m_fault_progress.SetRange(0,100);
-
October 9th, 2019, 02:48 AM
#4
Re: CProgressCtrl problem
And what happens in your code between SetPos(75) and SetPos(100)?
Victor Nijegorodov
-
October 9th, 2019, 03:41 AM
#5
Re: CProgressCtrl problem
I am calling 2 applications using"ShellExecute" command which decode some files and generate some new files.
Once the control is returned from those I am using these SetPos() command to update the progress accordingly.
-
October 9th, 2019, 03:45 AM
#6
Re: CProgressCtrl problem
Originally Posted by vcdebugger
I am calling 2 applications using"ShellExecute" command which decode some files and generate some new files.
Once the control is returned from those I am using these SetPos() command to update the progress accordingly.
So what is the problem?
Victor Nijegorodov
-
October 9th, 2019, 06:24 AM
#7
Re: CProgressCtrl problem
The progress bar is an indicator of tasks performed, not time elapsed. If the tasks to perform don't take the same amount of time, then the indicated progress won't be linear. This non-linear progress indication is common in programs (eg MS update etc). If 10% of the tasks to be performed have completed in 10 seconds, then you cannot say that 100% will complete in 100 seconds. They might complete in 50 seconds or they might complete in 10 minutes.
All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!
C++23 Compiler: Microsoft VS2022 (17.6.5)
-
October 9th, 2019, 07:55 AM
#8
Re: CProgressCtrl problem
You could try adding DOF_m_fault_progress.UpdateWindow() to force it to update immediately.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|