[MSTSC][USETUP]

- Fix MSVC warnings
- Remove duplicated code in usetup progress bar

svn path=/trunk/; revision=52467
This commit is contained in:
Rafal Harabien 2011-06-26 10:08:31 +00:00
parent 6641b0995e
commit 28157f42c1
7 changed files with 24 additions and 95 deletions

View file

@ -1136,10 +1136,10 @@ DlgProc(HWND hDlg,
SRCCOPY); SRCCOPY);
SelectObject(hdcMem, hBmpOld); SelectObject(hdcMem, hBmpOld);
txtRc.left = bmpRc.right * 0.25; txtRc.left = bmpRc.right / 4;
txtRc.top = 10; txtRc.top = 10;
txtRc.right = bmpRc.right * 0.75; txtRc.right = bmpRc.right * 3 / 4;
txtRc.bottom = pInfo->headerbitmap.bmHeight * 0.5; txtRc.bottom = pInfo->headerbitmap.bmHeight / 2;
ZeroMemory(&lf, sizeof(LOGFONTW)); ZeroMemory(&lf, sizeof(LOGFONTW));
@ -1172,10 +1172,10 @@ DlgProc(HWND hDlg,
} }
} }
txtRc.left = bmpRc.right * 0.25; txtRc.left = bmpRc.right / 4;
txtRc.top = txtRc.bottom - 5; txtRc.top = txtRc.bottom - 5;
txtRc.right = bmpRc.right * 0.75; txtRc.right = bmpRc.right * 3 / 4;
txtRc.bottom = pInfo->headerbitmap.bmHeight * 0.9; txtRc.bottom = pInfo->headerbitmap.bmHeight * 9 / 10;
if (LoadStringW(hInst, if (LoadStringW(hInst,
IDS_HEADERTEXT2, IDS_HEADERTEXT2,

View file

@ -172,11 +172,11 @@ DrawFileSystemList(
if (ListEntry == &List->Selected->ListEntry) if (ListEntry == &List->Selected->ListEntry)
CONSOLE_SetInvertedTextXY(List->Left, CONSOLE_SetInvertedTextXY(List->Left,
List->Top + Index, List->Top + (SHORT)Index,
Buffer); Buffer);
else else
CONSOLE_SetTextXY(List->Left, CONSOLE_SetTextXY(List->Left,
List->Top + Index, List->Top + (SHORT)Index,
Buffer); Buffer);
Index++; Index++;
ListEntry = ListEntry->Flink; ListEntry = ListEntry->Flink;

View file

@ -75,7 +75,7 @@ InfpOpenInfFileW(
Status = InfOpenFile( Status = InfOpenFile(
&hInf, &hInf,
&FileNameU, &FileNameU,
LocaleId, LANGIDFROMLCID(LocaleId),
&ErrorLineUL); &ErrorLineUL);
*ErrorLine = (UINT)ErrorLineUL; *ErrorLine = (UINT)ErrorLineUL;
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
@ -197,7 +197,7 @@ INF_OpenBufferedFileA(
&hInf, &hInf,
FileBuffer, FileBuffer,
FileSize, FileSize,
LocaleId, LANGIDFROMLCID(LocaleId),
&ErrorLineUL); &ErrorLineUL);
*ErrorLine = (UINT)ErrorLineUL; *ErrorLine = (UINT)ErrorLineUL;
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))

View file

@ -1612,7 +1612,7 @@ SelectPartition(PPARTLIST List, ULONG DiskNumber, ULONG PartitionNumber)
PPARTENTRY PartEntry; PPARTENTRY PartEntry;
PLIST_ENTRY Entry1; PLIST_ENTRY Entry1;
PLIST_ENTRY Entry2; PLIST_ENTRY Entry2;
ULONG i; UCHAR i;
/* Check for empty disks */ /* Check for empty disks */
if (IsListEmpty (&List->DiskListHead)) if (IsListEmpty (&List->DiskListHead))
@ -1965,7 +1965,7 @@ CreateNewPartition (PPARTLIST List,
PartEntry->PartInfo[0].StartingOffset.QuadPart = PartEntry->PartInfo[0].StartingOffset.QuadPart =
PartEntry->UnpartitionedOffset + DiskEntry->TrackSize; PartEntry->UnpartitionedOffset + DiskEntry->TrackSize;
PartEntry->PartInfo[0].HiddenSectors = PartEntry->PartInfo[0].HiddenSectors =
PartEntry->PartInfo[0].StartingOffset.QuadPart / DiskEntry->BytesPerSector; (ULONG)(PartEntry->PartInfo[0].StartingOffset.QuadPart / DiskEntry->BytesPerSector);
PartEntry->PartInfo[0].PartitionLength.QuadPart = PartEntry->PartInfo[0].PartitionLength.QuadPart =
PartEntry->UnpartitionedLength - DiskEntry->TrackSize; PartEntry->UnpartitionedLength - DiskEntry->TrackSize;
PartEntry->PartInfo[0].PartitionType = PARTITION_ENTRY_UNUSED; PartEntry->PartInfo[0].PartitionType = PARTITION_ENTRY_UNUSED;
@ -1996,7 +1996,7 @@ CreateNewPartition (PPARTLIST List,
PrevPartEntry->PartInfo[1].StartingOffset.QuadPart = PrevPartEntry->PartInfo[1].StartingOffset.QuadPart =
PartEntry->PartInfo[0].StartingOffset.QuadPart - DiskEntry->TrackSize; PartEntry->PartInfo[0].StartingOffset.QuadPart - DiskEntry->TrackSize;
PrevPartEntry->PartInfo[1].HiddenSectors = PrevPartEntry->PartInfo[1].HiddenSectors =
PrevPartEntry->PartInfo[1].StartingOffset.QuadPart / DiskEntry->BytesPerSector; (ULONG)(PrevPartEntry->PartInfo[1].StartingOffset.QuadPart / DiskEntry->BytesPerSector);
if (DiskEntry->PartListHead.Flink == &PrevPartEntry->ListEntry) if (DiskEntry->PartListHead.Flink == &PrevPartEntry->ListEntry)
{ {
@ -2024,7 +2024,7 @@ CreateNewPartition (PPARTLIST List,
PrevPartEntry->PartInfo[1].StartingOffset.QuadPart = PrevPartEntry->PartInfo[1].StartingOffset.QuadPart =
PartEntry->PartInfo[0].StartingOffset.QuadPart - DiskEntry->TrackSize; PartEntry->PartInfo[0].StartingOffset.QuadPart - DiskEntry->TrackSize;
PrevPartEntry->PartInfo[1].HiddenSectors = PrevPartEntry->PartInfo[1].HiddenSectors =
PrevPartEntry->PartInfo[1].StartingOffset.QuadPart / DiskEntry->BytesPerSector; (ULONG)(PrevPartEntry->PartInfo[1].StartingOffset.QuadPart / DiskEntry->BytesPerSector);
if (DiskEntry->PartListHead.Flink == &PrevPartEntry->ListEntry) if (DiskEntry->PartListHead.Flink == &PrevPartEntry->ListEntry)
{ {
@ -2081,7 +2081,7 @@ CreateNewPartition (PPARTLIST List,
NewPartEntry->PartInfo[0].StartingOffset.QuadPart = NewPartEntry->PartInfo[0].StartingOffset.QuadPart =
PartEntry->UnpartitionedOffset + DiskEntry->TrackSize; PartEntry->UnpartitionedOffset + DiskEntry->TrackSize;
NewPartEntry->PartInfo[0].HiddenSectors = NewPartEntry->PartInfo[0].HiddenSectors =
NewPartEntry->PartInfo[0].StartingOffset.QuadPart / DiskEntry->BytesPerSector; (ULONG)(NewPartEntry->PartInfo[0].StartingOffset.QuadPart / DiskEntry->BytesPerSector);
NewPartEntry->PartInfo[0].PartitionLength.QuadPart = NewPartEntry->PartInfo[0].PartitionLength.QuadPart =
PartitionSize - DiskEntry->TrackSize; PartitionSize - DiskEntry->TrackSize;
NewPartEntry->PartInfo[0].PartitionType = PARTITION_ENTRY_UNUSED; NewPartEntry->PartInfo[0].PartitionType = PARTITION_ENTRY_UNUSED;
@ -2112,7 +2112,7 @@ CreateNewPartition (PPARTLIST List,
PrevPartEntry->PartInfo[1].StartingOffset.QuadPart = PrevPartEntry->PartInfo[1].StartingOffset.QuadPart =
NewPartEntry->PartInfo[0].StartingOffset.QuadPart - DiskEntry->TrackSize; NewPartEntry->PartInfo[0].StartingOffset.QuadPart - DiskEntry->TrackSize;
PrevPartEntry->PartInfo[1].HiddenSectors = PrevPartEntry->PartInfo[1].HiddenSectors =
PrevPartEntry->PartInfo[1].StartingOffset.QuadPart / DiskEntry->BytesPerSector; (ULONG)(PrevPartEntry->PartInfo[1].StartingOffset.QuadPart / DiskEntry->BytesPerSector);
if (DiskEntry->PartListHead.Flink == &PrevPartEntry->ListEntry) if (DiskEntry->PartListHead.Flink == &PrevPartEntry->ListEntry)
{ {
@ -2140,7 +2140,7 @@ CreateNewPartition (PPARTLIST List,
PrevPartEntry->PartInfo[1].StartingOffset.QuadPart = PrevPartEntry->PartInfo[1].StartingOffset.QuadPart =
NewPartEntry->PartInfo[0].StartingOffset.QuadPart - DiskEntry->TrackSize; NewPartEntry->PartInfo[0].StartingOffset.QuadPart - DiskEntry->TrackSize;
PrevPartEntry->PartInfo[1].HiddenSectors = PrevPartEntry->PartInfo[1].HiddenSectors =
PrevPartEntry->PartInfo[1].StartingOffset.QuadPart / DiskEntry->BytesPerSector; (ULONG)(PrevPartEntry->PartInfo[1].StartingOffset.QuadPart / DiskEntry->BytesPerSector);
if (DiskEntry->PartListHead.Flink == &PrevPartEntry->ListEntry) if (DiskEntry->PartListHead.Flink == &PrevPartEntry->ListEntry)
{ {

View file

@ -290,75 +290,7 @@ ProgressSetStepCount(PPROGRESSBAR Bar,
VOID VOID
ProgressNextStep(PPROGRESSBAR Bar) ProgressNextStep(PPROGRESSBAR Bar)
{ {
CHAR TextBuffer[8]; ProgressSetStep(Bar, Bar->CurrentStep + 1);
COORD coPos;
DWORD Written;
ULONG NewPercent;
ULONG NewPos;
if ((Bar->StepCount == 0) ||
(Bar->CurrentStep == Bar->StepCount))
return;
Bar->CurrentStep++;
/* Calculate new percentage */
NewPercent = (ULONG)(((100.0 * (float)Bar->CurrentStep) / (float)Bar->StepCount) + 0.5);
/* Redraw precentage if changed */
if (Bar->Percent != NewPercent)
{
Bar->Percent = NewPercent;
sprintf(TextBuffer, "%-3lu%%", Bar->Percent);
coPos.X = Bar->Left + (Bar->Width - 2) / 2;
coPos.Y = Bar->Top;
WriteConsoleOutputCharacterA(StdOutput,
TextBuffer,
4,
coPos,
&Written);
}
/* Calculate bar position */
NewPos = (ULONG)((((float)(Bar->Width - 2) * 2.0 * (float)Bar->CurrentStep) / (float)Bar->StepCount) + 0.5);
/* Redraw bar if changed */
if (Bar->Pos != NewPos)
{
Bar->Pos = NewPos;
for (coPos.Y = Bar->Top + 2; coPos.Y <= Bar->Bottom - 1; coPos.Y++)
{
coPos.X = Bar->Left + 1;
FillConsoleOutputCharacterA(StdOutput,
0xDB,
Bar->Pos / 2,
coPos,
&Written);
coPos.X += Bar->Pos/2;
if (NewPos & 1)
{
FillConsoleOutputCharacterA(StdOutput,
0xDD,
1,
coPos,
&Written);
coPos.X++;
}
if (coPos.X <= Bar->Right - 1)
{
FillConsoleOutputCharacterA(StdOutput,
' ',
Bar->Right - coPos.X,
coPos,
&Written);
}
}
}
} }

View file

@ -38,7 +38,7 @@ typedef struct _PROGRESS
SHORT Width; SHORT Width;
ULONG Percent; ULONG Percent;
ULONG Pos; SHORT Pos;
ULONG StepCount; ULONG StepCount;
ULONG CurrentStep; ULONG CurrentStep;

View file

@ -398,8 +398,7 @@ CreateNestedKey (PHANDLE KeyHandle,
UNICODE_STRING LocalKeyName; UNICODE_STRING LocalKeyName;
ULONG Disposition; ULONG Disposition;
NTSTATUS Status; NTSTATUS Status;
ULONG FullNameLength; USHORT FullNameLength;
ULONG Length;
PWCHAR Ptr; PWCHAR Ptr;
HANDLE LocalKeyHandle; HANDLE LocalKeyHandle;
@ -421,7 +420,7 @@ CreateNestedKey (PHANDLE KeyHandle,
RtlCreateUnicodeString (&LocalKeyName, RtlCreateUnicodeString (&LocalKeyName,
ObjectAttributes->ObjectName->Buffer); ObjectAttributes->ObjectName->Buffer);
LocalObjectAttributes.ObjectName = &LocalKeyName; LocalObjectAttributes.ObjectName = &LocalKeyName;
FullNameLength = LocalKeyName.Length / sizeof(WCHAR); FullNameLength = LocalKeyName.Length;
/* Remove the last part of the key name and try to create the key again. */ /* Remove the last part of the key name and try to create the key again. */
while (Status == STATUS_OBJECT_NAME_NOT_FOUND) while (Status == STATUS_OBJECT_NAME_NOT_FOUND)
@ -452,10 +451,9 @@ CreateNestedKey (PHANDLE KeyHandle,
} }
/* Add removed parts of the key name and create them too. */ /* Add removed parts of the key name and create them too. */
Length = wcslen (LocalKeyName.Buffer);
while (TRUE) while (TRUE)
{ {
if (Length == FullNameLength) if (LocalKeyName.Length == FullNameLength)
{ {
Status = STATUS_SUCCESS; Status = STATUS_SUCCESS;
*KeyHandle = LocalKeyHandle; *KeyHandle = LocalKeyHandle;
@ -463,9 +461,8 @@ CreateNestedKey (PHANDLE KeyHandle,
} }
NtClose (LocalKeyHandle); NtClose (LocalKeyHandle);
LocalKeyName.Buffer[Length] = L'\\'; LocalKeyName.Buffer[LocalKeyName.Length / sizeof(WCHAR)] = L'\\';
Length = wcslen (LocalKeyName.Buffer); LocalKeyName.Length = wcslen (LocalKeyName.Buffer) * sizeof(WCHAR);
LocalKeyName.Length = Length * sizeof(WCHAR);
Status = NtCreateKey (&LocalKeyHandle, Status = NtCreateKey (&LocalKeyHandle,
KEY_ALL_ACCESS, KEY_ALL_ACCESS,