2 /* INCLUDES *****************************************************************/
10 /* FUNCTIONS ****************************************************************/
14 DrawBorder(PPROGRESS Bar)
20 /* draw upper left corner */
22 coPos.Y = Bar->Top + 1;
23 FillConsoleOutputCharacter(0xDA, // '+',
29 coPos.X = Bar->Left + 1;
30 coPos.Y = Bar->Top + 1;
31 FillConsoleOutputCharacter(0xC4, // '-',
32 Bar->Right - Bar->Left - 1,
36 /* draw upper right corner */
38 coPos.Y = Bar->Top + 1;
39 FillConsoleOutputCharacter(0xBF, // '+',
44 /* draw left and right edge */
45 for (i = Bar->Top + 2; i < Bar->Bottom; i++)
49 FillConsoleOutputCharacter(0xB3, // '|',
55 FillConsoleOutputCharacter(0xB3, //'|',
61 /* draw lower left corner */
63 coPos.Y = Bar->Bottom;
64 FillConsoleOutputCharacter(0xC0, // '+',
70 coPos.X = Bar->Left + 1;
71 coPos.Y = Bar->Bottom;
72 FillConsoleOutputCharacter(0xC4, // '-',
73 Bar->Right - Bar->Left - 1,
77 /* draw lower right corner */
79 coPos.Y = Bar->Bottom;
80 FillConsoleOutputCharacter(0xD9, // '+',
88 DrawProgressBar(PPROGRESS Bar)
95 /* Print percentage */
96 sprintf(TextBuffer, "%-3lu%%", Bar->Percent);
98 coPos.X = Bar->Left + (Bar->Width - 2) / 2;
100 WriteConsoleOutputCharacters(TextBuffer,
107 coPos.X = Bar->Left + 1;
108 for (coPos.Y = Bar->Top + 2; coPos.Y <= Bar->Bottom - 1; coPos.Y++)
110 FillConsoleOutputAttribute(0x1E, /* Yellow on blue */
115 FillConsoleOutputCharacter(' ',
126 CreateProgressBar(SHORT Left,
133 Bar = (PPROGRESS)RtlAllocateHeap(ProcessHeap,
142 Bar->Bottom = Bottom;
144 Bar->Width = Bar->Right - Bar->Left + 1;
150 Bar->CurrentStep = 0;
152 DrawProgressBar(Bar);
159 DestroyProgressBar(PPROGRESS Bar)
161 RtlFreeHeap(ProcessHeap,
167 ProgressSetStepCount(PPROGRESS Bar,
170 Bar->CurrentStep = 0;
171 Bar->StepCount = StepCount;
173 DrawProgressBar(Bar);
178 ProgressNextStep(PPROGRESS Bar)
186 if ((Bar->StepCount == 0) ||
187 (Bar->CurrentStep == Bar->StepCount))
192 /* Calculate new percentage */
193 NewPercent = (ULONG)(((100.0 * (float)Bar->CurrentStep) / (float)Bar->StepCount) + 0.5);
195 /* Redraw precentage if changed */
196 if (Bar->Percent != NewPercent)
198 Bar->Percent = NewPercent;
200 sprintf(TextBuffer, "%-3lu%%", Bar->Percent);
202 coPos.X = Bar->Left + (Bar->Width - 2) / 2;
204 WriteConsoleOutputCharacters(TextBuffer,
209 /* Calculate bar position */
210 NewPos = (ULONG)((((float)(Bar->Width - 2) * 2.0 * (float)Bar->CurrentStep) / (float)Bar->StepCount) + 0.5);
212 /* Redraw bar if changed */
213 if (Bar->Pos != NewPos)
217 for (coPos.Y = Bar->Top + 2; coPos.Y <= Bar->Bottom - 1; coPos.Y++)
219 coPos.X = Bar->Left + 1;
220 FillConsoleOutputCharacter(0xDB,
224 coPos.X += Bar->Pos/2;
228 FillConsoleOutputCharacter(0xDD,
235 if (coPos.X <= Bar->Right - 1)
237 FillConsoleOutputCharacter(' ',
238 Bar->Right - coPos.X,