Annotation of mstools/samples/filer/drvproc.c, revision 1.1.1.3

1.1.1.3 ! root        1: 
        !             2: /******************************************************************************\
        !             3: *       This is a part of the Microsoft Source Code Samples.
        !             4: *       Copyright (C) 1993 Microsoft Corporation.
        !             5: *       All rights reserved.
        !             6: *       This source code is only intended as a supplement to
        !             7: *       Microsoft Development Tools and/or WinHelp documentation.
        !             8: *       See these sources for detailed information regarding the
        !             9: *       Microsoft samples programs.
        !            10: \******************************************************************************/
        !            11: 
1.1       root       12: /******************************Module*Header*******************************\
                     13: * Module Name:  drvproc.c
                     14: *
                     15: * Filer : SDK sample
                     16: *   +   Simple File Management program with GUI front end.
                     17: *       Demonstrates Win32 File I/O API and various User algorithms.
                     18: *
                     19: * DRVPROC.C : Contains procedures relating to child window management.
                     20: *               In this sample, the Drive children handle the directory
                     21: *               and file enumeration, as well as the file I/O operations.
                     22: *
                     23: \**************************************************************************/
                     24: 
1.1.1.2   root       25: #define  STRICT
1.1       root       26: #include <windows.h>
                     27: #include <string.h>
                     28: #include "globals.h"
                     29: #include "filer.h"
1.1.1.3 ! root       30: #include "expdir.h"
1.1       root       31: #include "drvproc.h"
                     32: 
                     33: extern HANDLE   ghModule;
                     34: extern HANDLE   ghHeap;
                     35: extern HFONT    ghFont;
1.1.1.3 ! root       36: extern HANDLE   ghDrvThread;
        !            37: extern HANDLE   ghMenu;
1.1       root       38: 
                     39: extern HWND     ghwndCommand;
                     40: extern HWND     ghwndDrives;
                     41: extern HWND     ghActiveChild;
                     42: extern HWND     ghwndDrv1;
                     43: extern HWND     ghwndDrv2;
1.1.1.3 ! root       44: extern HWND     ghFocusWnd;
1.1       root       45: 
                     46: extern LPDINFO  glpDrives;
                     47: 
                     48: extern CRITICAL_SECTION    gHeapCS;  // Global heap critical section var.
                     49: extern CRITICAL_SECTION    gDrvCS;   // Drive list critical section var.
                     50: 
1.1.1.3 ! root       51: extern TCHAR    gszEditor[DIRECTORY_STRING_SIZE];
        !            52: extern TCHAR    gszCommandLine[DIRECTORY_STRING_SIZE * 2];
        !            53: 
        !            54: extern TCHAR    gszExtensions[NUM_EXTENSION_STRINGS][EXTENSION_LENGTH];
        !            55: 
        !            56: extern VKINFO   gVKArray[NUM_VERSION_INFO_KEYS];  // .EXE version info array.
1.1       root       57: 
                     58: 
                     59: /***************************************************************************\
                     60: * DrvWndProc()
                     61: *
                     62: * History:
                     63: * 05-1-92  Created
                     64: \***************************************************************************/
                     65: 
1.1.1.2   root       66: LRESULT  WINAPI DrvWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
1.1       root       67: {
1.1.1.3 ! root       68:     DWORD dwDirStyle = WS_BORDER | WS_CHILD | WS_VISIBLE |
1.1       root       69:                               LBS_NOINTEGRALHEIGHT | LBS_NOTIFY |
                     70:                               LBS_HASSTRINGS | LBS_WANTKEYBOARDINPUT |
                     71:                               LBS_DISABLENOSCROLL | WS_HSCROLL |
                     72:                               WS_VSCROLL |LBS_USETABSTOPS;
                     73: 
1.1.1.3 ! root       74:     DWORD dwFileStyle = WS_BORDER | WS_CHILD | WS_VISIBLE |
1.1       root       75:                                LBS_NOINTEGRALHEIGHT | LBS_NOTIFY |
                     76:                                LBS_HASSTRINGS | LBS_WANTKEYBOARDINPUT |
                     77:                                LBS_DISABLENOSCROLL | WS_HSCROLL |
                     78:                                LBS_EXTENDEDSEL | LBS_MULTIPLESEL |
                     79:                                LBS_MULTICOLUMN | LBS_SORT;
                     80: 
1.1.1.3 ! root       81:     switch (message){
1.1       root       82: 
                     83:         //
                     84:         // Creates the text and listbox windows for this Drv child and
                     85:         //  saves its handle in the per Drv child DRVCHILDINFO data structure.
                     86:         //
1.1.1.3 ! root       87:         case WM_CREATE: {
1.1       root       88:             LPCINFO lpCInfo;
                     89: 
                     90:             DWORD   dwLoop;
1.1.1.3 ! root       91: 
1.1       root       92:             LPDINFO lpWalk;
                     93: 
                     94:             LONG    lTabs = LISTBOX_TAB_SIZE;
                     95: 
1.1.1.3 ! root       96: 
        !            97:             //
        !            98:             // Initialize DRVCHILDINFO structure
        !            99:             //
        !           100:             lpCInfo = (LPCINFO) ((LPCREATESTRUCT) lParam)->lpCreateParams;
        !           101: 
        !           102:             lpCInfo->hwnd = hwnd;
        !           103: 
1.1       root      104:             // Create text window
1.1.1.3 ! root      105:             lpCInfo->hTextWnd = CreateWindow(TEXT("TextClass"), NULL,
1.1       root      106:                                     SS_LEFT | WS_CHILD | WS_VISIBLE | WS_BORDER,
                    107:                                     0, 0, 0, 0,
1.1.1.3 ! root      108:                                     lpCInfo->hwnd,
1.1       root      109:                                     (HMENU) TEXT_WINDOW_ID,
                    110:                                     ghModule,
                    111:                                     NULL);
                    112: 
1.1.1.3 ! root      113:             // Create Directory and File List boxes
        !           114:             lpCInfo->hDirLB = CreateWindow(TEXT("LISTBOX"), NULL,
1.1       root      115:                                     dwDirStyle,
                    116:                                     0, 0, 0, 0,
1.1.1.3 ! root      117:                                     lpCInfo->hwnd,
        !           118:                                     (HMENU) LISTDIR_ID,
1.1       root      119:                                     ghModule,
                    120:                                     NULL);
                    121: 
1.1.1.3 ! root      122:             lpCInfo->hFileLB = CreateWindow(TEXT("LISTBOX"), NULL,
1.1       root      123:                                     dwFileStyle,
                    124:                                     0, 0, 0, 0,
1.1.1.3 ! root      125:                                     lpCInfo->hwnd,
        !           126:                                     (HMENU) LISTFILE_ID,
1.1       root      127:                                     ghModule,
                    128:                                     NULL);
                    129: 
                    130:             //
1.1.1.3 ! root      131:             // fDirLeft indicates whether the Directory ListBox defaults to
        !           132:             //  the left side of each of the two drive windows.
        !           133:             // fDirExpand indicates whether the Directory Listbox defaults
        !           134:             //  to full expansion.
1.1       root      135:             //
1.1.1.3 ! root      136:             lpCInfo->fDirLeft = TRUE;
        !           137:             lpCInfo->fDirExpand = FALSE;
        !           138:             lpCInfo->fSuicide = FALSE;
1.1       root      139: 
                    140:             //
1.1.1.3 ! root      141:             // Create Mutex associated with each list box
1.1       root      142:             //
1.1.1.3 ! root      143:             lpCInfo->hDirMutex = CreateMutex(NULL, FALSE, NULL);
        !           144:             lpCInfo->hFileMutex = CreateMutex(NULL, FALSE, NULL);
1.1       root      145: 
                    146:             //
                    147:             // Associate window with the current directory LPDINFO structure
                    148:             //   from the Drives linked list
                    149:             //
                    150:             dwLoop = GetCurrentDirectory( DIRECTORY_STRING_SIZE,
                    151:                                           lpCInfo->CaptionBarText );
                    152:             CharUpper(lpCInfo->CaptionBarText);
                    153: 
1.1.1.3 ! root      154:             WaitForSingleObject(ghDrvThread, INFINITE);
1.1       root      155:             EnterCriticalSection(&gDrvCS);
                    156: 
                    157:             lpWalk = glpDrives;
                    158: 
                    159:             if( dwLoop && dwLoop <= DIRECTORY_STRING_SIZE ){
                    160:                 while( lpWalk && lpWalk->DriveName[0] !=
                    161:                        (lpCInfo->CaptionBarText)[0] )
                    162:                     lpWalk = lpWalk->next;
                    163:                 if( !lpWalk ){
1.1.1.3 ! root      164:                     ErrorMsg(TEXT("Drive Child Create: Drive list failure."));
1.1       root      165:                     LeaveCriticalSection(&gDrvCS);
                    166:                     return(-1);
                    167:                 }
                    168:             }
                    169:             else{
1.1.1.3 ! root      170:                 ErrorMsg(TEXT("Drive Child Create: GetCurrentDir failure."));
1.1       root      171:                 LeaveCriticalSection(&gDrvCS);
                    172:                 return(-1);
                    173:             }
                    174: 
                    175:             LeaveCriticalSection(&gDrvCS);
                    176: 
                    177:             lpCInfo->lpDriveInfo = lpWalk;
                    178: 
                    179:             //
                    180:             // Save the handle to DRVCHILDINFO in our window structure
                    181:             //
                    182:             SetWindowLong(hwnd, GWL_USERDATA, (LONG) lpCInfo);
                    183: 
                    184:             //
                    185:             // Initialize child windows
                    186:             //
1.1.1.3 ! root      187:             if( !SendMessage(lpCInfo->hDirLB, LB_SETTABSTOPS, (WPARAM)1,
1.1       root      188:                             (LPARAM)&lTabs) )
1.1.1.3 ! root      189:                 ErrorMsg(TEXT("Drv window Create: Set tab stop failure."));
1.1       root      190: 
                    191: 
                    192:             //
                    193:             // Set default font.
                    194:             //
1.1.1.3 ! root      195:             SendMessage(lpCInfo->hDirLB, WM_SETFONT, (WPARAM)ghFont, (LPARAM)FALSE);
        !           196:             SendMessage(lpCInfo->hFileLB, WM_SETFONT, (WPARAM)ghFont, (LPARAM)FALSE);
1.1       root      197: 
                    198:             SendMessage(hwnd, WM_COMMAND, (WPARAM)MM_REFRESH, (LPARAM)NULL);
                    199: 
                    200:             return(1);
1.1.1.3 ! root      201:         }
1.1       root      202: 
1.1.1.3 ! root      203:         case WM_COMMAND: {
1.1       root      204:           static LPCINFO     lpCInfo;
                    205:           static SELECTINFO  Select;
                    206: 
                    207:           //
                    208:           // Retrieving this child window's DRVCHILDINFO data for displaying
                    209:           //    messages in the text window
                    210:           //
                    211:           lpCInfo = (LPCINFO) GetWindowLong(hwnd, GWL_USERDATA);
                    212: 
1.1.1.3 ! root      213:           switch (LOWORD(wParam)){
1.1       root      214: 
                    215:             case MM_TAB:{
                    216:                 HWND    hFocus;
                    217: 
                    218:                 hFocus = GetFocus();
                    219: 
1.1.1.3 ! root      220:                 if( hFocus == lpCInfo->hDirLB )
        !           221:                     ghFocusWnd = lpCInfo->hFileLB;
1.1       root      222:                 else
1.1.1.3 ! root      223:                     if( hFocus == lpCInfo->hFileLB )
        !           224:                         ghFocusWnd = ghwndCommand;
1.1       root      225:                     else
                    226:                         if( hFocus == ghwndCommand)
1.1.1.3 ! root      227:                             ghFocusWnd = lpCInfo->hDirLB;
1.1       root      228: 
1.1.1.3 ! root      229:                 SetFocus( ghFocusWnd );
1.1       root      230:                 return(1);
                    231:             }
                    232: 
                    233:             //
                    234:             //  Clears the selection in the active window.
                    235:             //  Sent when user hits escape key.
                    236:             //
                    237:             case MM_ESCAPE:{
                    238:                 //
1.1.1.3 ! root      239:                 // If there is a directory expand in process, kill the
        !           240:                 //  thread, and leave the listbox in a semi-expanded state.
        !           241:                 //  Else, clear file selection, and switch to command window.
1.1       root      242:                 //
1.1.1.3 ! root      243:                 if( WaitForSingleObject( lpCInfo->hDirMutex, MUTEX_TIMEOUT)
        !           244:                         == WAIT_TIMEOUT ){
        !           245:                     lpCInfo->fSuicide = TRUE;
        !           246:                     lpCInfo->fEscape = TRUE;
        !           247:                 }
1.1       root      248:                 else
1.1.1.3 ! root      249:                     ReleaseMutex( lpCInfo->hDirMutex );
1.1       root      250: 
1.1.1.3 ! root      251:                 SendMessage(lpCInfo->hFileLB, LB_SETCURSEL, (WPARAM)-1,
        !           252:                                (LPARAM)0);
        !           253: 
        !           254:                 SetFocus( ghwndCommand );
        !           255:                 ghFocusWnd = ghwndCommand;
        !           256:                 SendMessage(ghwndCommand, LB_SETCURSEL, (WPARAM)0,
        !           257:                                (LPARAM)-1);
1.1       root      258:                 return(1);
                    259:             }
                    260: 
                    261:             case MM_OPEN:{
1.1.1.3 ! root      262:                 if( ghFocusWnd == lpCInfo->hFileLB )
        !           263:                     OpenListBoxItem(lpCInfo);
        !           264:                 else
        !           265:                     if( ghFocusWnd == lpCInfo->hDirLB ){
        !           266:                         if( !PostMessage(hwnd, WM_COMMAND, MM_FILLDIR,
        !           267:                                          (LPARAM)0) ){
        !           268:                             ErrorMsg(TEXT("MM_OPEN: Filldir failure."));
        !           269:                             return(0);
        !           270:                         }
        !           271:                     }
        !           272:                     else
        !           273:                         RunCommandItem(lpCInfo);
1.1       root      274: 
                    275:                 return(1);
                    276:             }
                    277: 
1.1.1.3 ! root      278:             case MM_COPY:{
1.1       root      279: 
                    280:                 Select.hwnd = hwnd;
                    281:                 Select.dwAction = MM_COPY;
1.1.1.3 ! root      282:                 Select.szAction = TEXT("COPYING:");
        !           283:                 Select.szToFrom = TEXT("TO:");
1.1       root      284: 
                    285:                 ExecuteFileAction(&Select);
                    286: 
                    287:                 return(1);
                    288:             }
                    289: 
1.1.1.3 ! root      290:             case MM_DELETE:{
1.1       root      291: 
                    292:                 Select.hwnd = hwnd;
                    293:                 Select.dwAction = MM_DELETE;
1.1.1.3 ! root      294:                 Select.szAction = TEXT("DELETING:");
        !           295:                 Select.szToFrom = TEXT("FROM:");
1.1       root      296: 
                    297:                 ExecuteFileAction(&Select);
                    298: 
                    299:                 return(1);
                    300:             }
                    301: 
1.1.1.3 ! root      302:             case MM_MOVE:{
1.1       root      303: 
                    304:                 Select.hwnd = hwnd;
                    305:                 Select.dwAction = MM_MOVE;
1.1.1.3 ! root      306:                 Select.szAction = TEXT("MOVING:");
        !           307:                 Select.szToFrom = TEXT("TO:");
1.1       root      308: 
                    309:                 ExecuteFileAction(&Select);
                    310: 
                    311:                 return(1);
                    312:             }
                    313: 
1.1.1.3 ! root      314:             case MM_RENAME:{
1.1       root      315: 
1.1.1.3 ! root      316:                 if( DialogBoxParam(ghModule, TEXT("RenameDlg"), hwnd,
1.1       root      317:                               (DLGPROC)RenameProc, (LPARAM)lpCInfo) == -1 ){
1.1.1.3 ! root      318:                     ErrorMsg(TEXT("DriveProc: Rename Dialog Creation failure."));
1.1       root      319:                     return(0);
                    320:                 }
                    321: 
                    322:                 return(1);
                    323:             }
                    324: 
1.1.1.3 ! root      325:             case MM_MKDIR:{
1.1       root      326: 
1.1.1.3 ! root      327:                 if( DialogBoxParam(ghModule, TEXT("MkDirDlg"), hwnd,
1.1       root      328:                               (DLGPROC)MkDirProc, (LPARAM)lpCInfo) == -1 ){
1.1.1.3 ! root      329:                     ErrorMsg(TEXT("DriveProc: MkDir Dialog Creation failure."));
        !           330:                     return(0);
        !           331:                 }
        !           332: 
        !           333:                 return(1);
        !           334:             }
        !           335: 
        !           336:             case MM_VERSION:{
        !           337: 
        !           338:                 if( DialogBoxParam(ghModule, TEXT("VersionInfoDlg"), hwnd,
        !           339:                               (DLGPROC)VersionProc, (LPARAM)lpCInfo) == -1 ){
        !           340:                     ErrorMsg(TEXT("DriveProc: Version Info Dialog Creation failure."));
1.1       root      341:                     return(0);
                    342:                 }
                    343: 
                    344:                 return(1);
                    345:             }
                    346: 
1.1.1.3 ! root      347:             case MM_EXPAND:{
        !           348: 
        !           349:                 lpCInfo->fDirExpand = !lpCInfo->fDirExpand;
        !           350: 
        !           351:                 if( lpCInfo->fDirExpand )
        !           352:                     CheckMenuItem( ghMenu, MM_EXPAND,
        !           353:                                     MF_BYCOMMAND | MF_CHECKED);
        !           354:                 else
        !           355:                     CheckMenuItem( ghMenu, MM_EXPAND,
        !           356:                                 MF_BYCOMMAND | MF_UNCHECKED);
        !           357: 
        !           358:                 if( !SendMessage( (HWND)lpCInfo->hwnd, WM_COMMAND,
        !           359:                                  (WPARAM)MM_REFRESH, (LPARAM)0 ) ){
        !           360:                     ErrorMsg(TEXT("MM_EXPAND:  MM_REFRESH failure."));
        !           361:                     return(0);
        !           362:                 }
        !           363:                 return(1);
        !           364:             }
        !           365: 
1.1       root      366:             //
                    367:             // refreshes contents of directory and file ListBoxes.
                    368:             //
                    369:             case MM_REFRESH:{
                    370: 
1.1.1.3 ! root      371:                 DWORD   dwThreadID;
        !           372: 
        !           373:                 if( WaitForSingleObject( lpCInfo->hDirMutex, MUTEX_TIMEOUT)
        !           374:                         == WAIT_TIMEOUT )
        !           375:                     //
        !           376:                     // If the full directory expand has been cancled, kill the
        !           377:                     //  existing thread.
        !           378:                     //
        !           379:                     if( !lpCInfo->fDirExpand && !lpCInfo->fSuicide){
        !           380:                         lpCInfo->fSuicide = TRUE;
        !           381:                         return(1);
        !           382:                     }
        !           383:                     else{
        !           384:                         return(0);
        !           385:                     }
        !           386: 
        !           387:                 // if set, clear the expand dir. user abort (escape key) flag.
        !           388:                 if( lpCInfo->fEscape ){
        !           389:                     lpCInfo->fEscape = FALSE;
        !           390:                     ReleaseMutex( lpCInfo->hDirMutex );
        !           391:                     return(1);
1.1       root      392:                 }
1.1.1.3 ! root      393: 
        !           394:                 // At this point, the Dir LB mutex has been grabbed.
        !           395: 
        !           396:                 // Clear directory LB.  If expand flag is set, expand all
        !           397:                 //  directories.  Refill File LB.
        !           398:                 //
        !           399:                 if( SendMessage( lpCInfo->hDirLB, LB_RESETCONTENT,
        !           400:                                  (WPARAM)0, (LPARAM)0 ) < 0 ){
        !           401:                     ErrorMsg(TEXT("Refresh Drv window: Reset Dir LB content failure."));
        !           402:                     ReleaseMutex( lpCInfo->hDirMutex );
        !           403:                     return(0);
        !           404:                 }
        !           405: 
        !           406:                 //
        !           407:                 // This call puts the default root entry back into the empty
        !           408:                 //  LB.  Set suicide flag to false to ensure it will complete.
        !           409:                 //
        !           410:                 lpCInfo->fSuicide = FALSE;
        !           411:                 ExpDir( lpCInfo );
        !           412: 
        !           413:                 //
        !           414:                 // All the Dir LB work is done.  Release Dir LB Mutex.
        !           415:                 //
        !           416:                 ReleaseMutex( lpCInfo->hDirMutex );
        !           417: 
        !           418:                 if( lpCInfo->fDirExpand ){
        !           419: 
        !           420:                     CloseHandle( lpCInfo->hDirThread );
        !           421: 
        !           422:                     lpCInfo->hDirThread = CreateThread( NULL, 0,
        !           423:                                   (LPTHREAD_START_ROUTINE)FullExpand,
        !           424:                                   (LPVOID)lpCInfo, 0, &dwThreadID);
        !           425: 
        !           426:                     if( !lpCInfo->hDirThread ){
        !           427:                         ErrorMsg(TEXT("MM_REFRESH: FullExpand CreateThread failure."));
        !           428:                         return(0);
        !           429:                     }
        !           430:                 }
        !           431:                 else
        !           432:                     ExpDir( lpCInfo );
        !           433: 
        !           434:                 if( !PostMessage(hwnd, WM_COMMAND, MM_FILLFILE,
        !           435:                                  (LPARAM)0) ){
        !           436:                     ErrorMsg(TEXT("Refresh Drv window: Fillfile failure."));
        !           437:                     return(0);
1.1       root      438:                 }
                    439: 
                    440:                 return(1);
                    441:             }
                    442: 
                    443:             //
                    444:             //  Fill listbox in lParam with directory from Drv child's drive.
                    445:             //  Sent by MM_REFRESH.
                    446:             //
1.1.1.3 ! root      447:             //  lParam == 0
        !           448:             //
1.1       root      449:             case MM_FILLDIR:{
                    450: 
                    451:                 DWORD   dwThreadID;
                    452: 
1.1.1.3 ! root      453:                 lpCInfo->fSuicide = FALSE;
        !           454: 
        !           455:                 CloseHandle( lpCInfo->hDirThread );
1.1       root      456: 
                    457:                 lpCInfo->hDirThread = CreateThread( NULL, 0,
1.1.1.3 ! root      458:                               (LPTHREAD_START_ROUTINE)ExpDir,
        !           459:                               (LPVOID)lpCInfo, 0, &dwThreadID);
1.1       root      460: 
                    461:                 if( !(lpCInfo->hDirThread) ){
1.1.1.3 ! root      462:                     ErrorMsg(TEXT("MM_FILLDIR: ExpDir CreateThread failure."));
1.1       root      463:                     return(0);
                    464:                 }
                    465: 
                    466:                 return(1);
                    467:             }
                    468: 
                    469:             //
                    470:             //  Fill listbox in lParam with files from current directory.
                    471:             //  Sent by MM_REFRESH & LBN_DBLCLK in DrvWndProc, as well as
                    472:             //  DoFileIO. and HandleIOError().
                    473:             //
1.1.1.3 ! root      474:             //  lParam == 0
        !           475:             //
1.1       root      476:             case MM_FILLFILE:{
1.1.1.3 ! root      477:                 TCHAR               szFiles[DIRECTORY_STRING_SIZE + 20];
        !           478:                 LPTSTR              lpHold;
1.1       root      479: 
1.1.1.3 ! root      480:                 if( WaitForSingleObject( lpCInfo->hFileMutex, MUTEX_TIMEOUT)
        !           481:                         == WAIT_TIMEOUT ){
        !           482:                     ErrorMsg(TEXT("MM_FILLFILE: File LB Mutex Timeout."));
        !           483:                     return(0);
        !           484:                 }
1.1       root      485: 
                    486: 
                    487:                 //
                    488:                 // Not checking for errors here, as LB_RESETCONTENT always
                    489:                 //  returns true, and LB_DIR returns an error if the directory
                    490:                 //  is empty.
                    491:                 //
1.1.1.3 ! root      492:                 SendMessage(lpCInfo->hFileLB, LB_RESETCONTENT, (WPARAM)NULL, (LPARAM)NULL);
1.1       root      493: 
                    494:                 lstrcpy( szFiles, lpCInfo->CaptionBarText );
1.1.1.3 ! root      495:                 lpHold = TStrChr(szFiles, TEXT('\0'));
1.1       root      496:                 lpHold--;
1.1.1.3 ! root      497:                 if( *lpHold != TEXT('\\') ){
        !           498:                     lpHold++;
        !           499:                     *lpHold = TEXT('\\');
        !           500:                 }
1.1       root      501: 
1.1.1.3 ! root      502:                 lpHold++;
        !           503:                 lstrcpy( lpHold, TEXT("*.*"));
        !           504: 
        !           505:                 if( SendMessage( lpCInfo->hFileLB, LB_DIR, (WPARAM)0x10,
1.1       root      506:                                  (LPARAM)szFiles ) == LB_ERR ){
1.1.1.3 ! root      507:                     ErrorMsg(TEXT("MM_FILLFILE:  Fill ListBox failure."));
        !           508:                     ReleaseMutex( lpCInfo->hFileMutex );
        !           509:                     return(0);
        !           510:                 }
        !           511: 
        !           512:                 //
        !           513:                 //  Set selection to first file.
        !           514:                 //
        !           515:                 if( SendMessage( lpCInfo->hFileLB, LB_SETSEL, (WPARAM)TRUE,
        !           516:                                  (LPARAM)0 ) == LB_ERR ){
        !           517:                     ErrorMsg(TEXT("MM_FILLFILE:  Listbox selection failure."));
        !           518:                     ReleaseMutex( lpCInfo->hFileMutex );
1.1       root      519:                     return(0);
                    520:                 }
                    521: 
                    522:                 SetWindowText(lpCInfo->hTextWnd, lpCInfo->CaptionBarText);
                    523: 
1.1.1.3 ! root      524:                 ReleaseMutex( lpCInfo->hFileMutex );
1.1       root      525: 
                    526:                 return(1);
                    527:             }
                    528: 
1.1.1.3 ! root      529:             //
        !           530:             //  Toggle active status of drive child.
        !           531:             //
1.1       root      532:             case MM_TOGGLE:{
                    533: 
1.1.1.3 ! root      534:                 SetWindowText(lpCInfo->hTextWnd, lpCInfo->CaptionBarText);
1.1       root      535:                 return(1);
                    536:             }
                    537: 
                    538:             //
                    539:             // The following WM_COMMAND messages are sent by the listboxes
                    540:             //
1.1.1.3 ! root      541:             // HIWORD(wParam) = LB notification message
        !           542:             // lParam = LB window handle
        !           543:             //
        !           544:             case LISTFILE_ID:{
1.1       root      545:               switch( HIWORD(wParam) ){
                    546:                 //
                    547:                 // In case of double click on a directory, expand the file
1.1.1.3 ! root      548:                 // Listbox. if on a file name, run or edit file.
1.1       root      549:                 //
                    550:                 case LBN_DBLCLK:{
1.1.1.3 ! root      551:                     OpenListBoxItem(lpCInfo);
1.1       root      552:                     return(1);
                    553:                 }
                    554:                 break;
                    555: 
                    556:                 case LBN_SETFOCUS:{
1.1.1.3 ! root      557:                     ghFocusWnd = lpCInfo->hFileLB;
1.1       root      558:                 }
                    559:                 break;
                    560: 
                    561:                 default:
                    562:                     return(1);
                    563:               }
1.1.1.3 ! root      564:             } // LISTFILE_ID
1.1       root      565:             break;
                    566: 
1.1.1.3 ! root      567:             //
        !           568:             // Notification from the Directory ListBox
        !           569:             //
        !           570:             case LISTDIR_ID:{
        !           571:               switch( HIWORD(wParam) ){
        !           572: 
        !           573:                 case LBN_SETFOCUS:{
        !           574:                     ghFocusWnd = lpCInfo->hDirLB;
        !           575:                 }
        !           576:                 break;
1.1       root      577: 
1.1.1.3 ! root      578:                 //
        !           579:                 // Expand subdirectories in dir listbox
        !           580:                 //
        !           581:                 case LBN_DBLCLK:{
1.1       root      582: 
1.1.1.3 ! root      583:                     if( !PostMessage(hwnd, WM_COMMAND, MM_FILLDIR,
        !           584:                                      (LPARAM)0) ){
        !           585:                         ErrorMsg(TEXT("Dir ListBox Notify: Filldir failure."));
        !           586:                         return(0);
        !           587:                     }
        !           588:                     return(1);
        !           589:                 }
        !           590:                 break;
        !           591: 
        !           592:                 case LBN_SELCHANGE:{
        !           593:                     //
        !           594:                     // for the Directory LB, fill the
        !           595:                     // corresp. File LB with items in the newly selected dir.
        !           596:                     //
        !           597:                     LONG lIndex;
        !           598: 
        !           599: 
        !           600:                     if( WaitForSingleObject( lpCInfo->hDirMutex, MUTEX_TIMEOUT)
        !           601:                             == WAIT_TIMEOUT ){
        !           602:                         ErrorMsg(TEXT("Dir LB Notify: Dir LB Mutex Timeout."));
        !           603:                         return(0);
        !           604:                     }
        !           605: 
        !           606:                     //
        !           607:                     // Retrieve selected (careted) item.
        !           608:                     //
        !           609:                     lIndex = SendMessage( (HWND)lParam, LB_GETCARETINDEX,
        !           610:                                         (WPARAM)NULL, (LPARAM)NULL );
        !           611: 
        !           612:                     if( !ConstructDirName(lpCInfo, lIndex,
        !           613:                                           lpCInfo->CaptionBarText) ){
        !           614:                         ErrorMsg(TEXT("Dir LB Notify:  ConstructDirName failure."));
        !           615:                         ReleaseMutex( lpCInfo->hDirMutex );
        !           616:                         return(0);
        !           617:                     }
        !           618: 
        !           619:                     ReleaseMutex( lpCInfo->hDirMutex );
        !           620: 
        !           621:                     if( !PostMessage(hwnd, WM_COMMAND, MM_FILLFILE,
        !           622:                                      (LPARAM)0) ){
        !           623:                         ErrorMsg(TEXT("Dir ListBox Notify: Fillfile failure."));
        !           624:                         return(0);
        !           625:                     }
        !           626:                 } // LBN_SELCHANGE
        !           627:                 break;
        !           628: 
        !           629:                 default:
        !           630:                     return(1);
        !           631:               }
        !           632:             } //  LISTDIR_ID
        !           633:             break;
        !           634: 
        !           635:             default:
        !           636:                return(1);
        !           637:           }
        !           638:         }
1.1       root      639:         break;
                    640: 
                    641:         //
                    642:         // Whenever the Drv child window is resized, its children has to be
                    643:         //  resized accordingly.  The GetWindowLong GWL_USERDATA values
                    644:         //  contain the height of the windows queried, set in their respective
                    645:         //  WM_CREATE cases.
                    646:         //
1.1.1.3 ! root      647:         case WM_SIZE: {
1.1       root      648:             LPCINFO     lpCInfo;
                    649: 
1.1.1.3 ! root      650:             int         nListHeight,
        !           651:                         nListWidth;
        !           652: 
        !           653:             HWND        hLeftLB,
        !           654:                         hRightLB;
1.1       root      655: 
                    656:             //
                    657:             // First, get the text window's handle from the per Drv child
                    658:             //  DRVCHILDINFO data structure
                    659:             //
                    660:             lpCInfo = (LPCINFO)GetWindowLong(hwnd, GWL_USERDATA);
                    661: 
                    662:             nListHeight = HIWORD(lParam) -
                    663:                           GetWindowLong(lpCInfo->hTextWnd, GWL_USERDATA)
                    664:                           - LIST_BORDER * 2;
                    665: 
                    666:             nListWidth = (LOWORD(lParam) - LIST_BORDER) / 2 - LIST_BORDER;
                    667: 
                    668:             //
                    669:             // Always, put the text window at the top of the Drv window.
                    670:             // Increasing sides and bottom extents by 1 to overlap border
                    671:             //   with Drv child border
                    672:             //
1.1.1.3 ! root      673:             MoveWindow(lpCInfo->hTextWnd,
        !           674:                        -1,
1.1       root      675:                        0,
1.1.1.3 ! root      676:                        LOWORD(lParam) + 2,
        !           677:                        GetWindowLong(lpCInfo->hTextWnd, GWL_USERDATA) + 1,
1.1       root      678:                        TRUE);
                    679: 
1.1.1.3 ! root      680:             if( lpCInfo->fDirLeft ){
        !           681:                 hLeftLB = lpCInfo->hDirLB;
        !           682:                 hRightLB = lpCInfo->hFileLB;
        !           683:             }
        !           684:             else{
        !           685:                 hLeftLB = lpCInfo->hFileLB;
        !           686:                 hRightLB = lpCInfo->hDirLB;
        !           687:             }
        !           688: 
        !           689:             MoveWindow(hLeftLB,
1.1       root      690:                        LIST_BORDER,
1.1.1.3 ! root      691:                        GetWindowLong(lpCInfo->hTextWnd, GWL_USERDATA) + 1
1.1       root      692:                          + LIST_BORDER,
                    693:                        nListWidth,
                    694:                        nListHeight,
                    695:                        TRUE);
                    696: 
1.1.1.3 ! root      697:             MoveWindow(hRightLB,
1.1       root      698:                        (LOWORD(lParam) + LIST_BORDER) / 2,
1.1.1.3 ! root      699:                        GetWindowLong(lpCInfo->hTextWnd, GWL_USERDATA) + 1
1.1       root      700:                          + LIST_BORDER,
                    701:                        nListWidth,
                    702:                        nListHeight,
                    703:                        TRUE);
                    704: 
1.1.1.3 ! root      705:         break;
1.1       root      706:         }
                    707: 
                    708:         case WM_PARENTNOTIFY:{
                    709:             LPCINFO lpCInfo;
                    710: 
                    711:             if(wParam == WM_LBUTTONDOWN){
                    712:                 lpCInfo = (LPCINFO) GetWindowLong(hwnd, GWL_USERDATA);
                    713:                 if(lpCInfo == NULL){
1.1.1.3 ! root      714:                     ErrorMsg(TEXT("Drv child: Parent notify failure."));
1.1       root      715:                     return(1);
                    716:                 }
1.1.1.3 ! root      717:                 if(HIWORD(wParam) == LISTDIR_ID)
        !           718:                     SetFocus(lpCInfo->hDirLB);
1.1       root      719:                 else
1.1.1.3 ! root      720:                     if(HIWORD(wParam) == LISTFILE_ID)
        !           721:                         SetFocus(lpCInfo->hFileLB);
1.1       root      722:                     else
                    723:                         if(HIWORD(wParam) == TEXT_WINDOW_ID)
                    724:                             SetFocus(lpCInfo->hTextWnd);
                    725:             }
                    726: 
                    727:             break;
                    728:         }
                    729: 
                    730:         //
                    731:         // Same as MainWndProc's MM_ACTIVEDRV case.  The initial PostMessage
                    732:         //   is so the currently active Drv child will not process the message
                    733:         //   until it is no longer in focus.
                    734:         //
                    735:         case WM_MOUSEACTIVATE:{
                    736:             LPCINFO lpCInfo;
                    737: 
                    738:             PostMessage(ghActiveChild, WM_COMMAND, (WPARAM)MM_TOGGLE,
                    739:                         (LPARAM)NULL);
                    740:             ghActiveChild = hwnd;
                    741:             SendMessage(ghActiveChild, WM_COMMAND, (WPARAM)MM_TOGGLE,
                    742:                         (LPARAM)NULL);
                    743: 
                    744:             lpCInfo = (LPCINFO) GetWindowLong(hwnd, GWL_USERDATA);
                    745:             SendMessage(ghwndDrives, WM_COMMAND, MM_ACTIVEDRV,
                    746:                         (LPARAM)lpCInfo->lpDriveInfo);
                    747: 
                    748:             break;
                    749:         }
                    750: 
                    751:         //
                    752:         // Free the DRVCHILDINFO data that associates with this window
                    753:         //  also, reset the menu.
                    754:         //
1.1.1.3 ! root      755:         case WM_CLOSE: {
1.1       root      756:             LPCINFO lpCInfo;
                    757: 
1.1.1.3 ! root      758:             lpCInfo = (LPCINFO)GetWindowLong(hwnd, GWL_USERDATA);
1.1       root      759: 
1.1.1.3 ! root      760:             CloseHandle(lpCInfo->hDirMutex );
        !           761:             CloseHandle(lpCInfo->hFileMutex );
1.1       root      762: 
                    763:             EnterCriticalSection(&gHeapCS);
1.1.1.3 ! root      764:             HeapFree(ghHeap, 0, (LPVOID)lpCInfo);
1.1       root      765:             LeaveCriticalSection(&gHeapCS);
                    766: 
                    767:             break;
1.1.1.3 ! root      768:         }
1.1       root      769: 
1.1.1.3 ! root      770:         default:
        !           771:             return DefWindowProc(hwnd, message, wParam, lParam);
1.1       root      772: 
                    773:     } //switch
                    774:     return DefWindowProc(hwnd, message, wParam, lParam);
                    775: }
                    776: 
                    777: 
                    778: /***************************************************************************\
                    779: *
1.1.1.3 ! root      780: * GetLBText()
        !           781: *
        !           782: * Gets the text of the currently selected (careted) item in the given
        !           783: *   listbox.
1.1       root      784: *
1.1.1.3 ! root      785: * Returns:  Index of selected item if successful, -1 on failure
1.1       root      786: *
                    787: * History:
1.1.1.3 ! root      788: * 4/26/93
1.1       root      789: *   Created.
                    790: *
                    791: \***************************************************************************/
1.1.1.3 ! root      792: LONG GetLBText(HWND hActiveLB, PTCHAR szItemBuff)
1.1       root      793: {
1.1.1.3 ! root      794:     LONG    lIndex;
1.1       root      795: 
1.1.1.3 ! root      796:     //
        !           797:     // Retrieve selected (careted) item.
        !           798:     //
        !           799:     lIndex = SendMessage( hActiveLB, LB_GETCARETINDEX,
        !           800:                           (WPARAM)NULL, (LPARAM)NULL );
        !           801: 
        !           802:     if( SendMessage( hActiveLB, LB_GETTEXT, (WPARAM)lIndex,
        !           803:                      (LPARAM)szItemBuff) == LB_ERR ){
        !           804:         ErrorMsg(TEXT("LBN_DBLCLK: Text retrieval failure."));
        !           805:         return(-1);
        !           806:     }
        !           807: 
        !           808:     return( lIndex );
1.1       root      809: }
                    810: 
                    811: 
                    812: /***************************************************************************\
                    813: *
1.1.1.3 ! root      814: * UpdateFileLB()
1.1       root      815: *
1.1.1.3 ! root      816: * Updates the file listbox of the drive child given by sending an MM_FILLFILE
        !           817: *   message to it.
        !           818: *
        !           819: *  input:   hwnd    -   Handle of drive child to update file listbox of.
1.1       root      820: *
                    821: * History:
1.1.1.3 ! root      822: * 6/3/92
1.1       root      823: *   Created.
                    824: *
                    825: \***************************************************************************/
1.1.1.3 ! root      826: void UpdateFileLB(HWND hwnd)
1.1       root      827: {
                    828:     LPCINFO lpCInfo;
                    829: 
1.1.1.3 ! root      830:     lpCInfo = (LPCINFO)GetWindowLong(hwnd, GWL_USERDATA);
1.1       root      831: 
1.1.1.3 ! root      832:     SendMessage(hwnd, WM_COMMAND, (WPARAM)MM_FILLFILE,
        !           833:                 (LPARAM)0);
1.1       root      834: }
                    835: 
                    836: 
                    837: /***************************************************************************\
                    838: *
                    839: * OpenListBoxItem()
                    840: *
1.1.1.3 ! root      841: * Attempts to expand a selected File list box directory entry into an available
1.1       root      842: *  file listbox, or spawn a selected list box file.
                    843: *
                    844: *  input:   lpCInfo   -   pointer to Drv child's LPCINFO structure
                    845: *
                    846: * History:
                    847: * 5/27/92
                    848: *   Created.
                    849: *
                    850: \***************************************************************************/
1.1.1.3 ! root      851: BOOL OpenListBoxItem(LPCINFO lpCInfo)
1.1       root      852: {
1.1.1.3 ! root      853:     TCHAR   szItemBuff[DIRECTORY_STRING_SIZE];
1.1       root      854: 
                    855:     //
                    856:     // Retrieve selected (careted) item.
                    857:     //
1.1.1.3 ! root      858:     GetLBText(lpCInfo->hFileLB, szItemBuff);
1.1       root      859: 
                    860:     //
1.1.1.3 ! root      861:     // Determine whether the item is a directory or a file.
        !           862:     //   If file, Run if possible.
        !           863:     //
        !           864:     if( !IsDirectory(lpCInfo->CaptionBarText, szItemBuff) ){
        !           865:         RunListBoxItem(lpCInfo);
        !           866:         return(1);
        !           867:         }
1.1       root      868: 
                    869:     //
1.1.1.3 ! root      870:     // It is a directory.  Set the new caption text, and expand files.
1.1       root      871:     //
                    872:     lstrcpy( lpCInfo->CaptionBarText, szItemBuff);
                    873: 
1.1.1.3 ! root      874:     if( !PostMessage(lpCInfo->hwnd, WM_COMMAND, MM_FILLFILE,
        !           875:                         (LPARAM)0) ){
        !           876:         ErrorMsg(TEXT("OpenListBoxItem: Fillfile failure."));
        !           877:         return(0);
        !           878:     }
        !           879: 
1.1       root      880:     return(1);
                    881: }
                    882: 
                    883: /***************************************************************************\
                    884: *
                    885: * RunListBoxItem()
                    886: *
                    887: * Attempts to spawn the selected list box file. If the file is not executable,
                    888: *   attempts to spawn an editor to edit the file.
                    889: *
                    890: *  input:   lpCInfo   -   pointer to Drv child's LPCINFO structure
                    891: *
                    892: * History:
                    893: * 5/27/92
                    894: *   Created.
                    895: *
1.1.1.3 ! root      896: * 5/12/93
        !           897: *   Modified.
        !           898: *
1.1       root      899: \***************************************************************************/
1.1.1.3 ! root      900: BOOL RunListBoxItem(LPCINFO lpCInfo)
1.1       root      901: {
                    902:     LONG        lIndex;
1.1.1.3 ! root      903:     TCHAR       szFileBuff[DIRECTORY_STRING_SIZE];
        !           904:     TCHAR       szCmdLine[DIRECTORY_STRING_SIZE * 2];
        !           905:     LPTSTR      szHold;
1.1       root      906: 
                    907:     STARTUPINFO si;
                    908:     PROCESS_INFORMATION pi;
                    909: 
                    910: 
                    911:     lstrcpy(szCmdLine, lpCInfo->CaptionBarText);
1.1.1.3 ! root      912: 
        !           913:     lstrcat(szCmdLine, TEXT("\\"));
1.1       root      914: 
                    915:     //
                    916:     // Get file that was opened, and attempt to spawn. If fails, attempt to
                    917:     // edit it.
                    918:     //
                    919: 
1.1.1.3 ! root      920:     //
        !           921:     // Retrieve selected (careted) item.
        !           922:     //
        !           923:     lIndex = GetLBText(lpCInfo->hFileLB, szFileBuff);
        !           924:     if( !lIndex )
1.1       root      925:         return(0);
                    926: 
                    927:     //
1.1.1.3 ! root      928:     // Don't assume the file has an extension. if no '.', insert one at end
        !           929:     //  of file, so spawned editor will not assume any default extension.
        !           930:     //  (i.e. Notepad assumes a .TXT if no extension is given.)
1.1       root      931:     //
1.1.1.3 ! root      932:     szHold = TStrChr(szFileBuff, TEXT('.'));
1.1       root      933:     if( !szHold ){
1.1.1.3 ! root      934:         szHold = TStrChr(szFileBuff, TEXT('\0'));
        !           935:         *szHold = TEXT('.');
        !           936:         *(szHold + sizeof(TCHAR)) = TEXT('\0');
1.1       root      937:     }
                    938: 
                    939:     si.cb = sizeof(STARTUPINFO);
                    940:     si.lpReserved = NULL;
                    941:     si.lpDesktop = NULL;
                    942:     si.lpTitle = NULL;
1.1.1.3 ! root      943:     si.dwFlags = 0;
1.1       root      944:     si.cbReserved2 = 0;
                    945:     si.lpReserved2 = NULL;
                    946: 
                    947:     //
                    948:     // Convert file to uppercase for extension comparison.  Raise the
                    949:     //   priority of this thread for the duration of the create process code.
                    950:     //   This is so the CreateProcess will not be held up by the directory
                    951:     //   fill threads.
                    952:     //   If an executable extension, spawn, else edit.
                    953:     //
                    954:     CharUpper(szFileBuff);
                    955: 
                    956:     SetThreadPriority( GetCurrentThread(), THREAD_PRIORITY_HIGHEST);
                    957: 
                    958:     for(lIndex = 0; lIndex < NUM_EXTENSION_STRINGS; lIndex++)
                    959:         if( !lstrcmp(szHold, &gszExtensions[lIndex][0]) ){
                    960: 
                    961:             lstrcat(szCmdLine, szFileBuff);
                    962: 
                    963:             if( !CreateProcess(NULL, (LPCTSTR)szCmdLine, NULL, NULL, FALSE,
                    964:                                CREATE_NEW_CONSOLE | NORMAL_PRIORITY_CLASS,
                    965:                                NULL, lpCInfo->CaptionBarText, &si, &pi) ){
1.1.1.3 ! root      966:                 ErrorMsg(TEXT("RunListBoxItem: Unable to spawn file."));
1.1       root      967:                 return(0);
                    968:             }
1.1.1.3 ! root      969: 
        !           970:             CloseHandle( pi.hProcess );
        !           971:             CloseHandle( pi.hThread );
        !           972: 
1.1       root      973:             return(1);
                    974:         }
                    975: 
                    976:     LoadString(ghModule, STR_DEF_EDITOR, szCmdLine,
                    977:                DIRECTORY_STRING_SIZE * 2);
1.1.1.3 ! root      978:     lstrcat(szCmdLine, TEXT(" "));
1.1       root      979:     lstrcat(szCmdLine, szFileBuff);
                    980: 
                    981:     if( !CreateProcess(NULL, szCmdLine, NULL, NULL, FALSE,
                    982:                        CREATE_NEW_CONSOLE | NORMAL_PRIORITY_CLASS,
                    983:                        NULL, lpCInfo->CaptionBarText, &si, &pi) ){
1.1.1.3 ! root      984:         ErrorMsg(TEXT("RunListBoxItem: Unable to edit file."));
1.1       root      985:         return(0);
                    986:     }
                    987: 
1.1.1.3 ! root      988:     CloseHandle( pi.hProcess );
        !           989:     CloseHandle( pi.hThread );
        !           990: 
1.1       root      991:     SetThreadPriority( GetCurrentThread(), THREAD_PRIORITY_NORMAL);
                    992: 
                    993:     return(1);
                    994: }
                    995: 
                    996: 
                    997: /***************************************************************************\
                    998: *
1.1.1.3 ! root      999: * FilerGetVersion()
        !          1000: *
        !          1001: *  Given an item from a File ListBox, GetVersion retrieves the version
        !          1002: *    information from the specified file.
        !          1003: *
        !          1004: *  input:   lpszFileName   -   the name of the file.
        !          1005: *           dwBuffSize     -   > 0 size of buffer to hold version info
        !          1006: *           szBuff         -   buffer to hold version info
        !          1007: *
        !          1008: *  returns: TRUE if successful, FALSE otherwise.
        !          1009: *
        !          1010: *  comments:  gVKArray would need a critical section if this function were
        !          1011: *             to be called by more than one thread.
        !          1012: *
        !          1013: * History:
        !          1014: * 2/23/93
        !          1015: *   Created.
        !          1016: *
        !          1017: \***************************************************************************/
        !          1018: BOOL FilerGetVersion(LPTSTR lpszFileName, DWORD dwBuffSize, LPTSTR szBuff)
        !          1019: {
        !          1020:     //
        !          1021:     // NUM_VERSION_INFO_KEYS in GLOBALS.H should be set to the number of entries in
        !          1022:     //   VersionKeys[].
        !          1023:     //
        !          1024:     CONST static TCHAR   *VersionKeys[] = {
        !          1025:             TEXT("ProductName"),
        !          1026:             TEXT("ProductVersion"),
        !          1027:             TEXT("OriginalFilename"),
        !          1028:             TEXT("FileDescription"),
        !          1029:             TEXT("FileVersion"),
        !          1030:             TEXT("CompanyName"),
        !          1031:             TEXT("LegalCopyright"),
        !          1032:             TEXT("LegalTrademarks"),
        !          1033:             TEXT("InternalName"),
        !          1034:             TEXT("PrivateBuild"),
        !          1035:             TEXT("SpecialBuild"),
        !          1036:             TEXT("Comments")
        !          1037:     };
        !          1038: 
        !          1039:     static TCHAR szNull[1] = TEXT("");
        !          1040:     LPVOID  lpInfo;
        !          1041:     DWORD   cch;
        !          1042:     UINT    i;
        !          1043:     TCHAR   key[80];
        !          1044: 
        !          1045:     GetFileVersionInfo(lpszFileName, 0, dwBuffSize, (LPVOID)szBuff );
        !          1046: 
        !          1047:     for (i = 0; i < NUM_VERSION_INFO_KEYS; i++) {
        !          1048:         lstrcpy(key, VERSION_INFO_KEY_ROOT);
        !          1049:         lstrcat(key, VERSION_INFO_LANG_ID);
        !          1050:         lstrcat(key, "\\");
        !          1051:         lstrcat(key, VersionKeys[i]);
        !          1052:         gVKArray[i].szKey = VersionKeys[i];
        !          1053: 
        !          1054:         //
        !          1055:         // If version info exists, and the key query is successful, add
        !          1056:         //  the value.  Otherwise, the value for the key is NULL.
        !          1057:         //
        !          1058:         if( dwBuffSize && VerQueryValue(szBuff, key, &lpInfo, &cch) )
        !          1059:             gVKArray[i].szValue = lpInfo;
        !          1060:         else
        !          1061:             gVKArray[i].szValue = szNull;
        !          1062:     }
        !          1063: 
        !          1064:     return TRUE;
        !          1065: }
        !          1066: 
        !          1067: 
        !          1068: /***************************************************************************\
        !          1069: * VersionProc()
        !          1070: *
        !          1071: * .EXE Version Info Dialog Box
        !          1072: *
        !          1073: * History:
        !          1074: * 2/24/93  2am
        !          1075: *   Created.
        !          1076: \***************************************************************************/
        !          1077: LRESULT WINAPI VersionProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
        !          1078: {
        !          1079:     static LPTSTR   lpszBuff;
        !          1080: 
        !          1081:     switch (message){
        !          1082:       case WM_INITDIALOG:{
        !          1083: 
        !          1084:         LPCINFO lpCInfo;
        !          1085:         DWORD   dwLength;
        !          1086:         DWORD   dwCount;
        !          1087:         DWORD   dwHandle;
        !          1088:         TCHAR   szFile[DIRECTORY_STRING_SIZE] = TEXT("File:  ");
        !          1089:         TCHAR   szDir[DIRECTORY_STRING_SIZE] =  TEXT("Directory:  ");
        !          1090:         TCHAR   szFullName[DIRECTORY_STRING_SIZE];
        !          1091:         LPTSTR  lpszHold;
        !          1092: 
        !          1093: 
        !          1094:         lpCInfo = (LPCINFO)lParam;
        !          1095: 
        !          1096:         //
        !          1097:         // Concatenate path to szDir text-control string.
        !          1098:         //
        !          1099:         lstrcat(szDir, lpCInfo->CaptionBarText);
        !          1100:         SendDlgItemMessage( hDlg, SB_DEST, WM_SETTEXT,
        !          1101:                             (WPARAM)0, (LPARAM)szDir);
        !          1102: 
        !          1103:         //
        !          1104:         // Concatenate File name to szFile text-control string.
        !          1105:         //
        !          1106:         dwLength = lstrlen(szFile);
        !          1107: 
        !          1108:         //
        !          1109:         // Get selected (careted) ListBox item
        !          1110:         //
        !          1111:         GetLBText(lpCInfo->hFileLB, (PTCHAR)&szFile[dwLength]);
        !          1112: 
        !          1113:         SendDlgItemMessage( hDlg, SB_SOURCE, WM_SETTEXT,
        !          1114:                             (WPARAM)0, (LPARAM)szFile);
        !          1115: 
        !          1116:         //
        !          1117:         // Fill Version Key and Value edit boxes.
        !          1118:         //
        !          1119:         lstrcpy( szFullName, lpCInfo->CaptionBarText );
        !          1120: 
        !          1121:         //
        !          1122:         // a file under some file systems may have [] characters.
        !          1123:         //   Prepend path, adding a delimiting backslash unless we're in the root.
        !          1124:         //   If the attribute check is successful, it's a file, so leave.
        !          1125:         //
        !          1126:         lpszHold = TStrChr(szFullName, TEXT('\0'));
        !          1127: 
        !          1128:         lpszHold--;
        !          1129:         if( *lpszHold != TEXT('\\') ){
        !          1130:             lpszHold++;
        !          1131:             *lpszHold = TEXT('\\');
        !          1132:         }
        !          1133:         lpszHold++;
        !          1134: 
        !          1135:         lstrcpy(lpszHold, &szFile[dwLength]); // File name past 'File:' prefix
        !          1136: 
        !          1137:         dwLength = GetFileVersionInfoSize( szFullName, &dwHandle);
        !          1138:         if( !dwLength ){
        !          1139:             ErrorMsg(TEXT("VersionProc: GetFileVersionInfoSize() failure."));
        !          1140:             return(1);
        !          1141:         }
        !          1142: 
        !          1143:         // Allocate Version Info buffer
        !          1144:         EnterCriticalSection(&gHeapCS);
        !          1145:         lpszBuff = (LPTSTR)HeapAlloc( ghHeap, 0, dwLength * sizeof(TCHAR) );
        !          1146:         LeaveCriticalSection(&gHeapCS);
        !          1147: 
        !          1148:         FilerGetVersion( szFullName, dwLength, lpszBuff );
        !          1149: 
        !          1150:         for( dwCount = 0; dwCount < NUM_VERSION_INFO_KEYS; dwCount++){
        !          1151:             if( SendDlgItemMessage( hDlg, SB_KEY, LB_ADDSTRING, 0,
        !          1152:                                     (LPARAM)gVKArray[dwCount].szKey)
        !          1153:                                     == LB_ERR ){
        !          1154:                 ErrorMsg(TEXT("VersionProc: Add Key string failure."));
        !          1155:                 return(0);
        !          1156:             }
        !          1157:             if( SendDlgItemMessage( hDlg, SB_VALUE, LB_ADDSTRING, 0,
        !          1158:                                     (LPARAM)gVKArray[dwCount].szValue)
        !          1159:                                     == LB_ERR ){
        !          1160:                 ErrorMsg(TEXT("VersionProc: Add Value string failure."));
        !          1161:                 return(0);
        !          1162:             }
        !          1163:         }
        !          1164: 
        !          1165:         //  Set selection in listboxes to first item.
        !          1166:         if( SendDlgItemMessage( hDlg, SB_KEY, LB_SETCURSEL,
        !          1167:                                (WPARAM)0,
        !          1168:                                (LPARAM)0 )
        !          1169:                                == LB_ERR ){
        !          1170:             ErrorMsg(TEXT("VersionProc: Key LB Set Initial Selection failure."));
        !          1171:             return(0);
        !          1172:         }
        !          1173:         if( SendDlgItemMessage( hDlg, SB_VALUE, LB_SETCURSEL,
        !          1174:                                (WPARAM)0,
        !          1175:                                (LPARAM)0 )
        !          1176:                                == LB_ERR ){
        !          1177:             ErrorMsg(TEXT("VersionProc: Value LB Set Initial Selection failure."));
        !          1178:             return(0);
        !          1179:         }
        !          1180: 
        !          1181:         //  Initialize Scroll Bar
        !          1182:         //  Check to see if a scroll bar is needed. See GLOBALS.H and FILER.DLG
        !          1183:         if( NUM_VERSION_INFO_KEYS - VERSION_DLG_LB_HEIGHT > 0 )
        !          1184:             SendDlgItemMessage( hDlg, SB_SCROLL, SBM_SETRANGE,
        !          1185:                                (WPARAM)0,
        !          1186:                                (LPARAM)NUM_VERSION_INFO_KEYS -1);
        !          1187:         SendDlgItemMessage( hDlg, SB_SCROLL, SBM_SETPOS,
        !          1188:                            (WPARAM)0,
        !          1189:                            (LPARAM)TRUE );
        !          1190: 
        !          1191:         return(1);
        !          1192:       }
        !          1193: 
        !          1194:       case WM_VSCROLL:{
        !          1195:         int nPos;
        !          1196: 
        !          1197:         nPos = SendDlgItemMessage( hDlg, SB_SCROLL, SBM_GETPOS,
        !          1198:                                   (WPARAM)0,
        !          1199:                                   (LPARAM)0 );
        !          1200: 
        !          1201:         switch( LOWORD(wParam) ){
        !          1202: 
        !          1203:             case SB_PAGEDOWN:{
        !          1204:                 nPos += VERSION_DLG_LB_HEIGHT;
        !          1205:                 if( nPos > NUM_VERSION_INFO_KEYS )
        !          1206:                     nPos = NUM_VERSION_INFO_KEYS;
        !          1207:                 break;
        !          1208:             }
        !          1209:             case SB_LINEDOWN:{
        !          1210:                 nPos++;
        !          1211:                 if( nPos > NUM_VERSION_INFO_KEYS )
        !          1212:                     nPos = NUM_VERSION_INFO_KEYS;
        !          1213:                 break;
        !          1214:             }
        !          1215:             case SB_PAGEUP:{
        !          1216:                 nPos -= VERSION_DLG_LB_HEIGHT;
        !          1217:                 if( nPos < 0 )
        !          1218:                     nPos = 0;
        !          1219:                 break;
        !          1220:             }
        !          1221:             case SB_LINEUP:{
        !          1222:                 nPos--;
        !          1223:                 if( nPos < 0 )
        !          1224:                     nPos = 0;
        !          1225:                 break;
        !          1226:             }
        !          1227:             default:
        !          1228:                 return(1);
        !          1229:         }
        !          1230: 
        !          1231:         //  Set Scroll Bar position
        !          1232:         SendDlgItemMessage( hDlg, SB_SCROLL, SBM_SETPOS,
        !          1233:                             (WPARAM)nPos,
        !          1234:                             (LPARAM)TRUE );
        !          1235:         //  Set selection in listboxes
        !          1236:         if( SendDlgItemMessage( hDlg, SB_KEY, LB_SETCURSEL,
        !          1237:                                 (WPARAM)nPos,
        !          1238:                                 (LPARAM)0 )
        !          1239:                                 == LB_ERR ){
        !          1240:             ErrorMsg(TEXT("VersionProc: ListBox Set Current Selection failure."));
        !          1241:             return(0);
        !          1242:         }
        !          1243:         if( SendDlgItemMessage( hDlg, SB_VALUE, LB_SETCURSEL,
        !          1244:                                 (WPARAM)nPos,
        !          1245:                                 (LPARAM)0 )
        !          1246:                                 == LB_ERR ){
        !          1247:             ErrorMsg(TEXT("VersionProc: ListBox Set Current Selection failure."));
        !          1248:             return(0);
        !          1249:         }
        !          1250: 
        !          1251:         return(0);
        !          1252:       }
        !          1253: 
        !          1254:       case WM_COMMAND:{
        !          1255:             int nLBid = 0;  // holds ID of listbox other than one sending LBN msg.
        !          1256: 
        !          1257:         switch( LOWORD(wParam) ){
        !          1258:             case SB_OK:
        !          1259:             case SB_CANCEL:{
        !          1260:                 // Free allocated buffer
        !          1261:                 EnterCriticalSection(&gHeapCS);
        !          1262:                 HeapFree( ghHeap, 0, lpszBuff);
        !          1263:                 LeaveCriticalSection(&gHeapCS);
        !          1264: 
        !          1265:                 EndDialog(hDlg, wParam);
        !          1266:                 return(1);
        !          1267:             }
        !          1268: 
        !          1269:             // SB_VALUE and SB_KEY are the ListBox IDs. Below are LB notifications.
        !          1270:             case SB_VALUE:
        !          1271:                 nLBid = SB_KEY;
        !          1272:                 // we slip through to the SB_KEY case on purpose!!
        !          1273:             case SB_KEY:{
        !          1274:                 int nSelect;    // Holds selected item
        !          1275: 
        !          1276:                 if( HIWORD(wParam) == LBN_SELCHANGE ){
        !          1277: 
        !          1278:                     if( !nLBid )    // If nLBid wasn't set by the SB_VALUE case above...
        !          1279:                         nLBid = SB_VALUE;
        !          1280: 
        !          1281:                     //  Get current listbox selection.
        !          1282:                     nSelect = SendDlgItemMessage( hDlg, LOWORD(wParam), LB_GETCURSEL,
        !          1283:                                         (WPARAM)0,
        !          1284:                                         (LPARAM)0 );
        !          1285:                     if( nSelect == LB_ERR ){
        !          1286:                         ErrorMsg(TEXT("VersionProc: ListBox Get Selection failure."));
        !          1287:                         return(0);
        !          1288:                     }
        !          1289: 
        !          1290:                     //  Set similar selection in corresponding listbox.
        !          1291:                     if( SendDlgItemMessage( hDlg, nLBid, LB_SETCURSEL,
        !          1292:                                             (WPARAM)nSelect,
        !          1293:                                             (LPARAM)0 )
        !          1294:                                             == LB_ERR ){
        !          1295:                         ErrorMsg(TEXT("VersionProc: ListBox Get Current Selection failure."));
        !          1296:                         return(0);
        !          1297:                     }
        !          1298: 
        !          1299: 
        !          1300:                     //  Set Scroll Bar position
        !          1301:                     SendDlgItemMessage( hDlg, SB_SCROLL, SBM_SETPOS,
        !          1302:                                         (WPARAM)nSelect,
        !          1303:                                         (LPARAM)TRUE );
        !          1304:                 }
        !          1305:             }
        !          1306:         }
        !          1307:         return(1);
        !          1308:       }
        !          1309:     }
        !          1310: 
        !          1311:     return(0);
        !          1312: }
        !          1313: 
        !          1314: 
        !          1315: /***************************************************************************\
        !          1316: *
1.1       root     1317: * IsDirectory()
                   1318: *
                   1319: *  Given an item from a ListBox filled from an LB_DIR call, IsDirectory
                   1320: *    verifies whether or not the item is a directory, and if so, returns
                   1321: *    true, and places the full directory path in lpszFile.
                   1322: *
1.1.1.3 ! root     1323: *  input:   lpszDir     -   Holds current directory
1.1       root     1324: *           lpszFile    -   Holds item of dubious directoryness.
                   1325: *
                   1326: * History:
                   1327: * 5/30/92
                   1328: *   Created.
                   1329: *
                   1330: \***************************************************************************/
1.1.1.3 ! root     1331: BOOL IsDirectory(LPTSTR lpszDir, LPTSTR lpszFile)
1.1       root     1332: {
                   1333:     DWORD   dwAttrib;
1.1.1.3 ! root     1334:     LPTSTR  lpszHold;
        !          1335:     TCHAR   szItem[DIRECTORY_STRING_SIZE * 2];
        !          1336: 
1.1       root     1337: 
                   1338:     //
                   1339:     // if it's '..', go up one directory
                   1340:     //
1.1.1.3 ! root     1341:     if( !lstrcmp(lpszFile, TEXT("[..]")) ){
1.1       root     1342:         lstrcpy(lpszFile, lpszDir);
1.1.1.3 ! root     1343:         lpszHold = TStrChr(lpszFile, TEXT('\0'));
        !          1344:         while( (lpszHold > lpszFile) && (*lpszHold != TEXT('\\')) )
1.1       root     1345:             lpszHold--;
                   1346:         if(lpszHold <= lpszFile){
1.1.1.3 ! root     1347:             ErrorMsg(TEXT("IsDirectory: String parse failure."));
1.1       root     1348:             return(0);
                   1349:         }
                   1350:         else{
1.1.1.3 ! root     1351:             if( TStrChr(lpszFile, TEXT('\\')) == lpszHold )
1.1       root     1352:                 lpszHold++;
1.1.1.3 ! root     1353:             *lpszHold = TEXT('\0');
1.1       root     1354:             return(1);
                   1355:         }
                   1356:     }
                   1357: 
                   1358:     //
1.1.1.3 ! root     1359:     // A directory will have [] around it in the listbox. Check for it.
1.1       root     1360:     //
1.1.1.3 ! root     1361:     if( *lpszFile != TEXT('[') )
1.1       root     1362:         return(0);
                   1363: 
                   1364:     //
1.1.1.3 ! root     1365:     // A file under some file systems may have [] characters.
1.1       root     1366:     //   Prepend path, adding a delimiting backslash unless we're in the root.
                   1367:     //   If the attribute check is successful, it's a file, so leave.
                   1368:     //
1.1.1.3 ! root     1369:     // NOTE:  This is a hack.  If there is a file called '[foo]' and a
        !          1370:     //   Directory called 'foo', they will appear identical in the listbox.
        !          1371:     //   Rather than check for this rare case, if it happens, Filer will
        !          1372:     //   assume it is a file first, as the directory may be changed from
        !          1373:     //   the Directory Listbox.
        !          1374:     //
1.1       root     1375:     lstrcpy(szItem, lpszDir);
1.1.1.3 ! root     1376:     lpszHold = TStrChr(szItem, TEXT('\0'));
        !          1377: 
1.1       root     1378:     lpszHold--;
1.1.1.3 ! root     1379:     if( *lpszHold != TEXT('\\') ){
1.1       root     1380:         lpszHold++;
1.1.1.3 ! root     1381:         *lpszHold = TEXT('\\');
1.1       root     1382:     }
1.1.1.3 ! root     1383:     lpszHold++;
1.1       root     1384: 
                   1385:     lstrcpy(lpszHold, lpszFile);
                   1386: 
                   1387:     dwAttrib = GetFileAttributes(szItem);
                   1388: 
1.1.1.3 ! root     1389:     if( dwAttrib != 0xFFFFFFFF )             // there really is a file called
        !          1390:         return(0);                           //  '[foo]'.  Exit.
1.1       root     1391: 
                   1392:     //
                   1393:     // remove the [], and check if valid directory.
                   1394:     //   if it fails, or it's not a directory, leave.
                   1395:     //
                   1396:     lstrcpy(lpszHold, &lpszFile[1]);
1.1.1.3 ! root     1397:     lpszHold = TStrChr(lpszHold, TEXT('\0'));
        !          1398: 
1.1       root     1399:     lpszHold--;
1.1.1.3 ! root     1400:     if( *lpszHold != TEXT(']') )
1.1       root     1401:         return(0);
1.1.1.3 ! root     1402:     *lpszHold = TEXT('\0');
1.1       root     1403: 
                   1404:     dwAttrib = GetFileAttributes(szItem);
                   1405: 
                   1406:     if( (dwAttrib == 0xFFFFFFFF) || !(dwAttrib & FILE_ATTRIBUTE_DIRECTORY) )
                   1407:         return(0);
                   1408: 
                   1409:     //
                   1410:     // OK, it's a directory, and szItem now holds the fully qualified path.
                   1411:     // copy this to the filename buffer sent in, and return true.
                   1412:     //
                   1413:     CharUpper(szItem);
                   1414:     lstrcpy(lpszFile, szItem);
                   1415:     return(1);
                   1416: }
                   1417: 
                   1418: 
                   1419: /***************************************************************************\
                   1420: *
                   1421: * ExecuteFileAction()
                   1422: *
                   1423: * Creates a dialog box verifying a file action, and carries out the action.
                   1424: *
                   1425: *  input:   hwnd    -   handle to Drv child.
                   1426: *           lpSelect    -   pointer to SELECTINFO structure, containing
                   1427: *                           info on the file i/o action to be performed.
                   1428: *
                   1429: * History:
                   1430: * 5/28/92
                   1431: *   Created.
                   1432: *
                   1433: \***************************************************************************/
                   1434: BOOL ExecuteFileAction(LPSINFO lpSelect)
                   1435: {
                   1436: 
1.1.1.3 ! root     1437:     if( DialogBoxParam(ghModule, TEXT("SelectDlg"), lpSelect->hwnd,
1.1       root     1438:                   (DLGPROC)SelectProc, (LPARAM)lpSelect) == -1 ){
1.1.1.3 ! root     1439:         ErrorMsg(TEXT("ExecuteFileAction: File I/O Dialog Creation failure."));
1.1       root     1440:         return(0);
                   1441:     }
                   1442:     return(1);
                   1443: }
                   1444: 
                   1445: 
                   1446: /***************************************************************************\
                   1447: * SelectProc()
                   1448: *
                   1449: * File I/O selection dialog proc.
                   1450: *
                   1451: * History:
                   1452: * 5/28/92
                   1453: *   Created.
                   1454: \***************************************************************************/
1.1.1.3 ! root     1455: LRESULT WINAPI SelectProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
1.1       root     1456: {
                   1457:     static LPSINFO lpSelect;
                   1458: 
                   1459:     switch (message) {
                   1460:       case WM_INITDIALOG:{
                   1461: 
                   1462:         lpSelect = (LPSINFO)lParam;
                   1463: 
                   1464:         //
                   1465:         // Fill source and destination fields of Select dialog.
                   1466:         //
                   1467:         if( !FillSelectDlg(hDlg, lpSelect) ){
                   1468:             EndDialog(hDlg, wParam);
                   1469:             return(1);
                   1470:         }
                   1471: 
                   1472:         //
1.1.1.3 ! root     1473:         // Set the TEXT('action') text (i.e. TEXT("COPYING:"), TEXT("MOVING:"), etc.)
1.1       root     1474:         //
                   1475:         if( !SetDlgItemText(hDlg, SB_ACTION, lpSelect->szAction) ){
1.1.1.3 ! root     1476:             ErrorMsg(TEXT("SelectProc: Set Action Text failure."));
1.1       root     1477:             EndDialog(hDlg, wParam);
                   1478:             return(1);
                   1479:         }
                   1480: 
                   1481:         //
1.1.1.3 ! root     1482:         // Set the TEXT("TO:") or TEXT("FROM:") text.
1.1       root     1483:         //
                   1484:         if( !SetDlgItemText(hDlg, SB_TOFROM, lpSelect->szToFrom) ){
1.1.1.3 ! root     1485:             ErrorMsg(TEXT("SelectProc: Set Action Text failure."));
1.1       root     1486:             EndDialog(hDlg, wParam);
                   1487:             return(1);
                   1488:         }
                   1489: 
                   1490:         break;
                   1491:       }
                   1492:       case WM_COMMAND:{
1.1.1.3 ! root     1493:         switch(LOWORD(wParam)){
1.1       root     1494:             case SB_OK:{
                   1495:                 DoFileIO(hDlg, lpSelect);
                   1496:                 EndDialog(hDlg, wParam);
                   1497:                 return(1);
                   1498:             }
                   1499:             case SB_CANCEL:{
                   1500:                 EndDialog(hDlg, wParam);
                   1501:                 return(1);
                   1502:             }
                   1503:         }
                   1504:         return(1);
                   1505:       }
                   1506:     }
                   1507: 
                   1508:     return(0);
                   1509: }
                   1510: 
                   1511: 
                   1512: /***************************************************************************\
                   1513: *
                   1514: * FillSelectDlg()
                   1515: *
                   1516: * Fills the Select Dialog box with the files selected in the active Drv Child
                   1517: *  for a file i/o action.  Destination defaults to directory selection in
                   1518: *  inactive Drv Child.
                   1519: *
                   1520: *  input:   hDlg    -   handle to Select dialog box.
                   1521: *           hwnd    -   handle to Drv child.
                   1522: *
                   1523: * History:
                   1524: * 5/28/92
                   1525: *   Created.
                   1526: *
                   1527: \***************************************************************************/
                   1528: BOOL FillSelectDlg(HWND hDlg, LPSINFO lpSelect)
                   1529: {
                   1530:     LONG    lCount;         // Number of items selected in ListBox
                   1531:     LONG    lSize;          // Holds size of a string
                   1532:     LONG    lLargest = 0;   // Holds largest string encountered.
                   1533:     UINT    *lpnIndex;      // ptr to array of selected ListBox items' indeces
                   1534:     int     i;              // counter
                   1535: 
                   1536:     LPCINFO lpCInfo;
                   1537:     HWND    hDest;          // dir of files if delete, else inactive Drv dir.
                   1538: 
                   1539:     HDC     hDC;
                   1540:     TEXTMETRIC  Metrics;
                   1541: 
1.1.1.3 ! root     1542:     LPTSTR  lpszHold;       // marks end of directory path in szName.
        !          1543:     TCHAR   szName[DIRECTORY_STRING_SIZE * 2];  // holds ListBox strings.
1.1       root     1544: 
                   1545: 
                   1546:     lpCInfo = (LPCINFO)GetWindowLong(lpSelect->hwnd, GWL_USERDATA);
                   1547: 
1.1.1.3 ! root     1548:     lCount = SendMessage( lpCInfo->hFileLB, LB_GETSELCOUNT,
1.1       root     1549:                           (WPARAM)NULL, (LPARAM)NULL );
                   1550: 
                   1551:     //
                   1552:     // if no items selected, leave.
                   1553:     //
                   1554:     if( !lCount )
                   1555:         return(0);
                   1556: 
                   1557:     //
                   1558:     // Allocate array of lCount listbox indexes, and fill it.
                   1559:     //
                   1560:     EnterCriticalSection(&gHeapCS);
1.1.1.3 ! root     1561:     lpnIndex = (UINT*)HeapAlloc( ghHeap, 0, lCount * sizeof(UINT) );
1.1       root     1562:     LeaveCriticalSection(&gHeapCS);
                   1563:     if( !lpnIndex ){
1.1.1.3 ! root     1564:         ErrorMsg(TEXT("FillSelectDlg: Item list allocation failure."));
1.1       root     1565:         return(0);
                   1566:     }
                   1567: 
1.1.1.3 ! root     1568:     if( SendMessage( lpCInfo->hFileLB, LB_GETSELITEMS, (WPARAM)lCount,
1.1       root     1569:                      (LPARAM)lpnIndex) != lCount ){
1.1.1.3 ! root     1570:         ErrorMsg(TEXT("FillSelectDlg: Get Selections failure."));
1.1       root     1571:         return(0);
                   1572:     }
                   1573: 
                   1574:     //
                   1575:     // Check if each selected entry is a valid file.
                   1576:     //
1.1.1.3 ! root     1577:     // Check to see if there is a terminating backslash, by decrementing
        !          1578:     //  pointer, checking, adding a '\' if necessary, then re-incrementing
        !          1579:     //  the pointer.
        !          1580:     //
1.1       root     1581:     lstrcpy(szName, lpCInfo->CaptionBarText);
1.1.1.3 ! root     1582: 
        !          1583:     lpszHold = TStrChr(szName, TEXT('\0'));
        !          1584: 
        !          1585:     lpszHold--;
        !          1586:     if( *lpszHold != TEXT('\\') ){
        !          1587:         lpszHold++;
        !          1588:         *lpszHold = TEXT('\\');
        !          1589:     }
1.1       root     1590:     lpszHold++;
                   1591: 
1.1.1.3 ! root     1592:     //
        !          1593:     // Fill Dlg ListBox with selected strings from Drv child's ListBox,
        !          1594:     //   noting size of largest entry.
        !          1595:     //
1.1       root     1596:     for( i = 0; i < lCount; i++){
1.1.1.3 ! root     1597:         if( SendMessage( lpCInfo->hFileLB, LB_GETTEXT, (WPARAM)lpnIndex[i],
1.1       root     1598:                         (LPARAM)lpszHold) == LB_ERR ){
1.1.1.3 ! root     1599:             ErrorMsg(TEXT("FillSelectDlg: Get source string failure."));
1.1       root     1600:             return(0);
                   1601:         }
                   1602: 
1.1.1.3 ! root     1603:         if( GetFileAttributes(szName) == 0xFFFFFFFF ){    //Error
        !          1604:             lstrcat(lpszHold, TEXT(":  Access Denied."));
1.1       root     1605:             ErrorMsg(lpszHold);
                   1606:         }
                   1607:         else{
                   1608:             lSize = lstrlen(lpszHold);
                   1609:             if( lSize > lLargest )
                   1610:                 lLargest = lSize;
                   1611: 
1.1.1.3 ! root     1612:             if( SendDlgItemMessage( hDlg, SB_SOURCE, LB_ADDSTRING, 0,
1.1       root     1613:                                     (LPARAM)lpszHold) == LB_ERR ){
1.1.1.3 ! root     1614:                 ErrorMsg(TEXT("FillSelectDlg: Add source string failure."));
1.1       root     1615:                 return(0);
                   1616:             }
                   1617:         }
                   1618:     }
                   1619: 
                   1620:     //
                   1621:     // Get the average char width of current font,
                   1622:     // We then set the dialog listbox column width to
                   1623:     // (longest string + arbitrary column spacing) * ave width.
                   1624:     //
                   1625:     hDC = GetDC(lpSelect->hwnd);
                   1626:     if( !GetTextMetrics(hDC, &Metrics) ){
1.1.1.3 ! root     1627:         ErrorMsg(TEXT("FillSelectDlg: GetTextMetrics failure."));
1.1       root     1628:         return(0);
                   1629:     }
                   1630: 
                   1631:     ReleaseDC(lpSelect->hwnd, hDC);
                   1632: 
                   1633:     SendDlgItemMessage( hDlg, SB_SOURCE, LB_SETCOLUMNWIDTH,
                   1634:                         (WPARAM)((lLargest + 8) * Metrics.tmAveCharWidth),
                   1635:                         (LPARAM)NULL );
                   1636: 
                   1637:     EnterCriticalSection(&gHeapCS);
1.1.1.3 ! root     1638:     HeapFree( ghHeap, 0, (LPVOID)lpnIndex);
1.1       root     1639:     LeaveCriticalSection(&gHeapCS);
                   1640: 
                   1641: 
                   1642:     //
                   1643:     // Fill SB_DEST with directory.
                   1644:     // If deleteing, default to the directory of the files.
                   1645:     //
                   1646:     if( lpSelect->dwAction != MM_DELETE ){
                   1647:         //
                   1648:         // Not Deleting.  Default to selected directory (titlebar)
                   1649:         //   of the inactive Drive child.
                   1650:         //
                   1651:         if( lpSelect->hwnd == ghwndDrv1 )
                   1652:             hDest = ghwndDrv2;
                   1653:         else
                   1654:             hDest = ghwndDrv1;
                   1655: 
                   1656:         lpCInfo = (LPCINFO)GetWindowLong(hDest, GWL_USERDATA);
                   1657:     }
                   1658: 
                   1659:    SendDlgItemMessage( hDlg, SB_DEST, EM_LIMITTEXT,
                   1660:                             (WPARAM)DIRECTORY_STRING_SIZE, (LPARAM)0);
                   1661: 
1.1.1.3 ! root     1662:    if( SendDlgItemMessage( hDlg, SB_DEST, WM_SETTEXT, 0,
1.1       root     1663:                             (LPARAM)lpCInfo->CaptionBarText) == CB_ERR ){
1.1.1.3 ! root     1664:         ErrorMsg(TEXT("FillSelectDlg: Set Destination text failure."));
1.1       root     1665:         return(0);
                   1666:     }
                   1667: 
                   1668:     return(1);
                   1669: }
                   1670: 
                   1671: 
                   1672: /***************************************************************************\
                   1673: *
                   1674: * DoFileIO()
                   1675: *
                   1676: * Called by SelectProc.  Carries out the chosed file operations verified
                   1677: *   in the Select Dialog Box.
                   1678: *
                   1679: *  input:   hDlg    -   handle to Select dialog box.
                   1680: *           lpSelect    -   ptr to SELECTINFO structure.
                   1681: *
                   1682: *  returns: 1 if successful
                   1683: *           0 if unsuccessful
                   1684: * History:
                   1685: * 6/3/92
                   1686: *   Created.
                   1687: *
                   1688: \***************************************************************************/
                   1689: BOOL DoFileIO( HWND hDlg, LPSINFO lpSelect)
                   1690: {
                   1691:     LONG    lCount;
                   1692:     LONG    lFile;
                   1693:     LPCINFO lpCInfo;
1.1.1.3 ! root     1694:     LPTSTR  lpEndDest;
        !          1695:     LPTSTR  lpEndSource;
1.1       root     1696:     BOOL    fError = FALSE;
                   1697: 
1.1.1.3 ! root     1698:     TCHAR   szSource[DIRECTORY_STRING_SIZE];
        !          1699:     TCHAR   szDest[DIRECTORY_STRING_SIZE * 2];
1.1       root     1700: 
                   1701: 
                   1702:     //
                   1703:     // Find number of files to copy
                   1704:     //
                   1705:     lCount = SendDlgItemMessage( hDlg, SB_SOURCE, LB_GETCOUNT, (WPARAM)NULL,
                   1706:                                  (LPARAM)NULL);
                   1707: 
                   1708:     if( (lCount == LB_ERR) || (lCount == 0) ){
1.1.1.3 ! root     1709:         ErrorMsg(TEXT("DoFileIO: file selection failure."));
1.1       root     1710:         return(0);
                   1711:     }
                   1712: 
                   1713:     //
                   1714:     // Get source directory path. Add a \ to the end, set pointer to end.
                   1715:     //
                   1716:     lpCInfo = (LPCINFO)GetWindowLong( lpSelect->hwnd, GWL_USERDATA);
                   1717: 
                   1718:     lstrcpy(szSource, lpCInfo->CaptionBarText);
                   1719: 
1.1.1.3 ! root     1720:     lpEndSource = TStrChr(szSource, TEXT('\0'));
        !          1721:     *lpEndSource++ = TEXT('\\');
1.1       root     1722: 
                   1723:     //
                   1724:     // Get destination directory path. Add a \ to the end, set pointer to end.
                   1725:     //
                   1726:     if( SendDlgItemMessage( hDlg, SB_DEST, WM_GETTEXT,
                   1727:             (WPARAM)DIRECTORY_STRING_SIZE * 2, (LPARAM)szDest) == CB_ERR ){
1.1.1.3 ! root     1728:         ErrorMsg(TEXT("Do I/O: Get Destination failure."));
1.1       root     1729:         return(0);
                   1730:     }
                   1731: 
1.1.1.3 ! root     1732:     lpEndDest = TStrChr(szDest, TEXT('\0'));
        !          1733:     *lpEndDest++ = TEXT('\\');
1.1       root     1734: 
                   1735:     //
                   1736:     // for each file, do appropriate I/O.
                   1737:     //
                   1738:     while( lCount ){
                   1739: 
                   1740:         lCount--;
                   1741: 
                   1742:         lFile = SendDlgItemMessage( hDlg, SB_SOURCE, LB_GETTEXT,
                   1743:                                     (WPARAM)0, (LPARAM)lpEndSource);
                   1744:         if( lFile == LB_ERR){
1.1.1.3 ! root     1745:             ErrorMsg(TEXT("DoFileIO: file string retrieval failure."));
1.1       root     1746:             fError = TRUE;
                   1747:         }
                   1748: 
                   1749:         SendDlgItemMessage( hDlg, SB_SOURCE, LB_DELETESTRING,
                   1750:                             (WPARAM)0, (LPARAM)NULL);
                   1751: 
                   1752:         switch( lpSelect->dwAction ){
                   1753:           case MM_COPY:{
                   1754: 
                   1755:             lstrcpy(lpEndDest, lpEndSource);
                   1756: 
                   1757:             if( !CopyFile( szSource, szDest, TRUE) )
                   1758:                 if( !HandleIOError(lpSelect->hwnd, lpSelect->dwAction,
                   1759:                                    szSource, szDest) )
                   1760:                     fError = TRUE;
                   1761:             break;
                   1762:           }
                   1763: 
                   1764:           case MM_MOVE:{
                   1765: 
                   1766:             lstrcpy(lpEndDest, lpEndSource);
                   1767: 
                   1768:             if( !MoveFile( szSource, szDest) )
                   1769:                 if( !HandleIOError(lpSelect->hwnd, lpSelect->dwAction,
                   1770:                                    szSource, szDest) )
                   1771:                     fError = TRUE;
                   1772:             break;
                   1773:           }
                   1774:           case MM_DELETE:{
                   1775: 
                   1776:             if( !DeleteFile(szSource) )
                   1777:                 if( !HandleIOError(lpSelect->hwnd, lpSelect->dwAction,
                   1778:                                    szSource, szDest) )
                   1779:                     fError = TRUE;
                   1780:             break;
                   1781:           }
                   1782: 
                   1783:         }
                   1784:         if( fError )
                   1785:             break;
                   1786:     }
                   1787: 
                   1788:     //
1.1.1.3 ! root     1789:     //  Update file listboxes.
1.1       root     1790:     //
                   1791:     if( fError )
                   1792:         return(0);
                   1793:     else{
                   1794:         UpdateFileLB(ghwndDrv1);
                   1795:         UpdateFileLB(ghwndDrv2);
                   1796:     }
                   1797: 
                   1798:     return(1);
                   1799: }
                   1800: 
                   1801: 
                   1802: /***************************************************************************\
                   1803: *
                   1804: * HandleIOError()
                   1805: *
                   1806: * Called by DoFileIO. Handles errors arising from File IO operations
                   1807: *
                   1808: *  input:   hwnd        -   handle to Drv child window
                   1809: *           dwAction    -   File I/O Action.  Window message.
                   1810: *           szSource    -   ptr to Source string
                   1811: *           szDest      -   ptr to Destination string
                   1812: *
                   1813: *  returns: 1 if successful
                   1814: *           0 if unsuccessful
                   1815: *
                   1816: * History:
                   1817: * 6/3/92
                   1818: *   Created.
                   1819: *
                   1820: \***************************************************************************/
1.1.1.3 ! root     1821: BOOL HandleIOError(HWND hwnd, DWORD dwAction, LPTSTR szSource, LPTSTR szDest)
1.1       root     1822: {
                   1823:     DWORD   dwError;
                   1824:     int     nReply;
                   1825:     LPCINFO lpCInfo;
1.1.1.3 ! root     1826:     TCHAR   buff[50];
1.1       root     1827: 
                   1828:     dwError = GetLastError();
                   1829: 
                   1830:     CharUpper(szDest);
                   1831: 
                   1832:     switch( dwError ){
                   1833:         case ERROR_ALREADY_EXISTS:
                   1834:         case ERROR_FILE_EXISTS:{
                   1835:           //
                   1836:           // MoveFile file already exists. We can CopyFile & DeleteFile source.
                   1837:           //
                   1838:           nReply = MessageBox(hwnd,
1.1.1.3 ! root     1839:                               TEXT("File Already Exists!  Overwrite file?"),
1.1       root     1840:                               szDest, MB_YESNOCANCEL);
                   1841:           switch( nReply ){
                   1842:             case IDYES:{
                   1843: 
                   1844:               lpCInfo = (LPCINFO)GetWindowLong(hwnd, GWL_USERDATA);
                   1845: 
                   1846:               if( !CopyFile( szSource, szDest, FALSE) )
                   1847:                   if( HandleIOError(hwnd, dwAction, szSource, szDest) )
                   1848:                       return(1);
                   1849:                   else
                   1850:                       return(0);
                   1851:               if( dwAction == MM_MOVE )
                   1852:                   if( !DeleteFile( szSource) )
                   1853:                       if( HandleIOError(hwnd, dwAction, szSource, szDest) )
                   1854:                           return(1);
                   1855:                       else
                   1856:                           return(0);
                   1857: 
                   1858:               UpdateFileLB(ghwndDrv1);
                   1859:               UpdateFileLB(ghwndDrv2);
                   1860: 
                   1861:               return(1);
                   1862:             }
                   1863:             case IDNO:{
                   1864:               return(1);
                   1865:             }
                   1866:             case IDCANCEL:{
                   1867:               return(0);
                   1868:             }
                   1869:           }
                   1870:           break;
                   1871:         }
                   1872: 
                   1873:         case ERROR_ACCESS_DENIED:
                   1874:         case ERROR_FILE_NOT_FOUND:
                   1875:         case ERROR_INVALID_PARAMETER:{
                   1876:             wsprintf(buff,
1.1.1.3 ! root     1877:                      TEXT("Access Denied.  Check file name or security. Error %ld"),
1.1       root     1878:                       dwError);
                   1879:             MessageBox( hwnd, buff, szDest, MB_OK);
                   1880: 
                   1881:             return(1);
                   1882:         }
                   1883: 
                   1884:         case ERROR_DISK_FULL:{
                   1885:             MessageBox( hwnd,
1.1.1.3 ! root     1886:             TEXT("ERROR: The disk is full.  Unable to continue."),
1.1       root     1887:             szDest, MB_OK);
                   1888:             return(0);
                   1889:         }
                   1890: 
                   1891:         case ERROR_INVALID_NAME:
                   1892:         case ERROR_DIRECTORY:
                   1893:         case ERROR_PATH_NOT_FOUND:{
                   1894:             MessageBox( hwnd,
1.1.1.3 ! root     1895:             TEXT("ERROR: The path or file does not exist.  Unable to continue."),
1.1       root     1896:             szDest, MB_OK);
                   1897:             return(0);
                   1898:         }
                   1899: 
                   1900:         default:{
1.1.1.3 ! root     1901:             wsprintf(buff, TEXT("File I/O failure. Error %ld"), dwError);
1.1       root     1902:             ErrorMsg(buff);
                   1903:             return(1);
                   1904:         }
                   1905:     }
                   1906: 
                   1907:     return(1);
                   1908: }
                   1909: 
                   1910: 
                   1911: /***************************************************************************\
                   1912: * RenameProc()
                   1913: *
                   1914: * File I/O rename Dialog Box
                   1915: *
                   1916: * History:
                   1917: * 6/5/92  2am
                   1918: *   Created.
                   1919: \***************************************************************************/
1.1.1.3 ! root     1920: LRESULT WINAPI RenameProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
1.1       root     1921: {
1.1.1.3 ! root     1922:     static TCHAR   szName[DIRECTORY_STRING_SIZE];
        !          1923:     static LPTSTR  lpszHold;
        !          1924:     static LPCINFO lpCInfo;
1.1       root     1925: 
                   1926:     switch (message){
                   1927:       case WM_INITDIALOG:{
                   1928: 
                   1929:         LONG    lIndex;
                   1930: 
                   1931:         lpCInfo = (LPCINFO)lParam;
                   1932: 
                   1933:         //
1.1.1.3 ! root     1934:         // Check to see if there is a terminating backslash, by decrementing
        !          1935:         //  pointer, checking, adding a '\' if necessary, then re-incrementing
        !          1936:         //  the pointer.
1.1       root     1937:         //
                   1938:         lstrcpy(szName, lpCInfo->CaptionBarText);
1.1.1.3 ! root     1939:         lpszHold = TStrChr(szName, TEXT('\0'));
        !          1940: 
        !          1941:         lpszHold--;
        !          1942:         if( *lpszHold != TEXT('\\') ){
        !          1943:             lpszHold++;
        !          1944:             *lpszHold = TEXT('\\');
        !          1945:         }
1.1       root     1946:         lpszHold++;
                   1947: 
1.1.1.3 ! root     1948:         lIndex = GetLBText(lpCInfo->hFileLB, lpszHold);
        !          1949:         if( lIndex == -1 )
1.1       root     1950:             return(1);
                   1951: 
                   1952:         //
                   1953:         // if not a valid file (i.e. listbox directory entry in []s), fail.
                   1954:         //
1.1.1.3 ! root     1955:         if( GetFileAttributes(szName) == 0xFFFFFFFF ){    //Error
        !          1956:             lstrcat(lpszHold, TEXT(":  Access Denied."));
1.1       root     1957:             ErrorMsg(lpszHold);
                   1958:             return(1);
                   1959:         }
                   1960: 
                   1961:         //
                   1962:         // Place name in both source and destination edit controls.
                   1963:         //
                   1964:         CharUpper(szName);
                   1965: 
                   1966:         SendDlgItemMessage( hDlg, SB_SOURCE, EM_LIMITTEXT,
                   1967:                             (WPARAM)DIRECTORY_STRING_SIZE, (LPARAM)0);
                   1968: 
                   1969:         SendDlgItemMessage( hDlg, SB_DEST, EM_LIMITTEXT,
                   1970:                             (WPARAM)DIRECTORY_STRING_SIZE, (LPARAM)0);
                   1971: 
1.1.1.3 ! root     1972:         if( SendDlgItemMessage( hDlg, SB_SOURCE, WM_SETTEXT, 0,
1.1       root     1973:                                 (LPARAM)lpszHold) == LB_ERR ){
1.1.1.3 ! root     1974:             ErrorMsg(TEXT("Rename: Add Source String failure."));
1.1       root     1975:             return(1);
                   1976:         }
1.1.1.3 ! root     1977:         if( SendDlgItemMessage( hDlg, SB_DEST, WM_SETTEXT, 0,
1.1       root     1978:                                 (LPARAM)lpszHold) == LB_ERR ){
1.1.1.3 ! root     1979:             ErrorMsg(TEXT("Rename: Add Destination String failure."));
1.1       root     1980:             return(1);
                   1981:         }
                   1982:         return(1);
                   1983:       }
                   1984:       case WM_COMMAND:{
1.1.1.3 ! root     1985:         switch(LOWORD(wParam)){
1.1       root     1986:             case SB_OK:{
1.1.1.3 ! root     1987:                 TCHAR   szDest[DIRECTORY_STRING_SIZE];
        !          1988:                 LPTSTR  lpszCheck;
1.1       root     1989: 
                   1990:                 //
                   1991:                 // the entire source dir\file is still in static szName.
                   1992:                 // static lpszHold points to the end of the dir
                   1993:                 //
1.1.1.3 ! root     1994:                 *lpszHold = TEXT('\0');
1.1       root     1995: 
                   1996:                 lstrcpy(szDest, szName);
                   1997: 
                   1998:                 if( SendDlgItemMessage( hDlg, SB_SOURCE, WM_GETTEXT,
                   1999:                                         DIRECTORY_STRING_SIZE,
                   2000:                                         (LPARAM)lpszHold) == LB_ERR ){
1.1.1.3 ! root     2001:                     ErrorMsg(TEXT("Rename: Get Source String failure."));
1.1       root     2002:                     EndDialog(hDlg, wParam);
                   2003:                     return(1);
                   2004:                 }
                   2005: 
                   2006:                 //
                   2007:                 // If there are any \s in the new filename, fail.
                   2008:                 //
1.1.1.3 ! root     2009:                 lpszCheck = TStrChr(lpszHold, TEXT('\\'));
1.1       root     2010: 
                   2011:                 if( lpszCheck ){
1.1.1.3 ! root     2012:                     MessageBox(lpCInfo->hwnd,
        !          2013:                                TEXT("Rename works only in current directory."),
        !          2014:                                TEXT("Filer Notification"), MB_OK );
1.1       root     2015:                     return(1);
                   2016:                 }
                   2017: 
1.1.1.3 ! root     2018:                 lpszHold = TStrChr(szDest, TEXT('\0'));
1.1       root     2019: 
                   2020:                 if( SendDlgItemMessage( hDlg, SB_DEST, WM_GETTEXT,
                   2021:                                         DIRECTORY_STRING_SIZE,
                   2022:                                         (LPARAM)lpszHold) == LB_ERR ){
1.1.1.3 ! root     2023:                     ErrorMsg(TEXT("Rename: Get Destination String failure."));
1.1       root     2024:                     EndDialog(hDlg, wParam);
                   2025:                     return(1);
                   2026:                 }
                   2027: 
                   2028:                 //
1.1.1.3 ! root     2029:                 // If there are any \s in the destination filename, fail.
1.1       root     2030:                 //
1.1.1.3 ! root     2031:                 lpszCheck = TStrChr(lpszHold, TEXT('\\'));
1.1       root     2032: 
                   2033:                 if( lpszCheck ){
1.1.1.3 ! root     2034:                     MessageBox(lpCInfo->hwnd,
        !          2035:                                TEXT("Rename works only in current directory."),
        !          2036:                                TEXT("Filer Notification"), MB_OK );
1.1       root     2037:                     return(1);
                   2038:                 }
                   2039: 
                   2040:                 //
                   2041:                 // if strings are identical, leave.
                   2042:                 //
1.1.1.3 ! root     2043:                 if( !lstrcmpi(szName, szDest) ){
1.1       root     2044:                     EndDialog(hDlg, wParam);
                   2045:                     return(1);
                   2046:                 }
                   2047: 
                   2048:                 if( !MoveFile( szName, szDest) )
1.1.1.3 ! root     2049:                     if( !HandleIOError(lpCInfo->hwnd,
1.1       root     2050:                                        (DWORD)MM_RENAME, szName, szDest) ){
                   2051:                         EndDialog(hDlg, wParam);
                   2052:                         return(1);
                   2053:                     }
                   2054: 
1.1.1.3 ! root     2055:                 if( !PostMessage(lpCInfo->hwnd, WM_COMMAND, MM_FILLFILE,
        !          2056:                                  (LPARAM)0) )
        !          2057:                     ErrorMsg(TEXT("RenameProc: Fillfile failure."));
1.1       root     2058: 
                   2059:                 EndDialog(hDlg, wParam);
                   2060:                 return(1);
                   2061:             }
                   2062:             case SB_CANCEL:{
                   2063:                 EndDialog(hDlg, wParam);
                   2064:                 return(1);
                   2065:             }
                   2066:         }
                   2067:         return(1);
                   2068:       } // WM_COMMAND
                   2069:     }
                   2070: 
                   2071:     return(0);
                   2072: }
                   2073: 
                   2074: 
                   2075: /***************************************************************************\
                   2076: * MkDirProc()
                   2077: *
                   2078: * File I/O Make Directory Dialog Box
                   2079: *
                   2080: * History:
                   2081: * 6/5/92  2am
                   2082: *   Created.
                   2083: \***************************************************************************/
1.1.1.3 ! root     2084: LRESULT WINAPI MkDirProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
1.1       root     2085: {
                   2086:     switch (message){
                   2087:       case WM_INITDIALOG:{
                   2088:         LPCINFO lpCInfo;
1.1.1.3 ! root     2089:         TCHAR   szDest[DIRECTORY_STRING_SIZE];
        !          2090:         LPTSTR  lpszHold;
1.1       root     2091: 
                   2092: 
                   2093:         lpCInfo = (LPCINFO)lParam;
                   2094: 
1.1.1.3 ! root     2095:         //
        !          2096:         // Check to see if there is a terminating backslash, by decrementing
        !          2097:         //  pointer, checking, adding a '\' if necessary.
        !          2098:         //
1.1       root     2099:         lstrcpy(szDest, lpCInfo->CaptionBarText);
1.1.1.3 ! root     2100:         lpszHold = TStrChr(szDest, TEXT('\0'));
        !          2101: 
        !          2102:         lpszHold--;
        !          2103:         if( *lpszHold != TEXT('\\') ){
        !          2104:             lpszHold++;
        !          2105:             *lpszHold = TEXT('\\');
        !          2106:             lpszHold++;
        !          2107:             *lpszHold = TEXT('\0');
        !          2108:         }
1.1       root     2109: 
                   2110:         SendDlgItemMessage( hDlg, SB_DEST, EM_LIMITTEXT,
                   2111:                             (WPARAM)DIRECTORY_STRING_SIZE, (LPARAM)0);
                   2112: 
                   2113:         //
                   2114:         // Place name in directory name edit control.
                   2115:         //
1.1.1.3 ! root     2116:         if( SendDlgItemMessage( hDlg, SB_DEST, WM_SETTEXT, 0,
1.1       root     2117:                                 (LPARAM)szDest) == LB_ERR ){
1.1.1.3 ! root     2118:             ErrorMsg(TEXT("Mkdir: Add Directory Name String failure."));
1.1       root     2119:             return(1);
                   2120:         }
                   2121: 
                   2122:         SendDlgItemMessage( hDlg, SB_DEST, EM_SETSEL, (WPARAM)-1, (LPARAM)0);
                   2123: 
                   2124:         return(1);
                   2125:       }
                   2126:       case WM_COMMAND:{
                   2127:         switch(wParam){
                   2128:             case SB_OK:{
1.1.1.3 ! root     2129:                 TCHAR    szDest[DIRECTORY_STRING_SIZE];
1.1       root     2130: 
                   2131:                 if( SendDlgItemMessage( hDlg, SB_DEST, WM_GETTEXT,
                   2132:                                         DIRECTORY_STRING_SIZE,
                   2133:                                         (LPARAM)szDest) == LB_ERR ){
1.1.1.3 ! root     2134:                     ErrorMsg(TEXT("MkDir: Get Directory Location String failure."));
1.1       root     2135:                     EndDialog(hDlg, wParam);
                   2136:                     return(1);
                   2137:                 }
                   2138: 
                   2139:                 //
                   2140:                 // If loacation of subdir is invalid, leave.
                   2141:                 //
                   2142:                 if( !CreateDirectory(szDest, NULL) ){
1.1.1.3 ! root     2143:                     ErrorMsg(TEXT("MkDir: Create Directory failure."));
1.1       root     2144:                     EndDialog(hDlg, wParam);
                   2145:                     return(1);
                   2146:                 }
1.1.1.3 ! root     2147: 
        !          2148:                 SendMessage( ghwndDrv1, WM_COMMAND, MM_REFRESH, (LPARAM)0);
        !          2149:                 SendMessage( ghwndDrv2, WM_COMMAND, MM_REFRESH, (LPARAM)0);
1.1       root     2150:             }
                   2151:             case SB_CANCEL:{
                   2152:                 EndDialog(hDlg, wParam);
                   2153:                 return(1);
                   2154:             }
                   2155:         }
                   2156:         return(1);
                   2157:       }
                   2158:     }
                   2159: 
                   2160:     return(0);
                   2161: }
                   2162: 
                   2163: 
                   2164: /***************************************************************************\
                   2165: *
                   2166: * TextWndProc()
                   2167: *
                   2168: * Text Window procedure for displaying miscellaneous messages to user.
                   2169: *
                   2170: * History:
                   2171: * 5/25/92
                   2172: *   Created.
                   2173: *
                   2174: \***************************************************************************/
                   2175: 
1.1.1.2   root     2176: LRESULT WINAPI TextWndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
1.1       root     2177: {
                   2178: 
                   2179:     switch (message)
                   2180:     {
                   2181:     case WM_CREATE:
                   2182:         {
1.1.1.3 ! root     2183:         HDC        hDC;
        !          2184:         HGDIOBJ    hOldFont;
        !          2185:         TEXTMETRIC tm;
        !          2186:         LONG       lHeight;
1.1       root     2187: 
1.1.1.3 ! root     2188:         hDC = GetDC(hwnd);
1.1       root     2189: 
1.1.1.3 ! root     2190:         hOldFont = SelectObject(hDC, ghFont);
        !          2191:         GetTextMetrics(hDC, &tm);
1.1       root     2192: 
1.1.1.3 ! root     2193:         //
        !          2194:         // base the height of the window on size of text
        !          2195:         //
        !          2196:         lHeight = tm.tmHeight + GetSystemMetrics(SM_CYBORDER) + 6;
1.1       root     2197: 
1.1.1.3 ! root     2198:         //
        !          2199:         // saved the height for later reference
        !          2200:         //
        !          2201:         SetWindowLong(hwnd, GWL_USERDATA, lHeight);
1.1       root     2202: 
                   2203:             if(hOldFont)
                   2204:                 SelectObject(hDC, hOldFont);
1.1.1.3 ! root     2205: 
1.1       root     2206:             ReleaseDC(hwnd, hDC);
                   2207:             break;
                   2208:         }
                   2209: 
                   2210:     case WM_SETTEXT:
                   2211:             DefWindowProc(hwnd, message, wParam, lParam);
                   2212:             if( !InvalidateRect(hwnd, NULL, TRUE) ){
1.1.1.3 ! root     2213:                 ErrorMsg(TEXT("Textwindow: Set text failure."));
1.1       root     2214:                 return(1);
                   2215:             }
                   2216:             UpdateWindow(hwnd);
                   2217:             return(1);
                   2218: 
                   2219:     case WM_PAINT:
                   2220:         {
                   2221:             PAINTSTRUCT ps;
                   2222:             RECT        rc;
1.1.1.3 ! root     2223:             TCHAR       ach[128];
1.1       root     2224:             int         len, nxBorder, nyBorder;
                   2225:             HFONT       hOldFont = NULL;
                   2226:             HBRUSH      hBrush;
                   2227: 
                   2228:             BeginPaint(hwnd, &ps);
                   2229: 
                   2230:             GetClientRect(hwnd,&rc);
                   2231: 
                   2232:             len = GetWindowText(hwnd, ach, sizeof(ach));
                   2233: 
1.1.1.3 ! root     2234:             SetBkMode(ps.hdc, TRANSPARENT);
1.1       root     2235: 
                   2236:             if( GetParent(hwnd) == ghActiveChild ){
1.1.1.3 ! root     2237:                 hBrush = CreateSolidBrush( GetSysColor(COLOR_ACTIVECAPTION) );
        !          2238:                 SetTextColor( ps.hdc, GetSysColor(COLOR_CAPTIONTEXT) );
1.1       root     2239:             }
                   2240:             else{
                   2241:                 hBrush = CreateSolidBrush( GetSysColor(COLOR_INACTIVECAPTION) );
1.1.1.3 ! root     2242:                 SetTextColor( ps.hdc, GetSysColor(COLOR_INACTIVECAPTIONTEXT) );
1.1       root     2243:             }
                   2244: 
1.1.1.3 ! root     2245:             hOldFont = SelectObject(ps.hdc, ghFont);
1.1       root     2246: 
                   2247:             FillRect(ps.hdc, &rc, hBrush);
                   2248: 
                   2249:             nxBorder = GetSystemMetrics(SM_CXBORDER);
1.1.1.3 ! root     2250:             rc.left  += 9*nxBorder;
1.1       root     2251:             rc.right -= 9*nxBorder;
                   2252: 
                   2253:             nyBorder = GetSystemMetrics(SM_CYBORDER);
1.1.1.3 ! root     2254:             rc.top    += 3*nyBorder;
        !          2255:             rc.bottom -= 3*nyBorder;
1.1       root     2256: 
1.1.1.3 ! root     2257:             ExtTextOut(ps.hdc, rc.left+2*nxBorder, rc.top, ETO_CLIPPED,
        !          2258:                     &rc, ach, len, NULL);
1.1       root     2259: 
1.1.1.3 ! root     2260:             SetBkMode(ps.hdc, OPAQUE);
1.1       root     2261: 
1.1.1.3 ! root     2262:             if (hOldFont)
        !          2263:                 SelectObject(ps.hdc, hOldFont);
1.1       root     2264: 
                   2265:             DeleteObject(hBrush);
                   2266: 
                   2267:             EndPaint(hwnd, &ps);
                   2268:             return(1);
                   2269:         }
                   2270:     }
                   2271:     return DefWindowProc(hwnd, message, wParam, lParam);
                   2272: }
1.1.1.3 ! root     2273: 
        !          2274: /***************************************************************************\
        !          2275: *
        !          2276: * TStrChr()
        !          2277: *
        !          2278: * A strchr() function which is ASCII or UNICODE.
        !          2279: *
        !          2280: * History:
        !          2281: * 2/25/93
        !          2282: *   Created.
        !          2283: *
        !          2284: \***************************************************************************/
        !          2285: PTCHAR TStrChr(const PTCHAR string, UINT c)
        !          2286: {
        !          2287: #ifdef UNICODE
        !          2288:     return wcschr((wchar_t*)string, (wchar_t)c);
        !          2289: #else
        !          2290:     return strchr(string, c);
        !          2291: #endif
        !          2292: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.