summaryrefslogblamecommitdiffstats
path: root/private/utils/fdisk/fdlistbx.c
blob: 27ef39b61cac7cf6858ba51b1c3a4eddfc547397 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
















































































































































































































































































































































































































































































































































































































































































































































































































































































































                                                                                                              
/*++

Copyright (c) 1990  Microsoft Corporation

Module Name:

    fdlistbx.c

Abstract:

    Routines for handling the subclassed owner-draw listbox used by NT fdisk
    to display the state of attached disks.

Author:

    Ted Miller (tedm) 7-Jan-1992

--*/

#include "fdisk.h"

// constants used when listbox or its focus rectangle is
// scrolled/moved.

#define    DIR_NONE     0
#define    DIR_UP       1
#define    DIR_DN       2

// original window procedure for our subclassed listbox

WNDPROC OldListBoxProc;

// item which has focus

DWORD LBCursorListBoxItem,LBCursorRegion;

BOOL LBCursorOn = FALSE;

VOID
ToggleLBCursor(
    IN HDC hdc
    );

VOID
ToggleRegion(
    IN PDISKSTATE DiskState,
    IN DWORD      RegionIndex,
    IN HDC        hdc
    );

LONG
ListBoxSubProc(
    IN HWND  hwnd,
    IN UINT  msg,
    IN DWORD wParam,
    IN LONG  lParam
    )

/*++

Routine Description:

    This routine is the window procedure used for our subclassed listbox.
    We subclass the listbox so that we can handle keyboard input processing.
    All other messages are passed through to the original listbox procedure.

    Significant keys are arrows, pageup/dn, tab, space, return, home, and end.
    Control may be used to modify space and return.
    Shift may be used to modify tab.

Arguments:

    hwnd    - window handle of listbox

    msg     - message #

    wParam  - user param # 1

    lParam  - user param # 2

Return Value:

    see below

--*/

{
    int        focusDir = DIR_NONE;
    USHORT     vKey;
    DWORD      maxRegion;
    PDISKSTATE diskState;
    LONG       topItem,
               bottomWholeItem,
               visibleItems;
    RECT       rc;

    switch (msg) {

    case WM_CHAR:

        break;

    case WM_KEYDOWN:

        switch (vKey = LOWORD(wParam)) {
        case VK_LEFT:
        case VK_RIGHT:
        case VK_UP:
        case VK_DOWN:

            ToggleLBCursor(NULL);
            switch (vKey) {
            case VK_LEFT:
                LBCursorRegion = LBCursorRegion ? LBCursorRegion-1 : 0;
                break;
            case VK_RIGHT:
                maxRegion = Disks[LBCursorListBoxItem]->RegionCount - 1;
                if (LBCursorRegion < maxRegion) {
                    LBCursorRegion++;
                }
                break;
            case VK_UP:
                if (LBCursorListBoxItem) {
                    LBCursorListBoxItem--;
                    LBCursorRegion = 0;
                    focusDir = DIR_UP;
                }
                break;
            case VK_DOWN:
                if (LBCursorListBoxItem < DiskCount-1) {
                    LBCursorListBoxItem++;
                    LBCursorRegion = 0;
                    focusDir = DIR_DN;
                }
                break;
            }

            // don't allow list box cursor to fall on extended partition

            diskState = Disks[LBCursorListBoxItem];
            maxRegion = diskState->RegionCount - 1;
            if (IsExtended(diskState->RegionArray[LBCursorRegion].SysID)) {
                if (LBCursorRegion && ((vKey == VK_LEFT) || (LBCursorRegion == maxRegion))) {
                    LBCursorRegion--;
                } else {
                    LBCursorRegion++;
                }
            }

            ToggleLBCursor(NULL);
            break;

        case VK_TAB:

            ToggleLBCursor(NULL);

            if (GetKeyState(VK_SHIFT) & ~1) {    // shift-tab
                LBCursorListBoxItem--;
                focusDir = DIR_UP;
            } else {
                LBCursorListBoxItem++;
                focusDir = DIR_DN;
            }
            if (LBCursorListBoxItem == (DWORD)(-1)) {
                LBCursorListBoxItem = DiskCount-1;
                focusDir = DIR_DN;
            } else if (LBCursorListBoxItem == DiskCount) {
                LBCursorListBoxItem = 0;
                focusDir = DIR_UP;
            }
            ResetLBCursorRegion();

            ToggleLBCursor(NULL);
            break;

        case VK_HOME:
        case VK_END:

            ToggleLBCursor(NULL);
            topItem = (vKey == VK_HOME) ? 0 : DiskCount-1;
            SendMessage(hwndList, LB_SETTOPINDEX, (DWORD)topItem, 0);
            LBCursorListBoxItem = topItem;
            ResetLBCursorRegion();
            ToggleLBCursor(NULL);
            break;

        case VK_PRIOR:
        case VK_NEXT:

            ToggleLBCursor(NULL);
            topItem = SendMessage(hwndList, LB_GETTOPINDEX, 0, 0);
            GetClientRect(hwndList,&rc);
            visibleItems = (rc.bottom - rc.top) / GraphHeight;
            if (!visibleItems) {
                visibleItems = 1;
            }
            topItem = (vKey == VK_PRIOR)
                    ? max(topItem - visibleItems, 0)
                    : min(topItem + visibleItems, (LONG)DiskCount-1);
            SendMessage(hwndList, LB_SETTOPINDEX, (DWORD)topItem, 0);
            LBCursorListBoxItem = SendMessage(hwndList, LB_GETTOPINDEX, 0, 0);
            ResetLBCursorRegion();
            ToggleLBCursor(NULL);
            break;


        case VK_RETURN:
        case VK_SPACE:

            // Select the region that currently has the list box selection cursor.

            if (!Disks[LBCursorListBoxItem]->OffLine) {

                Selection(GetKeyState(VK_CONTROL) & ~1,     // strip toggle bit
                          Disks[LBCursorListBoxItem],
                          LBCursorRegion);
            }
            break;
        }

        // now scroll the newly focused item into view if necessary

        switch (focusDir) {
        case DIR_UP:
            if (LBCursorListBoxItem < (DWORD)SendMessage(hwndList, LB_GETTOPINDEX, 0, 0)) {
                SendMessage(hwndList, LB_SETTOPINDEX, LBCursorListBoxItem, 0);
            }
            break;
        case DIR_DN:
            GetClientRect(hwndList, &rc);
            topItem = SendMessage(hwndList, LB_GETTOPINDEX, 0, 0);
            bottomWholeItem = topItem + ((rc.bottom - rc.top) / GraphHeight) - 1;
            if (bottomWholeItem < topItem) {
                bottomWholeItem = topItem;
            }
            if ((DWORD)bottomWholeItem > DiskCount-1) {
                bottomWholeItem = DiskCount-1;
            }
            if (LBCursorListBoxItem > (DWORD)bottomWholeItem) {
                SendMessage(hwndList,
                            LB_SETTOPINDEX,
                            topItem + LBCursorListBoxItem - bottomWholeItem,
                            0);
            }
            break;
        }
        break;

    default:
        return CallWindowProc(OldListBoxProc, hwnd, msg, wParam, lParam);
    }
    return 0;
}

VOID
SubclassListBox(
    IN HWND hwnd
    )
{
    OldListBoxProc = (WNDPROC)GetWindowLong(hwnd, GWL_WNDPROC);
    SetWindowLong(hwnd, GWL_WNDPROC, (LONG)ListBoxSubProc);

    // There is a scantily documented 'feature' of a listbox wherein it will
    // use its parent's DC.  This means that drawing is not always clipped to
    // the client area of the listbox.  Seeing as we're subclassing listboxes
    // anyway, take care of this here.

    SetClassLong(hwnd, GCL_STYLE, GetClassLong(hwnd, GCL_STYLE) & ~CS_PARENTDC);
}

VOID
DeselectSelectedRegions(
    VOID
    )

/*++

Routine Description:

    This routine visually unselects all selected regions.  The selection
    state is also updated in the master disk structures.

Arguments:

    None.

Return Value:

    None.

--*/

{
    DWORD      i,
               j;
    PDISKSTATE diskState;

    for (i=0; i<DiskCount; i++) {
        diskState = Disks[i];
        for (j=0; j<diskState->RegionCount; j++) {
            if (diskState->Selected[j]) {
                diskState->Selected[j] = FALSE;
                ToggleRegion(diskState, j, NULL);
            }
        }
    }
}

VOID
Selection(
    IN BOOL       MultipleSel,
    IN PDISKSTATE DiskState,
    IN DWORD      RegionIndex
    )

/*++

Routine Description:

    This routine handles a user selection of a disk region.  It is called
    directly for a keyboard selection or indirectly for a mouse selection.
    If not a multiple selection, all selected regions are deselected.
    The focus rectangle is moved to the selected region, which is then
    visually selected.

Arguments:

    MultipleSel - whether the user has made a multiple selection
                  (ie, control-clicked).

    DiskState - master disk structure for disk containing selected region

    RegionIndex - index of selected region on the disk

Return Value:

    None.

--*/

{
    PFT_OBJECT     ftObject,
                   ftObj;
    PFT_OBJECT_SET ftSet;
    ULONG          disk,
                   r;

    if (!MultipleSel) {

        // need to deselect all selected regions first.

        DeselectSelectedRegions();
    }

    // remove the list box selection cursor from its previous region

    ToggleLBCursor(NULL);

    // The selected region might be part of an ft object set.  If it is,
    // scan each region in each disk and select each item in the set.

    if (ftObject = GET_FT_OBJECT(&DiskState->RegionArray[RegionIndex])) {

        ftSet = ftObject->Set;
        for (disk=0; disk<DiskCount; disk++) {
            PDISKSTATE diskState = Disks[disk];

            for (r=0; r<diskState->RegionCount; r++) {
                PREGION_DESCRIPTOR regionDescriptor = &diskState->RegionArray[r];

                if (DmSignificantRegion(regionDescriptor)) {

                    if (ftObj = GET_FT_OBJECT(regionDescriptor)) {

                        if (ftObj->Set == ftSet) {

                            diskState->Selected[r] = (BOOLEAN)(!diskState->Selected[r]);
                            ToggleRegion(diskState, r, NULL);
                        }
                    }
                }
            }
        }
    } else {
        DiskState->Selected[RegionIndex] = (BOOLEAN)(!DiskState->Selected[RegionIndex]);
        ToggleRegion(DiskState, RegionIndex, NULL);
    }

    LBCursorListBoxItem = DiskState->Disk;
    LBCursorRegion      = RegionIndex;
    ToggleLBCursor(NULL);
    AdjustMenuAndStatus();
}

VOID
MouseSelection(
    IN     BOOL   MultipleSel,
    IN OUT PPOINT Point
    )

/*++

Routine Description:

    This routine is called when the user clicks in the list box.  It determines
    which disk region the user has clicked on before calling the common
    selection subroutine.

Arguments:

    MultipleSel - whether the user has made a multiple selection
                  (ie, control-clicked).

    point - screen coords of the click

Return Value:

    None.

--*/

{
    PDISKSTATE  diskState;
    DWORD       selectedItem;
    DWORD       x,
                y;
    DWORD       i;
    RECT        rc;
    BOOL        valid;

    if ((selectedItem = SendMessage(hwndList, LB_GETCURSEL, 0, 0)) == LB_ERR) {
        return;
    }

    // user has clicked on a list box item.

    diskState = Disks[selectedItem];

    // Ignore clicks on off-line disks.

    if (diskState->OffLine) {
        return;
    }

    ScreenToClient(hwndList, Point);

    x = Point->x;
    y = Point->y;
    GetClientRect(hwndList,&rc);

    // first make sure that the click was within a bar and not in space
    // between two bars

    for (valid=FALSE, i=rc.top; i<=(DWORD)rc.bottom; i+=GraphHeight) {
        if ((y >= i+BarTopYOffset) && (y <= i+BarBottomYOffset)) {
            valid = TRUE;
            break;
        }
    }
    if (!valid) {
        return;
    }

    // determine which region he has clicked on

    for (i=0; i<diskState->RegionCount; i++) {
        if ((x >= (unsigned)diskState->LeftRight[i].Left) && (x <= (unsigned)diskState->LeftRight[i].Right)) {
            break;
        }
    }
    if (i == diskState->RegionCount) {
        return;     // region not found.  Ignore the click.
    }

    Selection(MultipleSel, diskState, i);
}

LONG
CalcBarTop(
    DWORD Bar
    )

/*++

Routine Description:

    This routine calculates the current top y coord of a given bar.
    The value is in listbox client coords.

Arguments:

    Bar - # of bar whose position is desired

Return Value:

    Y-coord, or -1 if bar is not visible.

--*/

{
    LONG  barDelta = (LONG)Bar - SendMessage(hwndList, LB_GETTOPINDEX, 0, 0);
    LONG  pos = -1;
    RECT  rc;

    if (barDelta >= 0) {                 // BUGBUG check bottom too
        GetClientRect(hwndList,&rc);
        pos = rc.top + (barDelta * GraphHeight);
    }
    return pos;
}

VOID
ResetLBCursorRegion(
    VOID
    )

/*++

Routine Description:

    This routine resets the list box focus cursor to the 0th (leftmost)
    region on the current disk.  If the 0th region is the extended
    partition, focus is set to the first logical volume or free space
    with the extended partition instead.

Arguments:

    None.

Return Value:

    None.

--*/

{
    PDISKSTATE diskState = Disks[LBCursorListBoxItem];
    unsigned   i;

    LBCursorRegion = 0;
    if (IsExtended(diskState->RegionArray[LBCursorRegion].SysID)) {
        for (i=0; i<diskState->RegionCount; i++) {
            if (diskState->RegionArray[i].RegionType == REGION_LOGICAL) {
                LBCursorRegion = i;
                return;
            }
        }
        FDASSERT(0);
    }
}

VOID
ToggleLBCursor(
    IN HDC hdc
    )

/*++

Routine Description:

    This routine visually toggles the focus state of the disk region
    described by the LBCursorListBoxItem and LBCursorRegion globals.

Arguments:

    hdc - If non-NULL, device context to use for drawing.  If NULL,
          we'll first get a DC via GetDC().

Return Value:

    None.

--*/

{
    PDISKSTATE lBCursorDisk = Disks[LBCursorListBoxItem];
    LONG       barTop = CalcBarTop(LBCursorListBoxItem);
    RECT       rc;
    HDC        hdcActual;

    if (barTop != -1) {

        hdcActual = hdc ? hdc : GetDC(hwndList);

        LBCursorOn = !LBCursorOn;

        rc.left   = lBCursorDisk->LeftRight[LBCursorRegion].Left;
        rc.right  = lBCursorDisk->LeftRight[LBCursorRegion].Right + 1;
        rc.top    = barTop + BarTopYOffset;
        rc.bottom = barTop + BarBottomYOffset;

        FrameRect(hdcActual,
                  &rc,
                  GetStockObject(LBCursorOn ? WHITE_BRUSH : BLACK_BRUSH));

        if (LBCursorOn) {

            // BUGBUG really want a dotted line.
            DrawFocusRect(hdcActual, &rc);
        }

        if (!hdc) {
            ReleaseDC(hwndList, hdcActual);
        }
    }
}

VOID
ForceLBRedraw(
    VOID
    )

/*++

Routine Description:

    This routine forces redraw of the listbox by invalidating its
    entire client area.

Arguments:

    None.

Return Value:

    None.

--*/

{
    InvalidateRect(hwndList,NULL,FALSE);
    UpdateWindow(hwndList);
}

VOID
ToggleRegion(
    IN PDISKSTATE DiskState,
    IN DWORD      RegionIndex,
    IN HDC        hdc
    )

/*++

Routine Description:

    This routine visually toggles the selection state of a given disk region.

Arguments:

    DiskState - master structure for disk containing region to select

    RegionIndex - which region on the disk to toggle

    hdc - if non-NULL, device context to use for drawing.  If NULL, we'll
          first get a device context via GetDC().


Return Value:

    None.

--*/

{
    PLEFTRIGHT leftRight = &DiskState->LeftRight[RegionIndex];
    LONG       barTop    = CalcBarTop(DiskState->Disk);  // BUGBUG disk# as lb index#
    BOOL       selected  = (BOOL)DiskState->Selected[RegionIndex];
    HBRUSH     hbr       = GetStockObject(BLACK_BRUSH);
    HDC        hdcActual;
    RECT       rc;
    int        i;

    if (barTop != -1) {

        hdcActual = hdc ? hdc : GetDC(hwndList);

        rc.left   = leftRight->Left + 1;
        rc.right  = leftRight->Right;
        rc.top    = barTop + BarTopYOffset + 1;
        rc.bottom = barTop + BarBottomYOffset - 1;

        if (selected) {

            for (i=0; i<SELECTION_THICKNESS; i++) {
                FrameRect(hdcActual, &rc, hbr);
                InflateRect(&rc, -1, -1);
            }

        } else {

            // Blt the region from the off-screen bitmap onto the
            // screen.  But first exclude the center of the region
            // from the clip region so we only blt the necessary bits.
            // This sppeds up selections noticably.

            InflateRect(&rc, -SELECTION_THICKNESS, -SELECTION_THICKNESS);
            ExcludeClipRect(hdcActual, rc.left, rc.top, rc.right, rc.bottom);
            BitBlt(hdcActual,
                   leftRight->Left,
                   barTop + BarTopYOffset,
                   leftRight->Right - leftRight->Left,
                   barTop + BarBottomYOffset,
                   DiskState->hDCMem,
                   leftRight->Left,
                   BarTopYOffset,
                   SRCCOPY);
        }

        if (!hdc) {
            ReleaseDC(hwndList, hdcActual);
        }
    }
}

DWORD
InitializeListBox(
    IN HWND  hwndListBox
    )

/*++

Routine Description:

    This routine sets up the list box.  This includes creating disk state
    structures, drawing the graphs for each disk off screen, and adding the
    disks to the list box.

    It also includes determining the initial volume labels and type names
    for all significant partitions.

Arguments:

    hwndListBox - handle of the list box that will hold the disk graphs

Return Value:

    Windows error code (esp. out of memory)

--*/

{
    PPERSISTENT_REGION_DATA regionData;
    TCHAR                   windowsDir[MAX_PATH];
    unsigned                i;
    PDISKSTATE              diskState;
    DWORD                   ec;
    ULONG                   r;
    BOOL                    diskSignaturesCreated,
                            temp;

    // First, create the array that will hold the diskstates,
    // the IsDiskRemovable array and the RemovableDiskReservedDriveLetters
    // array.

    Disks = Malloc(DiskCount * sizeof(PDISKSTATE));
    IsDiskRemovable = (PBOOLEAN)Malloc(DiskCount * sizeof(BOOLEAN));
    RemovableDiskReservedDriveLetters = (PCHAR)Malloc(DiskCount * sizeof(CHAR));

    // Determine which disks are removable and which are unpartitioned.

    for (i=0; i<DiskCount; i++) {

        IsDiskRemovable[i] = IsRemovable( i );
    }

    // next, create all disk states

    FDASSERT(DiskCount);
    diskSignaturesCreated = FALSE;
    for (i=0; i<DiskCount; i++) {

        // first create the disk state structure

        CreateDiskState(&diskState, i, &temp);
        diskSignaturesCreated = diskSignaturesCreated || temp;

        Disks[i] = diskState;

        // next determine the state of the disk's partitioning scheme

        DeterminePartitioningState(diskState);

        // Next create a blank logical disk structure for each region.

        for (r=0; r<diskState->RegionCount; r++) {
            if (DmSignificantRegion(&diskState->RegionArray[r])) {
                regionData = Malloc(sizeof(PERSISTENT_REGION_DATA));
                DmInitPersistentRegionData(regionData, NULL, NULL, NULL, NO_DRIVE_LETTER_YET);
                regionData->VolumeExists = TRUE;
            } else {
                regionData = NULL;
            }
            DmSetPersistentRegionData(&diskState->RegionArray[r], regionData);
        }

        // add the item to the listbox

        while (((ec = SendMessage(hwndListBox, LB_ADDSTRING, 0, 0)) == LB_ERR) || (ec == LB_ERRSPACE)) {
            ConfirmOutOfMemory();
        }
    }

    // Read the configuration registry

    if ((ec = InitializeFt(diskSignaturesCreated)) != NO_ERROR) {
        ErrorDialog(ec);
        return ec;
    }

    // Determine drive letter mappings

    InitializeDriveLetterInfo();

    // Determine volume labels and type names.

    InitVolumeLabelsAndTypeNames();

    // Determine which disk is the boot disk.

    if (GetWindowsDirectory(windowsDir, sizeof(windowsDir)/sizeof(TCHAR)) < 2 ||
        windowsDir[1] != TEXT(':')) {

        BootDiskNumber = (ULONG)-1;
        BootPartitionNumber = (ULONG)-1;
    } else {
        BootDiskNumber = GetDiskNumberFromDriveLetter((CHAR)windowsDir[0]);
        BootPartitionNumber = GetPartitionNumberFromDriveLetter((CHAR)windowsDir[0]);
    }

    // Locate and create data structures for any DoubleSpace volumes

    DblSpaceInitialize();

    for (i=0; i<DiskCount; i++) {

        DrawDiskBar(Disks[i]);
    }

    return NO_ERROR;
}

VOID
WMDrawItem(
    IN PDRAWITEMSTRUCT pDrawItem
    )
{
    DWORD      temp;
    PDISKSTATE pDiskState;

    if ((pDrawItem->itemID != (DWORD)(-1))
    && (pDrawItem->itemAction == ODA_DRAWENTIRE)) {
        pDiskState = Disks[pDrawItem->itemID];

        // blt the disk's bar from the off-screen bitmap to the screen

        BitBlt(pDrawItem->hDC,
               pDrawItem->rcItem.left,
               pDrawItem->rcItem.top,
               pDrawItem->rcItem.right  - pDrawItem->rcItem.left + 1,
               pDrawItem->rcItem.bottom - pDrawItem->rcItem.top  + 1,
               pDiskState->hDCMem,
               0,
               0,
               SRCCOPY);

        // if we just overwrote the focus cursor, redraw it

        if (pDrawItem->itemID == LBCursorListBoxItem) {
            LBCursorOn = FALSE;
            ToggleLBCursor(pDrawItem->hDC);
        }

        // select any items selected in this bar

        for (temp=0; temp<pDiskState->RegionCount; temp++) {
            if (pDiskState->Selected[temp]) {
                ToggleRegion(pDiskState, temp, pDrawItem->hDC);
            }
        }
    }
}