home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c480 / 18.ddi / SAMPLES / XTENSION / XTENSION.C_ / XTENSION.C
Encoding:
C/C++ Source or Header  |  1993-02-08  |  23.7 KB  |  794 lines

  1. //***************************************************************************
  2. //
  3. //  Library:
  4. //      XTENSION.DLL
  5. //
  6. //
  7. //  Author:
  8. //      Microsoft Product Support Services.
  9. //
  10. //
  11. //  Purpose:
  12. //      XTENSION is a File Manager extension DLL.  An extension DLL adds
  13. //      a menu to File Manager, contains entry point that processes menu
  14. //      commands and notification messages sent by File Manager, and
  15. //      queries data and information about the File Manager windows.  The 
  16. //      purpose of an extension DLL is to add administration support 
  17. //      features to File Manager, for example, file and disk utilities.
  18. //      Up to five extension DLLs may be instaled at any one time.
  19. //
  20. //      XTENSION adds a menu called "Extension" to File manager and 
  21. //      processes all the messages that are sent by File Manager to an 
  22. //      extension DLL.  In order to retrieve any information, it sends 
  23. //      messages to File Manager.  It also creates a topmost status window 
  24. //      using the DLL's instance handle.
  25. //
  26. //
  27. //  Usage:
  28. //      File Manager installs the extensions that have entries in the 
  29. //      [AddOns] section of the WINFILE.INI initialization file.  An entry 
  30. //      consists of a tag and a value.  To load XTENSION.DLL as a File 
  31. //      Manager extension, add the following to WINFILE.INI (assuming the 
  32. //      DLL resides in c:\win\system):
  33. //
  34. //      [AddOns]
  35. //      SDK Demo Extension=c:\win\system\xtension.dll
  36. //
  37. //
  38. //  Menu Options:
  39. //      Following menu items belong to the "Extension" menu that is added
  40. //      to File Manager:
  41. //
  42. //      Status Window               - Shows/Hides status window
  43. //      Selected File(s) Size...    - Displays disk space taken by the files
  44. //      Selected Drive Info...      - Displays selected drive information
  45. //      Focused Item Info           - Displays the name of the focused item
  46. //      Reload Extension            - Reloads this extension
  47. //      Refresh Window              - Refreshes File Manager's active window
  48. //      Refresh All Windows         - Refreshes all the File Manager's windows
  49. //      About Extension...          - Displays About dialog
  50. //
  51. //
  52. //  More Info:
  53. //      Query on-line help on: FMExtensionProc, File Manager Extensions
  54. //
  55. //
  56. //  Copyright (c) 1992 Microsoft Corporation. All rights reserved.
  57. //
  58. //***************************************************************************
  59.  
  60. #include <windows.h>
  61. #include "wfext.h"
  62. #include "xtension.h"
  63.  
  64. char    gszDllWndClass[] = "ExtenStatusWClass"; // Class name for status window
  65. HWND    ghwndStatus = 0;                        // Status window
  66. HWND    ghwndInfo;                              // Child window of status window
  67. HANDLE  ghDllInst;                              // DLL's instance handle
  68. HMENU   ghMenu;                                 // Extension's menu handle
  69. WORD    gwMenuDelta;                            // Delta for extension's menu items
  70. BOOL    gbStatusWinVisible = FALSE;             // Flag for status window
  71.                                                    // FALSE=Hidden,  TRUE=Visible
  72.  
  73. //***************************************************************************
  74. //
  75. //  LibMain()
  76. //
  77. //  Purpose:
  78. //
  79. //      LibMain is called by LibEntry.  LibEntry is called by Windows
  80. //      when the DLL is loaded.  The LibEntry routine is provided
  81. //      in the LIBENTRY.OBJ in the SDK Link Libraries disk.  (The
  82. //      source LIBENTRY.ASM is also provided.)
  83. //
  84. //      LibEntry initializes the DLL's heap if a HEAPSIZE value is
  85. //      specified in the DLL's DEF file.  After this, LibEntry calls
  86. //      LibMain.  The LibMain function below satisfies that call.
  87. //
  88. //      The LibMain function should perform additional initialization
  89. //      tasks required by the DLL.  In this example, no initialization
  90. //      tasks are required; only the DLL's instance handle is saved.  
  91. //      LibMain should return a value of TRUE if the initialization is 
  92. //      successful.
  93. //
  94. //
  95. //  Parameters:
  96. //
  97. //      IN:
  98. //          hLibInst    - DLLs instance handle
  99. //          wDataSeg    - Data segment
  100. //          cbHeapSize  - Size of the DLL's heap
  101. //          lpszCmdLine - Command line
  102. //
  103. //      OUT:
  104. //          N/A
  105. //
  106. //  Return Value:
  107. //
  108. //      TRUE if the initialization is successful; FALSE otherwise.
  109. //
  110. //***************************************************************************
  111.  
  112. int FAR PASCAL LibMain (HANDLE hLibInst,  WORD wDataSeg,
  113.                        WORD cbHeapSize, LPSTR lpszCmdLine)
  114. {
  115.     ghDllInst = hLibInst;
  116.     return (1);
  117. } // LibMain()
  118.  
  119. //***************************************************************************
  120. //
  121. //  WEP()
  122. //
  123. //  Purpose:
  124. //
  125. //      Performs cleanup tasks when the .DLL is unloaded.  The WEP() is
  126. //      called automatically by Windows when the DLL is unloaded.
  127. //      
  128. //      Make sure that the WEP() is @1 RESIDENTNAME in the EXPORTS
  129. //      section of the .DEF file.  This ensures that the WEP() can
  130. //      be called as quickly as possible.  Incidently, this is why
  131. //      the WEP() is called the WEP() instead of WindowsExitProcedure().
  132. //      It takes up the minimum amount of space and is quickly located.
  133. //
  134. //
  135. //  Parameters:
  136. //
  137. //      IN:
  138. //          bSystemExit - Type of exit
  139. //
  140. //      OUT:
  141. //          N/A
  142. //
  143. //  Return Value:
  144. //
  145. //      TRUE.
  146. //
  147. //***************************************************************************
  148.  
  149. int FAR PASCAL __export WEP (int bSystemExit)
  150. {
  151.     return (1);
  152. } // WEP()
  153.  
  154.  
  155. //***************************************************************************
  156. //
  157. //  FMExtensionProc()
  158. //
  159. //  Purpose:
  160. //
  161. //      This is an application-defined callback function.  It processes menu 
  162. //      commands and messages sent to XTENSION.DLL.
  163. //
  164. //
  165. //  Parameters:
  166. //
  167. //      IN:
  168. //          hwndExtension   - Identifies the File Manager window
  169. //          wMessage        - Message sent to extension DLL
  170. //          lParam          - Message information
  171. //
  172. //      OUT:
  173. //          N/A
  174. //
  175. //  Return Value:
  176. //
  177. //      When the wMessage is FMEVENT_INITMENU, handle to extension's menu
  178. //      should be returned; otherwise a NULL value.
  179. //
  180. //***************************************************************************
  181.  
  182. HMENU FAR PASCAL __export FMExtensionProc (HWND hwndExtension, WORD wMessage,
  183.                                   LONG lParam)
  184. {
  185.     LPFMS_LOAD  lpload;
  186.     FARPROC     lpDialogProc;
  187.     WORD        wFocusedItem;
  188.  
  189.     switch (wMessage)
  190.     {
  191.  
  192.     // ****************** File Manager Events
  193.  
  194.         case FMEVENT_INITMENU:
  195.             DisplayStatus (hwndExtension, wMessage);
  196.  
  197.             break;
  198.  
  199.         case FMEVENT_LOAD:
  200.  
  201.             // Create status window
  202.  
  203.             if (!ghwndStatus)
  204.             {
  205.                 if (!CreateStatusWindow (hwndExtension))
  206.                 {
  207.                     MessageBox (hwndExtension,
  208.                                 "Extension not loaded.  Status window creation error.",
  209.                                 "File Manager Extension",
  210.                                 MB_OK | MB_ICONASTERISK);
  211.  
  212.                     // Unload
  213.                     break;
  214.                 }
  215.             }
  216.  
  217.             lpload  = (LPFMS_LOAD) lParam;
  218.  
  219.             // Assign the menu handle from the DLL's resource
  220.  
  221.             ghMenu = LoadMenu (ghDllInst, "ExtensionMenu");
  222.  
  223.             lpload->hMenu = ghMenu;
  224.  
  225.             // This is the delta we are being assigned.
  226.  
  227.             gwMenuDelta = lpload->wMenuDelta;
  228.  
  229.             // Size of the load structure
  230.  
  231.             lpload->dwSize = sizeof (FMS_LOAD);
  232.         
  233.             // Assign the popup menu name for this extension
  234.  
  235.             lstrcpy (lpload->szMenuName, "&Extension");
  236.  
  237.             MessageBox (hwndExtension, "File Manager Extension will be loaded.",
  238.                         "File Manager Extension", MB_OK);
  239.  
  240.             // Return that handle
  241.  
  242.             return (ghMenu);
  243.  
  244.  
  245.         case FMEVENT_SELCHANGE:
  246.             DisplayStatus (hwndExtension, wMessage);
  247.  
  248.             break;
  249.  
  250.         case FMEVENT_UNLOAD:
  251.             DisplayStatus (hwndExtension, wMessage);
  252.             MessageBox (hwndExtension, "File Manager Extension will be unloaded.",
  253.                         "File Manager Extension", MB_OK);
  254.  
  255.             // Since the status window was created using DLL's 
  256.             // instance handle, we will have to destroy it on our own.
  257.  
  258.             DestroyWindow (ghwndStatus);
  259.  
  260.             break;
  261.  
  262.         case FMEVENT_USER_REFRESH:
  263.             DisplayStatus (hwndExtension, wMessage);
  264.  
  265.             break;
  266.  
  267.  
  268.     // ****************** Extension menu commands
  269.  
  270.         case IDM_STATUSWIN:
  271.             if (GetMenuState (ghMenu, gwMenuDelta + wMessage,
  272.                               MF_BYCOMMAND) & MF_CHECKED)
  273.             {
  274.                 gbStatusWinVisible = FALSE;
  275.  
  276.                 // Hide the status window
  277.  
  278.                 ShowWindow (ghwndStatus, SW_HIDE);
  279.  
  280.                 // Remove the checkmark 
  281.  
  282.                 CheckMenuItem (ghMenu, gwMenuDelta+IDM_STATUSWIN,
  283.                                MF_UNCHECKED | MF_BYCOMMAND);
  284.  
  285.             }
  286.             else
  287.             {
  288.                 gbStatusWinVisible = TRUE;
  289.  
  290.                 // Show the status window
  291.  
  292.                 ShowWindow (ghwndStatus, SW_SHOW);
  293.  
  294.                 // Add the checkmark 
  295.  
  296.                 CheckMenuItem (ghMenu, gwMenuDelta+IDM_STATUSWIN,
  297.                                MF_CHECKED | MF_BYCOMMAND);
  298.             }
  299.  
  300.             break;
  301.  
  302.         case IDM_GETDRIVEINFO:
  303.             lpDialogProc = (FARPROC) DriveInfoDlgProc;
  304.  
  305.             DialogBoxParam (ghDllInst,
  306.                             "DriveInfo",
  307.                             hwndExtension,
  308.                             lpDialogProc,
  309.                             (LONG) hwndExtension);
  310.  
  311.             break;
  312.  
  313.         case IDM_GETFILESELLFN:
  314.             lpDialogProc = (FARPROC) SelFileInfoDlgProc;
  315.  
  316.             DialogBoxParam (ghDllInst,
  317.                             "FileInfo",
  318.                             hwndExtension,
  319.                             lpDialogProc,
  320.                             (LONG) hwndExtension);
  321.  
  322.             break;
  323.  
  324.         case IDM_GETFOCUS:
  325.             wFocusedItem = (WORD) SendMessage (hwndExtension, FM_GETFOCUS, 0, 0L);
  326.  
  327.             switch (wFocusedItem)
  328.             {
  329.                 case FMFOCUS_DIR:
  330.                     MessageBox (hwndExtension, "Focus is on the DIRECTORY window.",
  331.                                 "Focus Information", MB_OK);
  332.                     break;
  333.  
  334.                 case FMFOCUS_TREE:
  335.                     MessageBox (hwndExtension, "Focus is on the TREE window.",
  336.                                 "Focus Information", MB_OK);
  337.                     break;
  338.  
  339.                 case FMFOCUS_DRIVES:
  340.                     MessageBox (hwndExtension, "Focus is on the DRIVE bar.",
  341.                                 "Focus Information", MB_OK);
  342.                     break;
  343.  
  344.                 case FMFOCUS_SEARCH:
  345.                     MessageBox (hwndExtension, "Focus is on the SEARCH RESULTS window.",
  346.                                 "Focus Information", MB_OK);
  347.             }
  348.  
  349.             break;
  350.  
  351.         case IDM_REFRESHWINDOW:
  352.         case IDM_REFRESHALLWINDOWS:
  353.             // Refresh one or all the windows
  354.  
  355.             SendMessage (hwndExtension, FM_REFRESH_WINDOWS,
  356.                          wMessage == IDM_REFRESHALLWINDOWS, 0L);
  357.  
  358.             break;
  359.  
  360.         case IDM_RELOADEXTENSIONS:
  361.             PostMessage(hwndExtension, FM_RELOAD_EXTENSIONS, 0, 0L);
  362.  
  363.             break;
  364.  
  365.         case IDM_ABOUTEXT:
  366.             lpDialogProc = (FARPROC) AboutDlgProc;
  367.  
  368.             DialogBox (ghDllInst,
  369.                        "AboutExtension",
  370.                        hwndExtension,
  371.                        lpDialogProc);
  372.  
  373.             break;
  374.     }
  375.  
  376.     return (NULL);
  377.  
  378. } // FMExtentensionProc()
  379.  
  380.  
  381. //***************************************************************************
  382. //
  383. //  CreateStatusWindow()
  384. //
  385. //  Purpose:
  386. //
  387. //      Creates a status window to display different File Manager events.
  388. //
  389. //
  390. //  Parameters:
  391. //
  392. //      IN:
  393. //          void
  394. //
  395. //      OUT:
  396. //          void
  397. //
  398. //  Return Value:
  399. //
  400. //      TRUE if status window is created; otherwise FALSE.
  401. //
  402. //***************************************************************************
  403.  
  404. BOOL CreateStatusWindow (HWND hwndExtension)
  405. {
  406.     WNDCLASS    wc;
  407.  
  408.     wc.style            = NULL;
  409.     wc.lpfnWndProc      = StatusWndProc;
  410.     wc.cbClsExtra       = 0;
  411.     wc.cbWndExtra       = 0;
  412.     wc.hInstance        = ghDllInst;
  413.     wc.hIcon            = LoadIcon (NULL, IDI_APPLICATION);
  414.     wc.hCursor          = LoadCursor (NULL, IDC_ARROW);
  415.     wc.hbrBackground    = COLOR_WINDOW+1;
  416.     wc.lpszMenuName     = NULL;
  417.     wc.lpszClassName    = (LPSTR) gszDllWndClass;
  418.  
  419.     if (!RegisterClass (&wc))
  420.         return (FALSE);
  421.  
  422.     ghwndStatus = CreateWindowEx (WS_EX_TOPMOST | WS_EX_DLGMODALFRAME,
  423.                                   gszDllWndClass,
  424.                                   "File Manager Extension",
  425.                                   WS_POPUP | WS_CAPTION,
  426.                                   CW_USEDEFAULT,
  427.                                   CW_USEDEFAULT,
  428.                                   STATUS_WIDTH,
  429.                                   STATUS_HEIGHT,
  430.                                   hwndExtension,
  431.                                   NULL,
  432.                                   ghDllInst,
  433.                                   NULL);
  434.  
  435.     ghwndInfo = CreateWindow ("STATIC",
  436.                               NULL,
  437.                               WS_CHILD | WS_VISIBLE,
  438.                               INFO_LINE_X,
  439.                               INFO_LINE_Y,
  440.                               INFO_LINE_WIDTH,
  441.                               INFO_LINE_HEIGHT,
  442.                               ghwndStatus,
  443.                               1,
  444.                               ghDllInst,
  445.                               NULL);
  446.  
  447.  
  448.     return ((BOOL) ghwndStatus | ghwndInfo);
  449. } // CreateStatusWindow()
  450.  
  451.  
  452. //***************************************************************************
  453. //
  454. //  StatusWndProc()
  455. //
  456. //  Purpose:
  457. //
  458. //      Window procedure of the DLL's status window.
  459. //
  460. //
  461. //  Parameters:
  462. //
  463. //      IN:
  464. //          hWnd        - Identifies the status window
  465. //          uMessage    - Message for this window
  466. //          wParam      - Message information
  467. //          lParam      - Additional message information
  468. //
  469. //      OUT:
  470. //          N/A
  471. //
  472. //  Return Value:
  473. //
  474. //      Appropriate value for the window message.
  475. //
  476. //***************************************************************************
  477.  
  478. long FAR PASCAL __export StatusWndProc (HWND hWnd, UINT uMessage,
  479.                    WPARAM wParam, LPARAM lParam)
  480. {
  481.     switch (uMessage)
  482.     {
  483.         case WM_TIMER:
  484.             // This timer is used to erase info from the 
  485.             // status window at the elapsed time
  486.  
  487.             if (wParam == ID_STATUSTIMER)
  488.             {
  489.                 KillTimer (hWnd, (UINT) wParam);
  490.                 SetWindowText (ghwndInfo, (LPSTR) '\0');
  491.             }
  492.             break;
  493.  
  494.         default:
  495.             return (DefWindowProc (hWnd, uMessage, wParam, lParam));
  496.     }
  497.     return (0L);
  498. } // StatusWndProc()
  499.  
  500.  
  501. //***************************************************************************
  502. //
  503. //  DisplayStatus()
  504. //
  505. //  Purpose:
  506. //
  507. //      Displays a File Manager event in the status window.  A timer is used
  508. //      to cler the status window after the elapsed time.  The timer messages
  509. //      go to the status window's procedure.
  510. //
  511. //
  512. //  Parameters:
  513. //
  514. //      IN:
  515. //          hwndExtension   - Identifies the File Manager window
  516. //          wEvent          - File Manager's event to be displayed
  517. //
  518. //      OUT:
  519. //          N/A
  520. //
  521. //  Return Value:
  522. //
  523. //      void
  524. //
  525. //***************************************************************************
  526.  
  527. void DisplayStatus (HWND hwndExtension, WORD wEvent)
  528. {
  529.     WORD    wFileCount;
  530.     char    szInfo [INFO_STR_LEN];
  531.  
  532.     if (gbStatusWinVisible)
  533.     {
  534.         switch (wEvent)
  535.         {
  536.             case FMEVENT_INITMENU:
  537.                 SetWindowText (ghwndInfo, (LPSTR) "Extension menu selected...");
  538.                 break;
  539.  
  540.             case FMEVENT_SELCHANGE:
  541.                 wFileCount = (WORD) SendMessage (hwndExtension, FM_GETSELCOUNTLFN, 0, 0L);
  542.                 wsprintf (szInfo, "File selection changed: %d item(s) selected...", wFileCount);
  543.                 SetWindowText (ghwndInfo, (LPSTR) szInfo);
  544.                 break;
  545.  
  546.             case FMEVENT_UNLOAD:
  547.                 SetWindowText (ghwndInfo, (LPSTR) "Unloading extension...");
  548.                 break;
  549.  
  550.             case FMEVENT_USER_REFRESH:
  551.                 SetWindowText (ghwndInfo, (LPSTR) "Refreshing window(s)...");
  552.                 break;
  553.         }
  554.  
  555.         // Timer to erase the info after the elapsed time
  556.  
  557.         SetTimer (ghwndStatus, ID_STATUSTIMER, TIMER_DURATION, NULL);
  558.     }
  559. } // DisplayStatus()
  560.  
  561.  
  562. //***************************************************************************
  563. //
  564. //  AboutDlgProc()
  565. //
  566. //  Purpose:
  567. //
  568. //      Procedure to handle About dialog messages.  This dialog displays
  569. //      copyright and help information.
  570. //      
  571. //
  572. //  Parameters:
  573. //
  574. //      IN:
  575. //          hDlg        - Dialog window handle
  576. //          uMessage    - Dialog message
  577. //          wParam      - Message information
  578. //          lParam      - Additional message information
  579. //
  580. //      OUT:
  581. //          N/A
  582. //
  583. //  Return Value:
  584. //
  585. //      Appropriate value for the dialog message.
  586. //
  587. //***************************************************************************
  588.  
  589. BOOL FAR PASCAL __export AboutDlgProc (HWND hDlg,   unsigned uMessage,
  590.                               WORD wParam, LONG lParam)
  591. {
  592.     switch (uMessage)
  593.     {
  594.         case WM_INITDIALOG:
  595.             return (TRUE);
  596.  
  597.         case WM_COMMAND:
  598.             switch (wParam)
  599.             {
  600.                 case IDOK:
  601.                 case IDCANCEL:
  602.                     EndDialog (hDlg, TRUE);
  603.                     return (TRUE);
  604.  
  605.                 default:
  606.                     break;
  607.             } // switch (wParam)
  608.     } // switch (message)
  609.  
  610.     return (FALSE);
  611. } // AboutDlgProc
  612.  
  613.  
  614. //***************************************************************************
  615. //
  616. //  DriveInfoDlgProc()
  617. //
  618. //  Purpose:
  619. //
  620. //      Procedure to handle Drive Info dialog messages.  This dialog displays
  621. //      information on the selected drive.  It queries this information by
  622. //      sending a FM_GETDRIVEINFO message to File Manager.
  623. //      
  624. //
  625. //  Parameters:
  626. //
  627. //      IN:
  628. //          hDlg        - Dialog window handle
  629. //          uMessage    - Dialog message
  630. //          wParam      - Message information
  631. //          lParam      - Additional message information
  632. //
  633. //      OUT:
  634. //          N/A
  635. //
  636. //  Return Value:
  637. //
  638. //      Appropriate value for the dialog message.
  639. //
  640. //***************************************************************************
  641.  
  642. BOOL FAR PASCAL __export DriveInfoDlgProc (HWND hDlg,   unsigned uMessage,
  643.                                   WORD wParam, LONG lParam)
  644. {
  645.     static  FMS_GETDRIVEINFO    fmsDriveInfo;
  646.             char                szTempString [SMALL_STR_LEN];
  647.  
  648.     switch (uMessage)
  649.     {
  650.         case WM_INITDIALOG:
  651.             SendMessage ((HWND) lParam, FM_GETDRIVEINFO, 0,
  652.                          (LONG) (LPFMS_GETDRIVEINFO) &fmsDriveInfo);
  653.  
  654.             // Convert OEM characters to Windows characters
  655.  
  656.             OemToAnsi (fmsDriveInfo.szPath, fmsDriveInfo.szPath);
  657.             OemToAnsi (fmsDriveInfo.szVolume, fmsDriveInfo.szVolume);
  658.  
  659.             if (fmsDriveInfo.szShare [0])
  660.                 OemToAnsi (fmsDriveInfo.szShare, fmsDriveInfo.szShare);
  661.             else
  662.                 lstrcpy (fmsDriveInfo.szShare, "< Not a Share >");
  663.  
  664.             if (fmsDriveInfo.szVolume [0])
  665.                 SetDlgItemText (hDlg, IDD_VOLUME, (LPSTR) fmsDriveInfo.szVolume);
  666.             else
  667.                 SetDlgItemText (hDlg, IDD_VOLUME, "< No volume label >");
  668.  
  669.             SetDlgItemText (hDlg, IDD_PATH, (LPSTR) fmsDriveInfo.szPath);
  670.             SetDlgItemText (hDlg, IDD_SHARE, (LPSTR) fmsDriveInfo.szShare);
  671.  
  672.  
  673.             // When a -1 is returned for either dwTotalSpace or dwFreeSpace,
  674.             // the extension will have compute that number on its own.
  675.  
  676.             if (fmsDriveInfo.dwTotalSpace == -1)
  677.                 SetDlgItemText (hDlg, IDD_TOTALSPACE, "< Info. not available >");
  678.             else
  679.             {
  680.                 wsprintf ((LPSTR) szTempString, "%ld", fmsDriveInfo.dwTotalSpace);
  681.                 SetDlgItemText (hDlg, IDD_TOTALSPACE, (LPSTR) szTempString);
  682.             }
  683.  
  684.             if (fmsDriveInfo.dwFreeSpace == -1)
  685.                 SetDlgItemText (hDlg, IDD_FREESPACE, "< Info. not available >");
  686.             else
  687.             {
  688.                 wsprintf ((LPSTR) szTempString, "%ld", fmsDriveInfo.dwFreeSpace);
  689.                 SetDlgItemText (hDlg, IDD_FREESPACE, (LPSTR) szTempString);
  690.             }
  691.  
  692.             return (TRUE);
  693.  
  694.         case WM_COMMAND:
  695.             switch (wParam)
  696.             {
  697.                 case IDOK:
  698.                 case IDCANCEL:
  699.                     EndDialog (hDlg, TRUE);
  700.                     return (TRUE);
  701.  
  702.                 default:
  703.                     break;
  704.             } // switch (wParam)
  705.     } // switch (message) 
  706.  
  707.     return (FALSE);
  708.  
  709. } // DriveInfoDlgProc()
  710.  
  711.  
  712. //***************************************************************************
  713. //
  714. //  SelFIleInfoDlgProc()
  715. //
  716. //  Purpose:
  717. //
  718. //      Procedure to handle File Info dialog messages.  This dialog displays
  719. //      information on the selected files.  It queries this information by
  720. //      sending a FM_GETSELCOUNTLFN message to File Manager.
  721. //      
  722. //
  723. //  Parameters:
  724. //
  725. //      IN:
  726. //          hDlg        - Dialog window handle
  727. //          uMessage    - Dialog message
  728. //          wParam      - Message information
  729. //          lParam      - Additional message information
  730. //
  731. //      OUT:
  732. //          N/A
  733. //
  734. //  Return Value:
  735. //
  736. //      Appropriate value for the dialog message.
  737. //
  738. //***************************************************************************
  739.  
  740. BOOL FAR PASCAL __export SelFileInfoDlgProc (HWND hDlg,   unsigned uMessage,
  741.                                     WORD wParam, LONG lParam)
  742. {
  743.     static  FMS_GETFILESEL  fmsFileInfo;
  744.             WORD            wSelFileCount;
  745.             WORD            wIndex;
  746.             char            szTempString [SMALL_STR_LEN];
  747.             DWORD           dwTotalSize = 0;
  748.  
  749.     switch (uMessage)
  750.     {
  751.         case WM_INITDIALOG:
  752.  
  753.             wSelFileCount = (WORD) SendMessage ((HWND) lParam,
  754.                                                 FM_GETSELCOUNTLFN, 0, 0L);
  755.  
  756.             wsprintf ((LPSTR) szTempString, "%d",
  757.                       wSelFileCount);
  758.  
  759.             SetDlgItemText (hDlg, IDD_SELFILECOUNT, (LPSTR) szTempString);
  760.     
  761.             for (wIndex = 1; wIndex <= wSelFileCount; wIndex++)
  762.             {
  763.                 SendMessage ((HWND) lParam, FM_GETFILESELLFN, wIndex,
  764.                             (LONG) (LPFMS_GETFILESEL) &fmsFileInfo);
  765.  
  766.                 dwTotalSize += fmsFileInfo.dwSize;
  767.  
  768.             }
  769.  
  770.             wsprintf ((LPSTR) szTempString, "%ld bytes",
  771.                       dwTotalSize);
  772.  
  773.             SetDlgItemText (hDlg, IDD_SELFILESIZE, (LPSTR) szTempString);
  774.  
  775.             return (TRUE);
  776.  
  777.         case WM_COMMAND:
  778.             switch (wParam)
  779.             {
  780.                 case IDOK:
  781.                 case IDCANCEL:
  782.                     EndDialog (hDlg, TRUE);
  783.                     return (TRUE);
  784.  
  785.                 default:
  786.                     break;
  787.             } // switch (wParam)
  788.     } // switch (message) 
  789.  
  790.     return (FALSE);
  791.  
  792. } // SelFileInfoDlgProc()
  793.  
  794.