ReactOS  0.4.14-dev-297-g23e575c
progress.c File Reference
#include "usetup.h"
#include <debug.h>
Include dependency graph for progress.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

static BOOLEAN NTAPI UpdateProgressPercentage (IN PPROGRESSBAR Bar, IN BOOLEAN AlwaysUpdate, OUT PSTR Buffer, IN SIZE_T cchBufferSize)
 
static VOID DrawBorder (IN PPROGRESSBAR Bar)
 
static VOID DrawThickBorder (IN PPROGRESSBAR Bar)
 
static VOID DrawProgressBar (IN PPROGRESSBAR Bar)
 
PPROGRESSBAR CreateProgressBarEx (IN SHORT Left, IN SHORT Top, IN SHORT Right, IN SHORT Bottom, IN SHORT TextTop, IN SHORT TextRight, IN BOOLEAN DoubleEdge, IN SHORT ProgressColour, IN ULONG StepCount, IN PCSTR DescriptionText OPTIONAL, IN PCSTR ProgressFormatText OPTIONAL, IN PUPDATE_PROGRESS UpdateProgressProc OPTIONAL)
 
PPROGRESSBAR CreateProgressBar (IN SHORT Left, IN SHORT Top, IN SHORT Right, IN SHORT Bottom, IN SHORT TextTop, IN SHORT TextRight, IN BOOLEAN DoubleEdge, IN PCSTR DescriptionText OPTIONAL)
 
VOID DestroyProgressBar (IN OUT PPROGRESSBAR Bar)
 
VOID ProgressSetStepCount (IN PPROGRESSBAR Bar, IN ULONG StepCount)
 
VOID ProgressNextStep (IN PPROGRESSBAR Bar)
 
VOID ProgressSetStep (IN PPROGRESSBAR Bar, IN ULONG Step)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 13 of file progress.c.

Function Documentation

◆ CreateProgressBar()

PPROGRESSBAR CreateProgressBar ( IN SHORT  Left,
IN SHORT  Top,
IN SHORT  Right,
IN SHORT  Bottom,
IN SHORT  TextTop,
IN SHORT  TextRight,
IN BOOLEAN  DoubleEdge,
IN PCSTR DescriptionText  OPTIONAL 
)

Definition at line 317 of file progress.c.

326 {
327  /* Call the Ex variant of the function */
328  return CreateProgressBarEx(Left, Top, Right, Bottom,
329  TextTop, TextRight,
330  DoubleEdge,
332  0,
333  DescriptionText,
334  "%-3lu%%",
336 }
PPROGRESSBAR CreateProgressBarEx(IN SHORT Left, IN SHORT Top, IN SHORT Right, IN SHORT Bottom, IN SHORT TextTop, IN SHORT TextRight, IN BOOLEAN DoubleEdge, IN SHORT ProgressColour, IN ULONG StepCount, IN PCSTR DescriptionText OPTIONAL, IN PCSTR ProgressFormatText OPTIONAL, IN PUPDATE_PROGRESS UpdateProgressProc OPTIONAL)
Definition: progress.c:272
static BOOLEAN NTAPI UpdateProgressPercentage(IN PPROGRESSBAR Bar, IN BOOLEAN AlwaysUpdate, OUT PSTR Buffer, IN SIZE_T cchBufferSize)
Definition: progress.c:20
#define FOREGROUND_YELLOW
Definition: consup.h:30
#define BACKGROUND_BLUE
Definition: wincon.h:43
static LPHIST_ENTRY Bottom
Definition: history.c:54
static LPHIST_ENTRY Top
Definition: history.c:53

Referenced by ChkdskPartition(), FileCopyPage(), and FormatPartition().

◆ CreateProgressBarEx()

PPROGRESSBAR CreateProgressBarEx ( IN SHORT  Left,
IN SHORT  Top,
IN SHORT  Right,
IN SHORT  Bottom,
IN SHORT  TextTop,
IN SHORT  TextRight,
IN BOOLEAN  DoubleEdge,
IN SHORT  ProgressColour,
IN ULONG  StepCount,
IN PCSTR DescriptionText  OPTIONAL,
IN PCSTR ProgressFormatText  OPTIONAL,
IN PUPDATE_PROGRESS UpdateProgressProc  OPTIONAL 
)

Definition at line 272 of file progress.c.

285 {
286  PPROGRESSBAR Bar;
287 
289  0,
290  sizeof(PROGRESSBAR));
291  if (Bar == NULL)
292  return NULL;
293 
294  Bar->Left = Left;
295  Bar->Top = Top;
296  Bar->Right = Right;
297  Bar->Bottom = Bottom;
298  Bar->TextTop = TextTop;
299  Bar->TextRight = TextRight;
300 
301  Bar->Width = Bar->Right - Bar->Left + 1;
302 
303  Bar->DoubleEdge = DoubleEdge;
304  Bar->ProgressColour = ProgressColour;
305  Bar->DescriptionText = DescriptionText;
306  Bar->ProgressFormatText = ProgressFormatText;
307 
308  Bar->UpdateProgressProc = UpdateProgressProc;
309 
310  /* Reset the progress bar counts and initially draw it */
311  ProgressSetStepCount(Bar, StepCount);
312 
313  return Bar;
314 }
BOOLEAN DoubleEdge
Definition: progress.h:60
SHORT TextRight
Definition: progress.h:46
SHORT Left
Definition: progress.h:41
PUPDATE_PROGRESS UpdateProgressProc
Definition: progress.h:55
VOID ProgressSetStepCount(IN PPROGRESSBAR Bar, IN ULONG StepCount)
Definition: progress.c:347
SHORT ProgressColour
Definition: progress.h:61
SHORT Bottom
Definition: progress.h:44
SHORT Right
Definition: progress.h:43
smooth NULL
Definition: ftsmooth.c:416
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:588
SHORT TextTop
Definition: progress.h:45
SHORT Width
Definition: progress.h:48
PCSTR DescriptionText
Definition: progress.h:62
HANDLE ProcessHeap
Definition: servman.c:15
static LPHIST_ENTRY Bottom
Definition: history.c:54
struct _PROGRESSBAR * PPROGRESSBAR
SHORT Top
Definition: progress.h:42
static LPHIST_ENTRY Top
Definition: history.c:53
PCSTR ProgressFormatText
Definition: progress.h:63

Referenced by CreateProgressBar(), and ProgressCountdown().

◆ DestroyProgressBar()

VOID DestroyProgressBar ( IN OUT PPROGRESSBAR  Bar)

Definition at line 339 of file progress.c.

341 {
342  RtlFreeHeap(ProcessHeap, 0, Bar);
343 }
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:606
HANDLE ProcessHeap
Definition: servman.c:15

Referenced by ChkdskPartition(), FileCopyPage(), FormatPartition(), and ProgressCountdown().

◆ DrawBorder()

static VOID DrawBorder ( IN PPROGRESSBAR  Bar)
static

Definition at line 48 of file progress.c.

50 {
51  COORD coPos;
52  DWORD Written;
53  SHORT i;
54 
55  /* draw upper left corner */
56  coPos.X = Bar->Left;
57  coPos.Y = Bar->Top + 1;
59  0xDA, // '+',
60  1,
61  coPos,
62  &Written);
63 
64  /* draw upper edge */
65  coPos.X = Bar->Left + 1;
66  coPos.Y = Bar->Top + 1;
68  0xC4, // '-',
69  Bar->Right - Bar->Left - 1,
70  coPos,
71  &Written);
72 
73  /* draw upper right corner */
74  coPos.X = Bar->Right;
75  coPos.Y = Bar->Top + 1;
77  0xBF, // '+',
78  1,
79  coPos,
80  &Written);
81 
82  /* draw left and right edge */
83  for (i = Bar->Top + 2; i < Bar->Bottom; i++)
84  {
85  coPos.X = Bar->Left;
86  coPos.Y = i;
88  0xB3, // '|',
89  1,
90  coPos,
91  &Written);
92 
93  coPos.X = Bar->Right;
95  0xB3, //'|',
96  1,
97  coPos,
98  &Written);
99  }
100 
101  /* draw lower left corner */
102  coPos.X = Bar->Left;
103  coPos.Y = Bar->Bottom;
105  0xC0, // '+',
106  1,
107  coPos,
108  &Written);
109 
110  /* draw lower edge */
111  coPos.X = Bar->Left + 1;
112  coPos.Y = Bar->Bottom;
114  0xC4, // '-',
115  Bar->Right - Bar->Left - 1,
116  coPos,
117  &Written);
118 
119  /* draw lower right corner */
120  coPos.X = Bar->Right;
121  coPos.Y = Bar->Bottom;
123  0xD9, // '+',
124  1,
125  coPos,
126  &Written);
127 }
BOOL WINAPI FillConsoleOutputCharacterA(IN HANDLE hConsoleOutput, IN CHAR cCharacter, IN DWORD nLength, IN COORD dwWriteCoord, OUT LPDWORD lpNumberOfCharsWritten)
Definition: console.c:509
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
short SHORT
Definition: pedump.c:59
HANDLE StdOutput
Definition: consup.c:37
ULONG X
Definition: bl.h:1340
unsigned long DWORD
Definition: ntddk_ex.h:95
Definition: bl.h:1338
static LPHIST_ENTRY Bottom
Definition: history.c:54
ULONG Y
Definition: bl.h:1341

Referenced by DrawProgressBar().

◆ DrawProgressBar()

static VOID DrawProgressBar ( IN PPROGRESSBAR  Bar)
static

Definition at line 214 of file progress.c.

216 {
217  COORD coPos;
218  DWORD Written;
219  PROGRESSBAR BarBorder = *Bar;
220  CHAR TextBuffer[256];
221 
222  /* Draw the progress bar "border" border */
223  if (Bar->DoubleEdge)
224  {
225  BarBorder.Top -= 5;
226  BarBorder.Bottom += 2;
227  BarBorder.Right += 5;
228  BarBorder.Left -= 5;
229  DrawThickBorder(&BarBorder);
230  }
231 
232  /* Draw the progress bar border */
233  DrawBorder(Bar);
234 
235  /* Display the description text */
236  if (Bar->DescriptionText)
237  CONSOLE_SetTextXY(Bar->TextTop, Bar->TextRight, Bar->DescriptionText);
238 
239  /* Always update and display the progress */
240  if (Bar->UpdateProgressProc &&
241  Bar->UpdateProgressProc(Bar, TRUE, TextBuffer, ARRAYSIZE(TextBuffer)))
242  {
243  coPos.X = Bar->Left + (Bar->Width - strlen(TextBuffer) + 1) / 2;
244  coPos.Y = Bar->Top;
246  TextBuffer,
248  coPos,
249  &Written);
250  }
251 
252  /* Draw the empty bar */
253  coPos.X = Bar->Left + 1;
254  for (coPos.Y = Bar->Top + 2; coPos.Y <= Bar->Bottom - 1; coPos.Y++)
255  {
257  Bar->ProgressColour,
258  Bar->Width - 2,
259  coPos,
260  &Written);
261 
263  ' ',
264  Bar->Width - 2,
265  coPos,
266  &Written);
267  }
268 }
#define TRUE
Definition: types.h:120
VOID CONSOLE_SetTextXY(IN SHORT x, IN SHORT y, IN LPCSTR Text)
Definition: consup.c:305
BOOL WINAPI FillConsoleOutputAttribute(IN HANDLE hConsoleOutput, IN WORD wAttribute, IN DWORD nLength, IN COORD dwWriteCoord, OUT LPDWORD lpNumberOfAttrsWritten)
Definition: console.c:474
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
SHORT Left
Definition: progress.h:41
char CHAR
Definition: xmlstorage.h:175
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
BOOL WINAPI FillConsoleOutputCharacterA(IN HANDLE hConsoleOutput, IN CHAR cCharacter, IN DWORD nLength, IN COORD dwWriteCoord, OUT LPDWORD lpNumberOfCharsWritten)
Definition: console.c:509
static VOID DrawBorder(IN PPROGRESSBAR Bar)
Definition: progress.c:48
HANDLE StdOutput
Definition: consup.c:37
SHORT Bottom
Definition: progress.h:44
SHORT Right
Definition: progress.h:43
BOOL WINAPI WriteConsoleOutputCharacterA(HANDLE hConsoleOutput, IN LPCSTR lpCharacter, IN DWORD nLength, IN COORD dwWriteCoord, OUT LPDWORD lpNumberOfCharsWritten)
Definition: console.c:356
ULONG X
Definition: bl.h:1340
unsigned long DWORD
Definition: ntddk_ex.h:95
Definition: bl.h:1338
SHORT Top
Definition: progress.h:42
char TextBuffer[BUFFERLEN]
Definition: combotst.c:45
static VOID DrawThickBorder(IN PPROGRESSBAR Bar)
Definition: progress.c:131
ULONG Y
Definition: bl.h:1341

Referenced by ProgressSetStepCount().

◆ DrawThickBorder()

static VOID DrawThickBorder ( IN PPROGRESSBAR  Bar)
static

Definition at line 131 of file progress.c.

133 {
134  COORD coPos;
135  DWORD Written;
136  SHORT i;
137 
138  /* draw upper left corner */
139  coPos.X = Bar->Left;
140  coPos.Y = Bar->Top + 1;
142  0xC9, // '+',
143  1,
144  coPos,
145  &Written);
146 
147  /* draw upper edge */
148  coPos.X = Bar->Left + 1;
149  coPos.Y = Bar->Top + 1;
151  0xCD, // '-',
152  Bar->Right - Bar->Left - 1,
153  coPos,
154  &Written);
155 
156  /* draw upper right corner */
157  coPos.X = Bar->Right;
158  coPos.Y = Bar->Top + 1;
160  0xBB, // '+',
161  1,
162  coPos,
163  &Written);
164 
165  /* draw left and right edge */
166  for (i = Bar->Top + 2; i < Bar->Bottom; i++)
167  {
168  coPos.X = Bar->Left;
169  coPos.Y = i;
171  0xBA, // '|',
172  1,
173  coPos,
174  &Written);
175 
176  coPos.X = Bar->Right;
178  0xBA, //'|',
179  1,
180  coPos,
181  &Written);
182  }
183 
184  /* draw lower left corner */
185  coPos.X = Bar->Left;
186  coPos.Y = Bar->Bottom;
188  0xC8, // '+',
189  1,
190  coPos,
191  &Written);
192 
193  /* draw lower edge */
194  coPos.X = Bar->Left + 1;
195  coPos.Y = Bar->Bottom;
197  0xCD, // '-',
198  Bar->Right - Bar->Left - 1,
199  coPos,
200  &Written);
201 
202  /* draw lower right corner */
203  coPos.X = Bar->Right;
204  coPos.Y = Bar->Bottom;
206  0xBC, // '+',
207  1,
208  coPos,
209  &Written);
210 }
BOOL WINAPI FillConsoleOutputCharacterA(IN HANDLE hConsoleOutput, IN CHAR cCharacter, IN DWORD nLength, IN COORD dwWriteCoord, OUT LPDWORD lpNumberOfCharsWritten)
Definition: console.c:509
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
short SHORT
Definition: pedump.c:59
HANDLE StdOutput
Definition: consup.c:37
ULONG X
Definition: bl.h:1340
unsigned long DWORD
Definition: ntddk_ex.h:95
Definition: bl.h:1338
static LPHIST_ENTRY Bottom
Definition: history.c:54
ULONG Y
Definition: bl.h:1341

Referenced by DrawProgressBar().

◆ ProgressNextStep()

VOID ProgressNextStep ( IN PPROGRESSBAR  Bar)

Definition at line 361 of file progress.c.

363 {
364  ProgressSetStep(Bar, Bar->CurrentStep + 1);
365 }
VOID ProgressSetStep(IN PPROGRESSBAR Bar, IN ULONG Step)
Definition: progress.c:368

Referenced by FileCopyCallback().

◆ ProgressSetStep()

VOID ProgressSetStep ( IN PPROGRESSBAR  Bar,
IN ULONG  Step 
)

Definition at line 368 of file progress.c.

371 {
372  COORD coPos;
373  DWORD Written;
374  ULONG NewPos;
375  CHAR TextBuffer[256];
376 
377  if (Step > Bar->StepCount)
378  return;
379 
380  Bar->CurrentStep = Step;
381 
382  /* Update the progress and redraw it if it has changed */
383  if (Bar->UpdateProgressProc &&
384  Bar->UpdateProgressProc(Bar, FALSE, TextBuffer, ARRAYSIZE(TextBuffer)))
385  {
386  coPos.X = Bar->Left + (Bar->Width - strlen(TextBuffer) + 1) / 2;
387  coPos.Y = Bar->Top;
389  TextBuffer,
391  coPos,
392  &Written);
393  }
394 
395  /* Calculate the bar position */
396  NewPos = (((Bar->Width - 2) * 2 * Bar->CurrentStep + (Bar->StepCount / 2)) / Bar->StepCount);
397 
398  /* Redraw the bar if it has changed */
399  if (Bar->Pos != NewPos)
400  {
401  Bar->Pos = NewPos;
402 
403  for (coPos.Y = Bar->Top + 2; coPos.Y <= Bar->Bottom - 1; coPos.Y++)
404  {
405  coPos.X = Bar->Left + 1;
407  0xDB,
408  Bar->Pos / 2,
409  coPos,
410  &Written);
411  coPos.X += Bar->Pos / 2;
412 
413  if (NewPos & 1)
414  {
416  0xDD,
417  1,
418  coPos,
419  &Written);
420  coPos.X++;
421  }
422 
423  if (coPos.X <= Bar->Right - 1)
424  {
426  ' ',
427  Bar->Right - coPos.X,
428  coPos,
429  &Written);
430  }
431  }
432  }
433 }
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
char CHAR
Definition: xmlstorage.h:175
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
BOOL WINAPI FillConsoleOutputCharacterA(IN HANDLE hConsoleOutput, IN CHAR cCharacter, IN DWORD nLength, IN COORD dwWriteCoord, OUT LPDWORD lpNumberOfCharsWritten)
Definition: console.c:509
HANDLE StdOutput
Definition: consup.c:37
BOOL WINAPI WriteConsoleOutputCharacterA(HANDLE hConsoleOutput, IN LPCSTR lpCharacter, IN DWORD nLength, IN COORD dwWriteCoord, OUT LPDWORD lpNumberOfCharsWritten)
Definition: console.c:356
ULONG X
Definition: bl.h:1340
unsigned long DWORD
Definition: ntddk_ex.h:95
Definition: bl.h:1338
char TextBuffer[BUFFERLEN]
Definition: combotst.c:45
unsigned int ULONG
Definition: retypes.h:1
ULONG Y
Definition: bl.h:1341

Referenced by FormatCallback(), ProgressCountdown(), ProgressNextStep(), and SetupUpdateMemoryInfo().

◆ ProgressSetStepCount()

VOID ProgressSetStepCount ( IN PPROGRESSBAR  Bar,
IN ULONG  StepCount 
)

Definition at line 347 of file progress.c.

350 {
351  Bar->CurrentStep = 0;
352  Bar->StepCount = StepCount;
353 
354  Bar->Progress = 0;
355  Bar->Pos = 0;
356 
357  DrawProgressBar(Bar);
358 }
static VOID DrawProgressBar(IN PPROGRESSBAR Bar)
Definition: progress.c:214

Referenced by ChkdskPartition(), CreateProgressBarEx(), FileCopyCallback(), FormatPartition(), ProgressCountdown(), and SetupUpdateMemoryInfo().

◆ UpdateProgressPercentage()

static BOOLEAN NTAPI UpdateProgressPercentage ( IN PPROGRESSBAR  Bar,
IN BOOLEAN  AlwaysUpdate,
OUT PSTR  Buffer,
IN SIZE_T  cchBufferSize 
)
static

Definition at line 20 of file progress.c.

25 {
26  // static PCSTR ProgressFormatText;
27  ULONG OldProgress = Bar->Progress;
28 
29  /* Calculate the new percentage */
30  if (Bar->StepCount == 0)
31  Bar->Progress = 0;
32  else
33  Bar->Progress = ((100 * Bar->CurrentStep + (Bar->StepCount / 2)) / Bar->StepCount);
34 
35  /* Build the progress string if it has changed */
36  if ( Bar->ProgressFormatText &&
37  (AlwaysUpdate || (Bar->Progress != OldProgress)) )
38  {
40  Bar->ProgressFormatText, Bar->Progress);
41  return TRUE;
42  }
43  return FALSE;
44 }
IN BOOLEAN OUT PSTR IN SIZE_T cchBufferSize
Definition: progress.h:34
#define TRUE
Definition: types.h:120
NTSTRSAFEVAPI RtlStringCchPrintfA(_Out_writes_(cchDest) _Always_(_Post_z_) NTSTRSAFE_PSTR pszDest, _In_ size_t cchDest, _In_ _Printf_format_string_ NTSTRSAFE_PCSTR pszFormat,...)
Definition: ntstrsafe.h:1085
Definition: bufpool.h:45
unsigned int ULONG
Definition: retypes.h:1
IN BOOLEAN AlwaysUpdate
Definition: progress.h:34

Referenced by CreateProgressBar().