home *** CD-ROM | disk | FTP | other *** search
/ World of Shareware - Software Farm 2 / wosw_2.zip / wosw_2 / CPROG / WDINFOC.ZIP / WDINFO.C next >
C/C++ Source or Header  |  1991-08-02  |  49KB  |  1,466 lines

  1. //*******************************************************************
  2. //
  3. // program - Dinfo.c
  4. // purpose - a Windows program to display directory utilization of a drive.
  5. //
  6. //*******************************************************************
  7.  
  8. #include <windows.h>
  9. #include <stdio.h>
  10. #include <time.h>
  11. #include <dos.h>
  12. #include <dir.h>
  13. #include <alloc.h>
  14.  
  15.  
  16. #include "wdinfo.h"
  17.  
  18.  
  19. // Data that can be referenced throughout the
  20. // program but not passed to other instances
  21.  
  22. HWND      hwndMainDialog ;
  23. HWND      hwndMainWin ;
  24. HWND      hMain ;           // main window handle
  25. HWND      hWnd ;
  26. HMENU     hMenu ;
  27. HWND hAbout ;
  28.  
  29. HANDLE    hdlgr ;       // i think it is handle of dialog like hMain
  30. HANDLE    hInst ;                             // hInstance of application
  31. HANDLE    hAccel ;
  32. static HWND hList ;
  33. static HWND hDirs ;
  34. static WORD W_ItemCnt ;
  35.  
  36. LOGFONT   cursfont;                           // font structure
  37. HANDLE    holdsfont;                          // handle of original font
  38. HANDLE    hnewsfont;                          // handle of new fixed font
  39.  
  40. FARPROC   lpMainDlgProc ;
  41.  
  42. char      DriveId[30] ;
  43. char      DriveSel ;
  44. int       driveln ;
  45.  
  46. int       baselo, basehi ;
  47.  
  48. int       xChar, yChar, yCharnl;              // character size
  49. int       hMainWin, wMainWin ;                // height and width of Main Win
  50. static int Num_Dir ;
  51.  
  52. // function prototypes
  53.  
  54. long FAR PASCAL MainWndProc(HWND hWnd, WORD message,
  55.                              WORD wParam, LONG lParam);
  56.  
  57. BOOL FAR PASCAL MainDlgProc(HWND hDlg, WORD message,
  58.                                WORD wParam, LONG lParam);
  59.  
  60. void DinfoMain (void) ;
  61.  
  62. void MsgListAdd (void) ;
  63.  
  64. int logic(char *) ;
  65.  
  66. void CheckButton(char) ;
  67.  
  68. //*******************************************************************
  69. // WinMain - Dinfo main
  70. //
  71. // paramaters:
  72. //             hInstance     - The instance of this instance of this
  73. //                             application.
  74. //             hPrevInstance - The instance of the previous instance
  75. //                             of this application. This will be 0
  76. //                             if this is the first instance.
  77. //             lpszCmdLine   - A long pointer to the command line that
  78. //                             started this application.
  79. //             cmdShow       - Indicates how the window is to be shown
  80. //                             initially. ie. SW_SHOWNORMAL, SW_HIDE,
  81. //                             SW_MIMIMIZE.
  82. //
  83. // returns:
  84. //             wParam from last message.
  85. //
  86. //*******************************************************************
  87. int PASCAL WinMain(HANDLE hInstance, HANDLE hPrevInstance,
  88.                    LPSTR lpszCmdLine, int cmdShow)
  89. {
  90.  
  91.     MSG   msg ;
  92.     WNDCLASS wndclass ;
  93.     HDC   hdc ;
  94.  
  95.     int  hght, width ;
  96.     LONG baseunit ;
  97.  
  98.  
  99.     typedef struct tagDLGTEMPLATE
  100.     {
  101.         long dtStyle ;
  102.         BYTE dtItemCount ;
  103.         int  dtX ;
  104.         int  dtY ;
  105.         int  dtCX ;
  106.         int  dtCY ;
  107.         char dtMenuName[] ;
  108.         char dtClassName[] ;
  109.         char dtCaptionText[] ;
  110.     }   DLGTEMPLATE;
  111.     DLGTEMPLATE FAR *dltp;
  112.  
  113.     // Define the window class for this application.
  114.     if (!hPrevInstance)
  115.      {
  116.         wndclass.lpszClassName = "Dinfo:Main" ;
  117.         wndclass.hInstance     = hInstance;
  118.         wndclass.lpfnWndProc   = MainWndProc;
  119.         wndclass.hCursor       = LoadCursor(NULL, IDC_ARROW);
  120.         wndclass.hIcon         = LoadIcon(hInstance, "SNAPSHOT");
  121.         wndclass.lpszMenuName  = "WD_Menu" ;  // NULL ;
  122.         wndclass.hbrBackground = GetStockObject(WHITE_BRUSH);
  123.         wndclass.style         = CS_HREDRAW | CS_VREDRAW ;
  124.         wndclass.cbClsExtra    = 0;
  125.         wndclass.cbWndExtra    = 0;
  126.  
  127.         // Register the class
  128.         RegisterClass(&wndclass);
  129.        }
  130.  
  131.     hInst = hInstance;       // save for use by window procs
  132.  
  133.     baseunit = GetDialogBaseUnits() ;
  134.     baselo = LOWORD(baseunit) ;     // get x value for width
  135.     basehi = HIWORD(baseunit) ;     // get y value for height
  136.     width = ((262*baselo) / 4) ;
  137.     hght = ((184*basehi) /8) ;
  138.  
  139.     // Create applications main window.
  140.     hWnd = CreateWindow(
  141.                   "Dinfo:Main",            // window class name
  142.                   "Directory Information", // window title
  143.                   WS_CAPTION |
  144.                    WS_SYSMENU |
  145.                    WS_VISIBLE |
  146.                    WS_MINIMIZEBOX,
  147.                   CW_USEDEFAULT,
  148.                   0,
  149.                   width,                   // CW_USEDEFAULT,
  150.                   hght,                    // 0,
  151.                   NULL,                    // no parent for this window
  152.                   NULL,                    // use the class menu
  153.                   hInstance,               // who created this window
  154.                   NULL                     // no parms to pass on
  155.                   );
  156.  
  157.     hwndMainWin = hWnd ;
  158.  
  159.  
  160.     hAccel = LoadAccelerators(hInst, "WD_ACC") ;
  161.  
  162.     ShowWindow(hWnd, cmdShow) ;
  163.     UpdateWindow(hWnd) ;
  164.  
  165.     while(GetMessage(&msg, NULL, 0, 0))
  166.       {
  167.        if (!TranslateAccelerator(hMain, hAccel, &msg))
  168.          {
  169.           TranslateMessage(&msg) ;
  170.           DispatchMessage(&msg) ;
  171.           }
  172.        }
  173.     return 0 ;
  174.  
  175. }
  176.  
  177.  
  178. //*******************************************************************
  179.  
  180. //*******************************************************************
  181. // MainWndProc - handles messages for this application
  182. //
  183. // paramaters:
  184. //             hWnd          - The window handle for this message
  185. //             message       - The message number
  186. //             wParam        - The WORD parmater for this message
  187. //             lParam        - The LONG parmater for this message
  188. //
  189. // returns:
  190. //             depends on message.
  191. //
  192. //*******************************************************************
  193. long FAR PASCAL MainWndProc(HWND hwnd, WORD wMsg,
  194.                              WORD wParam, LONG lParam)
  195. {
  196.     HDC  hdc ;
  197.     HWND thWnd ;
  198.     TEXTMETRIC tm ;
  199.  
  200.     char drvchk ;
  201.     char drv[5] ;
  202.     int i, Xorig, Yorig, hght, width ;
  203.     static HANDLE lhInst ;
  204.  
  205.     HANDLE hCursor ;
  206.  
  207.     switch (wMsg)
  208.     {
  209.         case WM_CREATE:
  210.             hMain = hwnd ;
  211.  
  212.  
  213.             // Get the display context.
  214.             hdc = GetDC(hwnd);
  215.  
  216.             // Build fixed screen font. Needed to display columinar report.
  217.             cursfont.lfHeight         =  0 ;
  218.             cursfont.lfWidth          =  0 ;
  219.             cursfont.lfEscapement     =  0 ;
  220.             cursfont.lfOrientation    =  0 ;
  221.             cursfont.lfWeight         =  FW_NORMAL;
  222.             cursfont.lfItalic         =  FALSE;
  223.             cursfont.lfUnderline      =  FALSE;
  224.             cursfont.lfStrikeOut      =  FALSE;
  225.             cursfont.lfCharSet        =  OEM_CHARSET;
  226.             cursfont.lfOutPrecision   =  OUT_DEFAULT_PRECIS;
  227.             cursfont.lfClipPrecision  =  CLIP_DEFAULT_PRECIS;
  228.             cursfont.lfQuality        =  DEFAULT_QUALITY;
  229.             cursfont.lfPitchAndFamily =  FIXED_PITCH | FF_DONTCARE ;
  230.             strcpy(cursfont.lfFaceName, "Terminal");
  231.  
  232.             hnewsfont = CreateFontIndirect((LPLOGFONT) &cursfont);
  233.  
  234.             // Install the font in the current display context.
  235.             holdsfont = SelectObject(hdc, hnewsfont);
  236.  
  237.             // get text metrics for paint
  238.             GetTextMetrics(hdc, &tm);
  239.             xChar = tm.tmAveCharWidth;
  240.             yChar = tm.tmHeight + tm.tmExternalLeading;
  241.             yCharnl = tm.tmHeight;
  242.  
  243.             // Release the display context.
  244.             ReleaseDC(hwnd, hdc);
  245.  
  246.             lhInst = ((LPCREATESTRUCT) lParam) -> hInstance ;
  247.             lpMainDlgProc = MakeProcInstance(MainDlgProc, lhInst);
  248.  
  249.             Xorig = ((66*baselo) / 4) ;
  250.             Yorig = ((3*basehi) /8) ;
  251.             width = ((40*baselo) / 4) ;
  252.             hght =  ((12*basehi) /8) ;
  253.  
  254.             // Create Accept Button
  255.             thWnd = CreateWindow(
  256.                                 "BUTTON",         // window class name
  257.                                 "&Accept",         // window title
  258.                                  WS_VISIBLE    |
  259.                                   WS_CHILD     |
  260.                                   WS_TABSTOP   |
  261.                                   BS_DEFPUSHBUTTON,
  262.                                  Xorig,
  263.                                  Yorig,
  264.                                  width,
  265.                                  hght,
  266.                                  hwnd,            // parent for this window
  267.                                  102,            // id for this window
  268.                                  lhInst,          // who created this window
  269.                                  NULL             // no parms to pass on
  270.                                  );
  271.  
  272.             Xorig = ((111*baselo) / 4) ;
  273.             Yorig = ((3*basehi) /8) ;
  274.             width = ((40*baselo) / 4) ;
  275.             hght =  ((12*basehi) /8) ;
  276.  
  277.             // Create Clear Button
  278.             thWnd = CreateWindow(
  279.                                 "BUTTON",          // window class name
  280.                                 "&Clear",           // window title
  281.                                 WS_VISIBLE    |
  282.                                  WS_CHILD     |
  283.                                  WS_TABSTOP,
  284.                                 Xorig,
  285.                                 Yorig,
  286.                                 width,
  287.                                 hght,
  288.                                 hwnd,              // parent for this window
  289.                                 103,               // id of window
  290.                                 lhInst,            // who created this window
  291.                                 NULL                     // no parms to pass on
  292.                                 );
  293.  
  294.             Xorig = ((156*baselo) / 4) ;
  295.             Yorig = ((3*basehi) /8) ;
  296.             width = ((40*baselo) / 4) ;
  297.             hght =  ((12*basehi) /8) ;
  298.  
  299.             // Create Cancel Button
  300.             thWnd = CreateWindow(
  301.                                 "BUTTON",          // window class name
  302.                                 "E&Xit",          // window title
  303.                                 WS_VISIBLE    |
  304.                                  WS_CHILD     |
  305.                                  WS_TABSTOP,
  306.                                 Xorig,
  307.                                 Yorig,
  308.                                 width,
  309.                                 hght,
  310.                                 hwnd,              // parent for this window
  311.                                 104,               // id of window
  312.                                 lhInst,            // who created this window
  313.                                 NULL               // no parms to pass on
  314.                                 );
  315.  
  316.             Xorig = ((1*baselo) / 4) ;
  317.             Yorig = ((46*basehi) /8) ;
  318.             width = ((256*baselo) / 4) ;
  319.             hght =  ((113*basehi) /8) ;
  320.  
  321.             // Create Cancel Button
  322.             thWnd = CreateWindow(
  323.                                 "LISTBOX",         // window class name
  324.                                 NULL,              // window title
  325.                                 WS_VISIBLE    |
  326.                                  WS_CHILD     |
  327.                                  WS_VSCROLL   |
  328.                                  WS_HSCROLL   |
  329.                                  WS_BORDER,
  330.                                 Xorig,
  331.                                 Yorig,
  332.                                 width,
  333.                                 hght,
  334.                                 hwnd,              // parent for this window
  335.                                 101,               // id of window
  336.                                 lhInst,            // who created this window
  337.                                 NULL               // no parms to pass on
  338.                                 );
  339.             hList = thWnd ;
  340.  
  341.             Xorig = ((4*baselo) / 4) ;
  342.             Yorig = ((24*basehi) /8) ;
  343.             width = ((33*baselo) / 4) ;
  344.             hght =  ((11*basehi) /8) ;
  345.  
  346.             // Create Drv Button
  347.             thWnd = CreateWindow(
  348.                                 "STATIC",          // window class name
  349.                                 "Drives:",         // window title
  350.                                 WS_VISIBLE | WS_CHILD,
  351.                                 Xorig, Yorig,
  352.                                 width, hght,
  353.                                 hwnd,              // parent for this window
  354.                                 105,            // id of window
  355.                                 lhInst,            // who created this window
  356.                                 NULL               // no parms to pass on
  357.                                 );
  358.  
  359.             Xorig = ((32*baselo) / 4) ;
  360.             Yorig = ((22*basehi) /8) ;
  361.             width = ((18*baselo) / 4) ;
  362.             hght =  ((12*basehi) /8) ;
  363.  
  364.             // Create Drv Button
  365.             thWnd = CreateWindow(
  366.                                 "BUTTON",          // window class name
  367.                                 "  ",              // window title
  368.                                 WS_CHILD | WS_TABSTOP |
  369.                                  BS_AUTORADIOBUTTON,
  370.                                 Xorig, Yorig,
  371.                                 width, hght,
  372.                                 hwnd,              // parent for this window
  373.                                 W_Drv1,            // id of window
  374.                                 lhInst,            // who created this window
  375.                                 NULL               // no parms to pass on
  376.                                 );
  377.  
  378.             Xorig = ((56*baselo) / 4) ;
  379.             Yorig = ((22*basehi) /8) ;
  380.             width = ((18*baselo) / 4) ;
  381.             hght =  ((12*basehi) /8) ;
  382.  
  383.             // Create Button
  384.             thWnd = CreateWindow(
  385.                                 "BUTTON",          // window class name
  386.                                 "  ",              // window title
  387.                                 WS_CHILD | WS_TABSTOP |
  388.                                  BS_AUTORADIOBUTTON,
  389.                                 Xorig, Yorig,
  390.                                 width, hght,
  391.                                 hwnd,              // parent for this window
  392.                                 107,            // id of window
  393.                                 lhInst,            // who created this window
  394.                                 NULL               // no parms to pass on
  395.                                 );
  396.  
  397.             Xorig = ((80*baselo) / 4) ;
  398.             Yorig = ((22*basehi) /8) ;
  399.             width = ((18*baselo) / 4) ;
  400.             hght =  ((12*basehi) /8) ;
  401.  
  402.             // Create Button
  403.             thWnd = CreateWindow(
  404.                                 "BUTTON",          // window class name
  405.                                 "  ",              // window title
  406.                                 WS_CHILD | WS_TABSTOP |
  407.                                  BS_AUTORADIOBUTTON,
  408.                                 Xorig, Yorig,
  409.                                 width, hght,
  410.                                 hwnd,              // parent for this window
  411.                                 108,               // id of window
  412.                                 lhInst,            // who created this window
  413.                                 NULL               // no parms to pass on
  414.                                 );
  415.  
  416.             Xorig = ((104*baselo) / 4) ;
  417.             Yorig = ((22*basehi) /8) ;
  418.             width = ((18*baselo) / 4) ;
  419.             hght =  ((12*basehi) /8) ;
  420.  
  421.             // Create Button
  422.             thWnd = CreateWindow(
  423.                                 "BUTTON",          // window class name
  424.                                 "  ",              // window title
  425.                                 WS_CHILD | WS_TABSTOP |
  426.                                  BS_AUTORADIOBUTTON,
  427.                                 Xorig, Yorig,
  428.                                 width, hght,
  429.                                 hwnd,              // parent for this window
  430.                                 109,               // id of window
  431.                                 lhInst,            // who created this window
  432.                                 NULL               // no parms to pass on
  433.                                 );
  434.  
  435.             Xorig = ((128*baselo) / 4) ;
  436.             Yorig = ((22*basehi) /8) ;
  437.             width = ((18*baselo) / 4) ;
  438.             hght =  ((12*basehi) /8) ;
  439.  
  440.             // Create Button
  441.             thWnd = CreateWindow(
  442.                                 "BUTTON",          // window class name
  443.                                 "  ",              // window title
  444.                                 WS_CHILD | WS_TABSTOP |
  445.                                  BS_AUTORADIOBUTTON,
  446.                                 Xorig, Yorig,
  447.                                 width, hght,
  448.                                 hwnd,              // parent for this window
  449.                                 110,               // id of window
  450.                                 lhInst,            // who created this window
  451.                                 NULL               // no parms to pass on
  452.                                 );
  453.  
  454.             Xorig = ((152*baselo) / 4) ;
  455.             Yorig = ((22*basehi) /8) ;
  456.             width = ((18*baselo) / 4) ;
  457.             hght =  ((12*basehi) /8) ;
  458.  
  459.             // Create Button
  460.             thWnd = CreateWindow(
  461.                                 "BUTTON",          // window class name
  462.                                 "  ",              // window title
  463.                                 WS_CHILD | WS_TABSTOP |
  464.                                  BS_AUTORADIOBUTTON,
  465.                                 Xorig, Yorig,
  466.                                 width, hght,
  467.                                 hwnd,              // parent for this window
  468.                                 111,               // id of window
  469.                                 lhInst,            // who created this window
  470.                                 NULL               // no parms to pass on
  471.                                 );
  472.  
  473.             Xorig = ((176*baselo) / 4) ;
  474.             Yorig = ((22*basehi) /8) ;
  475.             width = ((18*baselo) / 4) ;
  476.             hght =  ((12*basehi) /8) ;
  477.  
  478.             // Create Button
  479.             thWnd = CreateWindow(
  480.                                 "BUTTON",          // window class name
  481.                                 "  ",              // window title
  482.                                 WS_CHILD | WS_TABSTOP |
  483.                                  BS_AUTORADIOBUTTON,
  484.                                 Xorig, Yorig,
  485.                                 width, hght,
  486.                                 hwnd,              // parent for this window
  487.                                 112,               // id of window
  488.                                 lhInst,            // who created this window
  489.                                 NULL               // no parms to pass on
  490.                                 );
  491.  
  492.             Xorig = ((200*baselo) / 4) ;
  493.             Yorig = ((22*basehi) /8) ;
  494.             width = ((18*baselo) / 4) ;
  495.             hght =  ((12*basehi) /8) ;
  496.  
  497.             // Create Button
  498.             thWnd = CreateWindow(
  499.                                 "BUTTON",          // window class name
  500.                                 "  ",              // window title
  501.                                 WS_CHILD | WS_TABSTOP |
  502.                                  BS_AUTORADIOBUTTON,
  503.                                 Xorig, Yorig,
  504.                                 width, hght,
  505.                                 hwnd,              // parent for this window
  506.                                 113,               // id of window
  507.                                 lhInst,            // who created this window
  508.                                 NULL               // no parms to pass on
  509.                                 );
  510.  
  511.             Xorig = ((224*baselo) / 4) ;
  512.             Yorig = ((22*basehi) /8) ;
  513.             width = ((18*baselo) / 4) ;
  514.             hght =  ((12*basehi) /8) ;
  515.  
  516.             // Create Button
  517.             thWnd = CreateWindow(
  518.                                 "BUTTON",          // window class name
  519.                                 "  ",              // window title
  520.                                 WS_CHILD | WS_TABSTOP |
  521.                                  BS_AUTORADIOBUTTON,
  522.                                 Xorig, Yorig,
  523.                                 width, hght,
  524.                                 hwnd,              // parent for this window
  525.                                 114,               // id of window
  526.                                 lhInst,            // who created this window
  527.                                 NULL               // no parms to pass on
  528.                                 );
  529.  
  530.             Xorig = ((63*baselo) / 4) ;
  531.             Yorig = ((34*basehi) /8) ;
  532.             width = ((104*baselo) / 4) ;
  533.             hght =  ((9*basehi) /8) ;
  534.  
  535.             // Create Cancel Button
  536.             thWnd = CreateWindow(
  537.                                 "STATIC",          // window class name
  538.                                 "Directories Processed:",  // window title
  539.                                 WS_VISIBLE | WS_CHILD,
  540.                                 Xorig, Yorig,
  541.                                 width, hght,
  542.                                 hwnd,              // parent for this window
  543.                                 115,               // id of window
  544.                                 lhInst,            // who created this window
  545.                                 NULL               // no parms to pass on
  546.                                 );
  547.  
  548.             Xorig = ((148*baselo) / 4) ;
  549.             Yorig = ((34*basehi) /8) ;
  550.             width = ((27*baselo) / 4) ;
  551.             hght =  ((9*basehi) /8) ;
  552.  
  553.             // Create Button
  554.             thWnd = CreateWindow(
  555.                                 "STATIC",          // window class name
  556.                                 "",                // window title
  557.                                 WS_VISIBLE | WS_CHILD,
  558.                                 Xorig, Yorig,
  559.                                 width, hght,
  560.                                 hwnd,              // parent for this window
  561.                                 116,               // id of window
  562.                                 lhInst,            // who created this window
  563.                                 NULL               // no parms to pass on
  564.                                 );
  565.  
  566. //        hList = GetDlgItem(hwnd, W_List) ;  // get handle of list window
  567.  
  568.             SendMessage(hList, WM_SETFONT,
  569.                         hnewsfont, FALSE);
  570.  
  571.             driveln = logic(DriveId) ;
  572.             if (DriveId[0] != 0x00)
  573.               {
  574.                drv[2] = 0x00 ;
  575.  
  576.                if (driveln > 9)
  577.                  {
  578.                   driveln = 9 ;
  579.                   DriveId[9] = 0x00 ;
  580.                   }
  581.                DriveSel = DriveId[0] ; // set default drive id to first
  582.                for (i=0; i<driveln; i++)
  583.                  {
  584.                   sprintf(drv, "%c:", DriveId[i]) ;
  585.  
  586.                   thWnd = GetDlgItem(hwnd, W_Drv1 + i) ;
  587.                   EnableWindow(thWnd, TRUE) ;
  588.                   ShowWindow(thWnd, SW_SHOWNORMAL) ;
  589.  
  590.                   SetDlgItemText(hwnd, W_Drv1 + i, drv) ;
  591.                   if (DriveId[i] == 'C')
  592.                     {
  593.                      DriveSel = DriveId[i] ;  // set default drive to C
  594.                      CheckRadioButton(hwnd, W_Drv1, W_Drv9, W_Drv1 + i) ;
  595.                      }
  596.                   }
  597.                }
  598.               else
  599.                 {
  600.                  MessageBox(NULL,"No Drives Found",NULL,MB_OK) ;
  601.                  }
  602.  
  603.             break ;
  604.  
  605.  
  606.         case WM_CLOSE:
  607.             // Tell windows to destroy our window.
  608.             DestroyWindow(hwnd);
  609.             break;
  610.  
  611.         case WM_QUERYENDSESSION:
  612.             // If we return TRUE we are saying it's ok with us to end the
  613.             // windows session.
  614.             return((long) TRUE);  // we agree to end session.
  615.  
  616.         case WM_DESTROY:
  617.             // This is the end if we were closed by a DestroyWindow call.
  618.             PostQuitMessage(0);
  619.             break;
  620.  
  621.         case WM_COMMAND:
  622.             switch(wParam)
  623.             {
  624.              case W_Accept:
  625.                  W_ItemCnt = 0 ;
  626.                  Num_Dir = 0 ;
  627.                  SetDlgItemInt(hwnd, W_Dirs, Num_Dir, FALSE) ;
  628.  
  629.                  SendMessage(hList, LB_RESETCONTENT, 0, 0L) ;
  630.                  UpdateWindow(hList) ;
  631.                  InvalidateRect(hList, NULL, TRUE) ;
  632.  
  633.                  SendMessage(hList,WM_SETREDRAW, FALSE, 0L) ;
  634.                  InvalidateRect(hList, NULL, TRUE) ;
  635.                  UpdateWindow(hList) ;
  636.  
  637. //                 hCursor = LoadCursor(NULL, IDC_WAIT) ;
  638.                  hCursor = LoadCursor(lhInst, "CLOCK") ;
  639.                  SetCursor(hCursor) ;
  640.  
  641.                  DinfoMain() ;
  642.  
  643.                  hCursor = LoadCursor(NULL, IDC_ARROW) ;
  644.                  SetCursor(hCursor) ;
  645.  
  646.                  SendMessage(hList,WM_SETREDRAW, TRUE, 0L) ;
  647.                  InvalidateRect(hList, NULL, TRUE) ;
  648.                  UpdateWindow(hList) ;
  649.  
  650.                  return TRUE ;
  651.  
  652.              case W_Clear:
  653.                  W_ItemCnt = 0 ;
  654.                  Num_Dir = 0 ;
  655.                  SetDlgItemInt(hwnd, W_Dirs, Num_Dir, FALSE) ;
  656.                  SendMessage(hList, LB_RESETCONTENT, 0, 0L) ;
  657.                  InvalidateRect(hList, NULL, TRUE) ;
  658.                  UpdateWindow(hList) ;
  659.                  return TRUE ;
  660.  
  661.  
  662.              case W_Cancel:
  663.                  SendMessage(hwndMainWin, WM_CLOSE, 0, 0l) ;
  664.                  break ;
  665.  
  666.              case W_Drv1:
  667.              case W_Drv2:
  668.              case W_Drv3:
  669.              case W_Drv4:
  670.              case W_Drv5:
  671.              case W_Drv6:
  672.              case W_Drv7:
  673.              case W_Drv8:
  674.              case W_Drv9:
  675.                  i = wParam - W_Drv1 ;  // derive drive index
  676.                  DriveSel = DriveId[i] ;  // derive drive id
  677.                  CheckRadioButton(hwnd, W_Drv1, W_Drv9, wParam) ;
  678.                  break ;
  679.  
  680.              case W_DrvA:
  681.                  drvchk = 'A' ;
  682.                  CheckButton(drvchk) ;
  683.                  break ;
  684.              case W_DrvB:
  685.                  drvchk = 'B' ;
  686.                  CheckButton(drvchk) ;
  687.                  break ;
  688.              case W_DrvC:
  689.                  drvchk = 'C' ;
  690.                  CheckButton(drvchk) ;
  691.                  break ;
  692.              case W_DrvD:
  693.                  drvchk = 'D' ;
  694.                  CheckButton(drvchk) ;
  695.                  break ;
  696.              case W_DrvE:
  697.                  drvchk = 'E' ;
  698.                  CheckButton(drvchk) ;
  699.                  break ;
  700.              case W_DrvF:
  701.                  drvchk = 'F' ;
  702.                  CheckButton(drvchk) ;
  703.                  break ;
  704.              case W_DrvG:
  705.                  drvchk = 'G' ;
  706.                  CheckButton(drvchk) ;
  707.                  break ;
  708.              case W_DrvH:
  709.                  drvchk = 'H' ;
  710.                  CheckButton(drvchk) ;
  711.                  break ;
  712.              case W_DrvI:
  713.                  drvchk = 'I' ;
  714.                  CheckButton(drvchk) ;
  715.                  break ;
  716.              case W_DrvJ:
  717.                  drvchk = 'J' ;
  718.                  CheckButton(drvchk) ;
  719.                  break ;
  720.              case W_DrvK:
  721.                  drvchk = 'K' ;
  722.                  CheckButton(drvchk) ;
  723.                  break ;
  724.              case W_DrvL:
  725.                  drvchk = 'L' ;
  726.                  CheckButton(drvchk) ;
  727.                  break ;
  728.              case W_DrvM:
  729.                  drvchk = 'M' ;
  730.                  CheckButton(drvchk) ;
  731.                  break ;
  732.              case W_DrvN:
  733.                  drvchk = 'N' ;
  734.                  CheckButton(drvchk) ;
  735.                  break ;
  736.              case W_DrvO:
  737.                  drvchk = 'O' ;
  738.                  CheckButton(drvchk) ;
  739.                  break ;
  740.              case W_DrvP:
  741.                  drvchk = 'P' ;
  742.                  CheckButton(drvchk) ;
  743.                  break ;
  744.              case W_DrvQ:
  745.                  drvchk = 'Q' ;
  746.                  CheckButton(drvchk) ;
  747.                  break ;
  748.              case W_DrvR:
  749.                  drvchk = 'R' ;
  750.                  CheckButton(drvchk) ;
  751.                  break ;
  752.              case W_DrvS:
  753.                  drvchk = 'S' ;
  754.                  CheckButton(drvchk) ;
  755.                  break ;
  756.              case W_DrvT:
  757.                  drvchk = 'T' ;
  758.                  CheckButton(drvchk) ;
  759.                  break ;
  760.              case W_DrvU:
  761.                  drvchk = 'U' ;
  762.                  CheckButton(drvchk) ;
  763.                  break ;
  764.              case W_DrvV:
  765.                  drvchk = 'V' ;
  766.                  CheckButton(drvchk) ;
  767.                  break ;
  768.              case W_DrvW:
  769.                  drvchk = 'W' ;
  770.                  CheckButton(drvchk) ;
  771.                  break ;
  772.              case W_DrvX:
  773.                  drvchk = 'X' ;
  774.                  CheckButton(drvchk) ;
  775.                  break ;
  776.              case W_DrvY:
  777.                  drvchk = 'Y' ;
  778.                  CheckButton(drvchk) ;
  779.                  break ;
  780.              case W_DrvZ:
  781.                  drvchk = 'Z' ;
  782.                  CheckButton(drvchk) ;
  783.                  break ;
  784.  
  785.              case W_About:
  786.                  DialogBox(lhInst, "About_Box", hwnd, lpMainDlgProc) ;
  787.                  SetFocus(hAbout) ;
  788.                  break ;
  789.              }
  790.  
  791.  
  792.         default:
  793.             return(DefWindowProc(hwnd, wMsg, wParam, lParam));
  794.     }
  795.  
  796.     return(0L);
  797. }
  798.  
  799. //*******************************************************************
  800.  
  801. //*******************************************************************
  802. // MainDlgProc - handle Main dialog messages (modeless)
  803. //
  804. // This is a modeless dialog box procedure that controls this
  805. // entire application.
  806. //
  807. // paramaters:
  808. //             hDlg          - The window handle for this message
  809. //             message       - The message number
  810. //             wParam        - The WORD parmater for this message
  811. //             lParam        - The LONG parmater for this message
  812. //
  813. //*******************************************************************
  814. BOOL FAR PASCAL MainDlgProc(HWND hDlg, WORD wMsg,
  815.                                WORD wParam, LONG lParam)
  816. {
  817.  
  818.     int  i, x, y, w, h ;
  819.     char drv[5] ;
  820.  
  821.  
  822.  
  823.     static RECT   wrect;
  824.  
  825.  
  826.     switch (wMsg)
  827.     {
  828.         case WM_INITDIALOG:
  829.             hAbout = hDlg ;
  830.             break ;
  831.  
  832.         case WM_MOVE:
  833.             // Always keep this dialog box on top of main window.
  834.             GetWindowRect(hwndMainWin, (LPRECT) &wrect);
  835.             x = wrect.left;
  836.             y = wrect.top;
  837.             w = wrect.right - wrect.left;
  838.             h = wrect.bottom - wrect.top;
  839.             MoveWindow(hDlg, x, y, w, h, 1);
  840.             break;
  841.  
  842.         case WM_COMMAND:
  843.             switch(wParam)
  844.             {
  845.              case W_OK:                     // close out about box
  846.                  EndDialog(hDlg, 0) ;
  847.                  break ;
  848.              }
  849.  
  850.         case WM_KEYDOWN:
  851.             if (wParam == VK_RETURN)
  852.               EndDialog(hDlg, 0) ;
  853.             break ;
  854.  
  855.  
  856. //        case WM_SYSCOMMAND:
  857.            // send message out to window
  858. //            SendMessage(hwndMainWin, wMsg, wParam, lParam) ;
  859. //            break ;
  860.  
  861.  
  862.         default:
  863.             return FALSE;
  864.     }
  865.  
  866.     return(TRUE);
  867. }
  868.  
  869. //*******************************************************************
  870.  
  871. void CheckButton(char drv)
  872. {
  873.   int i ;
  874.     for (i=0; i<driveln; i++)
  875.        if (DriveId[i] == drv)
  876.          {
  877.           DriveSel = DriveId[i] ;  // set default drive to new drive
  878.           CheckRadioButton(hMain, W_Drv1, W_Drv9, W_Drv1 + i) ;
  879.           }
  880.  }
  881.  
  882.  
  883.  
  884. int logic(char *buf)
  885. {
  886.   /*********************************************************
  887.    *           VARIABLE DEFENITION                         *
  888.    *********************************************************/
  889.  
  890.   char xchar;
  891.   int save_current,i=0;
  892.  
  893.   /*********************************************************
  894.    *           STUCTURE DEFENITION FOR REGISTERS           *
  895.    *********************************************************/
  896.  
  897.   union REGS reg;
  898.   struct SREGS sregs;
  899.  
  900.  
  901.   /* Start of logic function */
  902.  
  903.   reg.h.ah = 0x19;                           /* DOS INT21 Function 0x19     */
  904.   int86(0X21,®,®);                     /* Getting default drive       */
  905.   save_current = reg.h.al;                   /* Save default drive          */
  906.  
  907.   for (xchar = 'A'; xchar <= 'Z'; xchar++){  /* For loop to locate valid    */
  908.      reg.h.ah = 0x0E;                        /* logic parations using DOS   */
  909.      reg.h.dl = xchar - 'A';                 /* INT21 function 0x0E & 0x19  */
  910.      int86(0X21,®,®);
  911.      reg.h.ah = 0X19;
  912.  
  913. //     intdosx(®,®,&sregs);
  914.      int86(0x21,®,®) ;
  915.  
  916.      if(reg.h.al == reg.h.dl)              /* If register AL is the same as */
  917.        buf[i++]=reg.h.al+'A';              /* requested drive, then logic   */
  918.     } /* For loop end */                   /* drive exist, hence assign     */
  919.                 /* drive letter to buffer */
  920.  
  921.    buf[i]='\0';                            /* Termeniate buffer with nul  */
  922.    reg.h.ah = 0x0E;                        /* Restore original default    */
  923.    reg.h.dl = save_current;                /* drive                       */
  924.    int86(0x21,®,®);
  925.    return i;                               /* Return length of buf        */
  926.  
  927.  }  /* End of function logic */
  928.  
  929. /*********************************************************************/
  930. /***********                                                **********/
  931. /*********************************************************************/
  932.  
  933. /***************************************************************/
  934. /*                                                             */
  935. /*             written by: George Hulse  11/90                 */
  936. /*                                                             */
  937. /***************************************************************/
  938. /*             compile with the COMPACT option                 */
  939. /***************************************************************/
  940.  
  941. struct ffblk finfo;
  942. #define dattr FA_DIREC ;
  943. #define fattr FA_RDONLY|FA_HIDDEN|FA_SYSTEM|FA_ARCH ;
  944.  
  945. typedef struct direntry {
  946.                            char  name[13] ;
  947.                            long  size ;
  948.                            long  subsize ;
  949.                            int   nest ;
  950.                            GLOBALHANDLE subdirh ;
  951.                            DWORD FAR subdir ;
  952.                            GLOBALHANDLE parenth ;
  953.                            DWORD FAR parent ;
  954.                           } ;
  955. typedef struct ptrelist {
  956.                            GLOBALHANDLE ptrenth[100] ;
  957.                            DWORD far ptrent[100] ;
  958.                           } ;
  959.  
  960.  
  961. void ParseSubs (struct direntry FAR *, GLOBALHANDLE) ;
  962. void DrawTree (struct direntry FAR *, GLOBALHANDLE, int) ;
  963. //void ParseSubs (struct direntry far *) ;
  964. //void DrawTree (struct direntry far *, int) ;
  965. void PlaceStr (char *, char *, int ) ;
  966. void Nbrfmt(char *) ;
  967. void Dir_Proc(void) ;
  968.  
  969.  
  970. static long tot ;
  971. static float pct, subpct, size, memalc ;
  972. static char prtline[80] ;
  973. static char workprt[30] ;
  974. static int nestbar[100], busychr ;
  975.  
  976. static char Tree[3] ;
  977.  
  978. char bar[2], ltbar[2], hbar[2], lcorn[2], lucorn[2] ;
  979.  
  980. struct direntry  FAR *rootptr ;
  981. GLOBALHANDLE roothndl ;
  982.  
  983. GLOBALHANDLE hGlobalMem ;
  984.  
  985.  
  986. void DinfoMain ()
  987. {     /*  start main code */
  988.    int ptrindx, drive, maxdrv ;
  989.    long d_avail, d_cap ;
  990.  
  991.    time_t t ;
  992.    struct dfree free ;
  993.    struct direntry far *parent ;
  994.    struct ptrelist far *subdir ;
  995.  
  996.    GLOBALHANDLE parenth ;
  997.  
  998. //   char dirname[101] ;
  999. //   char RESET[] = { 0x1b, 0x45, 0x00 } ;
  1000. //   char PC_8[]  = { 0x1b, 0x28, 0x31, 0x30, 0x55, 0x00 } ;
  1001. //   char FFeed[]  = { 0x0c, 0x00 } ;
  1002.  
  1003.    int i, j; //, HPLJ ;
  1004.  
  1005. //   HPLJ = 0 ;
  1006.    bar[0] = 0xb3 ;
  1007.    bar[1] = 0x00 ;
  1008.  
  1009.    ltbar[0] = 0xc3 ;
  1010.    ltbar[1] = 0x00 ;
  1011.  
  1012.    hbar[0] = 0xc4 ;
  1013.    hbar[1] = 0x00 ;
  1014.  
  1015.    lcorn[0] = 0xc0 ;
  1016.    lcorn[1] = 0x00 ;
  1017.  
  1018.    lucorn[0] = 0xda ;
  1019.    lucorn[1] = 0x00 ;
  1020.  
  1021.    busychr = 1 ;
  1022.  
  1023.    for (i = 0; i < 79; i++)
  1024.        prtline[i] = ' ' ;
  1025.    prtline[79] = 0x00 ;
  1026.  
  1027. /*********/
  1028.    Tree[0] = DriveSel ;
  1029.    Tree[1] = ':' ;
  1030.    Tree[2] = 0x00 ;
  1031. /*********/
  1032.  
  1033. //   if ( (rootptr = farmalloc(sizeof(struct direntry)) ) == NULL )
  1034.  
  1035.    hGlobalMem = GlobalAlloc(GMEM_MOVEABLE, sizeof(struct direntry)) ;
  1036.    roothndl = hGlobalMem ;
  1037.    if (hGlobalMem == NULL)
  1038.      {
  1039.        MessageBox(NULL,"Insufficient memory available for processing",
  1040.                  NULL,MB_OK) ;
  1041.        exit(1) ;
  1042.       }
  1043.    memalc = 0 ;
  1044.    memalc = memalc + sizeof(struct direntry) ;
  1045.  
  1046.    (DWORD FAR *) rootptr = (DWORD FAR *) GlobalLock(hGlobalMem) ;
  1047.  
  1048.    rootptr->name[0] = 0x00 ;
  1049.    rootptr->size = 0 ;
  1050.    rootptr->subsize = 0 ;
  1051.    rootptr->nest = 0 ;
  1052.    rootptr->subdir = NULL ;
  1053.    rootptr->subdirh = NULL ;
  1054.    rootptr->parent = NULL ;
  1055.    rootptr->parenth = NULL ;
  1056.  
  1057.  
  1058.    tot = 0 ;
  1059.  
  1060.    ParseSubs(rootptr,roothndl) ; /* start processing subdirs, including root*/
  1061.  
  1062.    busychr = 9 ;
  1063.  
  1064.  
  1065.    PlaceStr(prtline,"Bytes used on    disk: ",1) ;
  1066.    prtline[15] = DriveSel ;
  1067.    prtline[16] = ':' ;
  1068.    ltoa(tot,workprt,10) ;
  1069.    Nbrfmt(workprt) ;
  1070.    PlaceStr(prtline,workprt,24) ;
  1071.    t = time(NULL) ;
  1072.    strcpy(workprt,ctime(&t)) ;
  1073.    workprt[24] = 0x00 ;
  1074.    PlaceStr(prtline,workprt,40) ;
  1075. //   fprintf(fptr, "%s\n",prtline) ;
  1076.  
  1077.    MsgListAdd() ;
  1078.  
  1079.    MsgListAdd() ;
  1080.  
  1081.    getdfree((DriveSel-'A')+1, &free) ;
  1082.    if (free.df_sclus != 0xFFFF)
  1083.     {
  1084.        PlaceStr(prtline,"Bytes free on disk:    ",1) ;
  1085.        d_avail = (long) free.df_avail * (long) free.df_bsec *
  1086.                 (long) free.df_sclus ;
  1087.        ltoa(d_avail,workprt,10) ;
  1088.          Nbrfmt(workprt) ;
  1089.        PlaceStr(prtline,workprt,24) ;
  1090.  
  1091.    //    fprintf(fptr, "%s\n",prtline) ;
  1092.  
  1093.        MsgListAdd() ;
  1094.  
  1095.        PlaceStr(prtline,"Disk capacity (bytes): ",1) ;
  1096.        d_cap = (long) free.df_total * (long) free.df_bsec *
  1097.                 (long) free.df_sclus ;
  1098.        ltoa(d_cap,workprt,10) ;
  1099.          Nbrfmt(workprt) ;
  1100.        PlaceStr(prtline,workprt,24) ;
  1101.  
  1102.    //    fprintf(fptr, "%s\n",prtline) ;
  1103.  
  1104.        MsgListAdd() ;
  1105.       }
  1106.  
  1107. //   fprintf(fptr, "%s\n",prtline) ;
  1108.  
  1109.    MsgListAdd() ;
  1110.  
  1111.    strcpy(rootptr->name, "(root)" );
  1112.    size = rootptr->size ;
  1113.    pct = size / tot ;  /* get sub-dirs percentage of total */
  1114.    pct = pct* 100 ;    /* make percentage real */
  1115.    ltoa(rootptr->size,workprt,10) ;
  1116.    Nbrfmt(workprt) ;
  1117.    j = 2 ;
  1118.    PlaceStr(prtline,lucorn,j) ;
  1119.    PlaceStr(prtline,hbar,j+1) ;
  1120.    PlaceStr(prtline,rootptr->name,j+2) ;
  1121.    PlaceStr(prtline,workprt,j+12) ;
  1122.    sprintf(workprt,"%3.2f %%",pct) ;
  1123.    PlaceStr(prtline,workprt,j+29) ;
  1124.  
  1125. //   fprintf(fptr, "%s\n",prtline) ;
  1126.  
  1127.    MsgListAdd() ;
  1128.  
  1129.  
  1130.    ptrindx = 0 ;
  1131.    if (rootptr->subdir != NULL)
  1132.     {
  1133.       (DWORD FAR *)subdir = (DWORD FAR *) rootptr->subdir ;
  1134.       while (subdir->ptrent[ptrindx] != NULL)
  1135.        {
  1136.           (DWORD FAR *) parent = (DWORD FAR *) subdir->ptrent[ptrindx] ;
  1137.           parenth = subdir->ptrenth[ptrindx] ;
  1138.           if (subdir->ptrent[ptrindx+1] != NULL)
  1139.             {
  1140.              nestbar[0] = 1 ;
  1141.              DrawTree(parent,parenth,0) ;
  1142.              }
  1143.             else
  1144.             {
  1145.              nestbar[0] = 0 ;
  1146.              DrawTree(parent,parenth,1) ;
  1147.              }
  1148.           ptrindx = ptrindx + 1 ;
  1149.        }
  1150.     }
  1151.  
  1152. //   fprintf(fptr, "\n") ;
  1153. //   fprintf(fptr, "  (C) Copyright George Hulse, 1991\n") ;
  1154.  
  1155. //   farfree(rootptr) ;
  1156.    GlobalUnlock(roothndl) ;
  1157.    GlobalFree(roothndl) ;
  1158.  
  1159.    memalc = memalc / 1024 ;
  1160. //   printf("\n") ;
  1161. //   printf("%5.2f k bytes used for directory tree",memalc) ;
  1162.  
  1163. }     /*  end main code */
  1164.  
  1165. void ParseSubs(struct direntry FAR *parentd, GLOBALHANDLE parenth)
  1166. {
  1167.    struct direntry FAR *dirptr ;
  1168.    struct ptrelist FAR *subdir ;
  1169.    struct direntry FAR *parent ;
  1170.  
  1171.    GLOBALHANDLE parenth2 ;
  1172.    GLOBALHANDLE dirptrh ;
  1173.  
  1174.    char dirname[100], dirhold[100] ;
  1175.    int done, attr, i, j, ptrindx, attr2 ;
  1176.  
  1177.    Dir_Proc() ;
  1178.  
  1179. //  if ( (parentd->subdir = farmalloc(sizeof(struct ptrelist)) ) == NULL )
  1180.  
  1181.    hGlobalMem = GlobalAlloc(GMEM_MOVEABLE, sizeof(struct ptrelist)) ;
  1182.    parentd->subdirh = hGlobalMem ;
  1183.    if (hGlobalMem == NULL)
  1184.      {
  1185.        MessageBox(NULL,"Insufficient memory available for processing",
  1186.                  NULL,MB_OK) ;
  1187. //       exit(1) ;
  1188.       }
  1189.  
  1190.    (DWORD FAR *) parentd->subdir = (DWORD FAR *) GlobalLock(hGlobalMem) ;
  1191.  
  1192.    memalc = memalc + sizeof(struct ptrelist) ;
  1193.    dirname[0] = 0x00 ;
  1194.    dirhold[0] = 0x00 ;
  1195.  
  1196.    strcpy(dirname,parentd->name) ;
  1197.    (DWORD FAR *) parent = (DWORD FAR *) parentd->parent ;
  1198.  
  1199.  
  1200.    while (parent != NULL)
  1201.     {
  1202.       strcpy(dirhold,parent->name) ;
  1203.       if (parent->name[0] != 0x00)
  1204.         strcat(dirhold,"\\") ;
  1205.       strcat(dirhold,dirname) ;
  1206.       strcpy(dirname,dirhold) ;
  1207.       dirhold[0] = 0x00 ;
  1208.       (DWORD FAR *) dirptr = (DWORD FAR *) parent->parent ;
  1209.       parent = dirptr ;
  1210.      }
  1211.  
  1212.    strcpy(dirhold,Tree) ;
  1213.    strcat(dirhold,"\\") ;
  1214.    strcat(dirhold,dirname) ;
  1215.    if (strlen(dirhold) > 3)
  1216.      strcat(dirhold,"\\") ;
  1217.    strcat(dirhold,"*.*") ;
  1218.    strcpy(dirname,dirhold) ;
  1219.  
  1220.    ptrindx = 0 ;
  1221.    (DWORD FAR *) subdir = (DWORD FAR *) parentd->subdir ;
  1222.    subdir->ptrent[0] = NULL ;
  1223.    subdir->ptrenth[0] = NULL ;
  1224.    attr = dattr ;
  1225.  
  1226.    done = findfirst(dirname,&finfo,attr) ;
  1227.    while (!done)
  1228.     {
  1229.        if (finfo.ff_attrib == attr)
  1230.          {
  1231.           if (finfo.ff_name[0] != '.')
  1232.              {
  1233. //            if ( (dirptr = farmalloc(sizeof(struct direntry)) ) == NULL )
  1234.  
  1235.                hGlobalMem =
  1236.                      GlobalAlloc(GMEM_MOVEABLE, sizeof(struct direntry)) ;
  1237.                dirptrh = hGlobalMem ;
  1238.                if (hGlobalMem == NULL)
  1239.                  {
  1240.                    MessageBox(NULL,
  1241.                               "Insufficient memory available for processing",
  1242.                               NULL,MB_OK) ;
  1243. //                   exit(1) ;
  1244.                   }
  1245.                 else
  1246.                 {
  1247.                   (DWORD FAR *) dirptr = (DWORD FAR *) GlobalLock(hGlobalMem);
  1248.                   memalc = memalc + sizeof(struct direntry) ;
  1249.                   strcpy(dirptr->name,finfo.ff_name) ;
  1250.                   dirptr->size = 0 ;
  1251.                   dirptr->subsize = 0 ;
  1252.                   dirptr->nest = parentd->nest + 1 ;
  1253.                   (DWORD FAR *) dirptr->parent = (DWORD FAR *) parentd ;
  1254.                   dirptr->parenth = parenth ;
  1255.                   dirptr->subdir = NULL ;
  1256.                   dirptr->subdirh = NULL ;
  1257.  
  1258.                   subdir->ptrenth[ptrindx] = dirptrh ;
  1259.                   (DWORD FAR *) subdir->ptrent[ptrindx] =
  1260.                        (DWORD FAR *) dirptr ;
  1261.  
  1262.                   ptrindx = ptrindx + 1 ;
  1263.                   subdir->ptrent[ptrindx] = NULL ;
  1264.                   subdir->ptrenth[ptrindx] = NULL ;
  1265.                   }
  1266.             }
  1267.           }
  1268.        done = findnext(&finfo) ;
  1269.       }
  1270.    attr2 = fattr ;
  1271.    done = findfirst(dirname,&finfo,attr2) ;
  1272.    while (!done)
  1273.     {
  1274.        parentd->size = parentd->size + finfo.ff_fsize ;
  1275.        done = findnext(&finfo) ;
  1276.       }
  1277.  
  1278.    tot = tot + parentd->size ;
  1279.  
  1280.    ptrindx = 0 ;
  1281.    if (parentd->subdir != NULL)
  1282.     {
  1283.       (DWORD FAR *) subdir = (DWORD FAR *) parentd->subdir ;
  1284.       while (subdir->ptrent[ptrindx] != NULL)
  1285.        {
  1286.           (DWORD FAR *) parent = (DWORD FAR *) subdir->ptrent[ptrindx] ;
  1287.           parenth2 = subdir->ptrenth[ptrindx] ;
  1288.           ParseSubs(parent,parenth2) ;
  1289.           ptrindx = ptrindx + 1 ;
  1290.          }
  1291.    }
  1292.  
  1293.    (DWORD FAR *) parent = (DWORD FAR *) parentd->parent ;
  1294.    if (parent != NULL)
  1295.     parent->subsize = parent->subsize + parentd->size + parentd->subsize ;
  1296.  
  1297. }
  1298.  
  1299. void DrawTree(struct direntry FAR *parentd,
  1300.                GLOBALHANDLE parenth, int last)
  1301. {
  1302.    int i, j, ptrindx ;
  1303.  
  1304.    struct direntry FAR *parent ;
  1305.    struct ptrelist FAR *subdir ;
  1306.  
  1307.    GLOBALHANDLE parenth2 ;
  1308.    GLOBALHANDLE subdirh2 ;
  1309.  
  1310.    subpct = 0 ;
  1311.    size = parentd->size ;
  1312.    pct = size / tot ;  /* get sub-dirs percentage of total */
  1313.    pct = pct* 100 ;    /* make percentage real */
  1314.    if (parentd->subsize > 0)
  1315.       {
  1316.        size = size + parentd->subsize ;
  1317.        subpct = size / tot ; /* get sub-sub-dirs percentage of total */
  1318.        subpct = subpct* 100 ;  /* make percentage real */
  1319.        }
  1320.    ltoa(parentd->size,workprt,10) ;
  1321.    Nbrfmt(workprt) ;
  1322.  
  1323.    j = 2 ;     // starting position of bars
  1324.      for (i=1; i < parentd->nest ; i++)
  1325.     {
  1326.        if (nestbar[i] == 1)
  1327.        PlaceStr(prtline,bar,j) ;
  1328.        j = j + 2 ;
  1329.       }
  1330.    if (last == 0)
  1331.      {
  1332.       nestbar[parentd->nest] = 1 ;
  1333.     PlaceStr(prtline,ltbar,j) ;
  1334.      }
  1335.    else
  1336.      {
  1337.       nestbar[parentd->nest] = 0 ;
  1338.       PlaceStr(prtline,lcorn,j) ;
  1339.       }
  1340.    PlaceStr(prtline,hbar,j+1) ;
  1341.    PlaceStr(prtline,parentd->name,j+2) ;
  1342.    PlaceStr(prtline,workprt,j+12) ;
  1343.    sprintf(workprt,"%3.2f %%",pct) ;
  1344.    PlaceStr(prtline,workprt,j+27) ;    // was 29
  1345.    if (subpct > 0)
  1346.       {
  1347.        sprintf(workprt,"(%3.2f %%)",subpct) ;
  1348.        PlaceStr(prtline,workprt,j+37) ;   // was 39
  1349.        }
  1350.  
  1351. //   fprintf(fptr, "%s\n",prtline) ;
  1352.  
  1353.    MsgListAdd() ;
  1354.  
  1355.    ptrindx = 0 ;
  1356.    if (parentd->subdir != NULL)
  1357.      {
  1358.       (DWORD FAR *)subdir = (DWORD FAR *) parentd->subdir ;
  1359.       while (subdir->ptrent[ptrindx] != NULL)
  1360.         {
  1361.           (DWORD FAR *) parent = (DWORD FAR *) subdir->ptrent[ptrindx] ;
  1362.           parenth2 = subdir->ptrenth[ptrindx] ;
  1363.           if (subdir->ptrent[ptrindx+1] != NULL)
  1364.              DrawTree(parent,parenth,0) ;
  1365.             else
  1366.              DrawTree(parent,parenth2,1) ;
  1367.  
  1368.           hGlobalMem = parent->subdirh ;
  1369.           GlobalUnlock(hGlobalMem) ;
  1370.           GlobalFree(hGlobalMem) ;
  1371.           hGlobalMem = parenth2 ;
  1372.           GlobalUnlock(hGlobalMem) ;
  1373.           GlobalFree(hGlobalMem) ;
  1374.  
  1375. //          farfree(parent->subdir) ;
  1376. //          farfree(parent) ;
  1377.           ptrindx = ptrindx + 1 ;
  1378.          }
  1379.    }
  1380. }
  1381.  
  1382. void PlaceStr(char *dest, char *src, int ptr)
  1383. {
  1384.    int i, len ;
  1385.  
  1386.    i = 0 ;
  1387.    len = strlen(src) ;
  1388.    for (i = 0; i < len; i++)
  1389.     {
  1390.       dest[ptr] = src[i] ;
  1391.       ptr = ptr + 1 ;
  1392.       }
  1393. }
  1394.  
  1395. void Nbrfmt(char *src)
  1396. {
  1397.    int i, j, k, len ;
  1398.    char fmt[14] ;
  1399.  
  1400.    j = 13 ;
  1401.    for (i = 0; i <14; i++)
  1402.       fmt[i] = ' ' ;
  1403.    fmt[14] = 0x00 ;
  1404.    k = 0 ;
  1405.    len = strlen(src) ;
  1406.    for (i = len-1; i > -1; i--)
  1407.     {
  1408.       if (k == 3)
  1409.         {
  1410.          fmt[j] = ',' ;
  1411.          j = j - 1 ;
  1412.          k = 0 ;
  1413.          }
  1414.       fmt[j] = src[i] ;
  1415.       j = j - 1 ;
  1416.       k = k + 1 ;
  1417.       }
  1418.    for (i=0; i<14; i++)
  1419.       src[i] = fmt[i] ;
  1420.    src[14] = 0x00 ;
  1421. }
  1422.  
  1423. void MsgListAdd()
  1424. {
  1425.    int i ;
  1426.    long rc ;
  1427.  
  1428.    MSG msg ;
  1429.  
  1430.    for (i = 78; i > -1; i--)
  1431.      if (prtline[i] > ' ')
  1432.        {
  1433.         prtline[i+1] = 0x00 ;
  1434.         i = -1 ;
  1435.         }
  1436.  
  1437. //   rc = SendDlgItemMessage(hMain, W_List, LB_ADDSTRING, W_ItemCnt,
  1438. //                        (LONG) ((LPSTR) prtline)) ;
  1439.  
  1440.    rc = SendMessage(hList, LB_ADDSTRING, W_ItemCnt,
  1441.                         (LONG) ((LPSTR) prtline)) ;
  1442.  
  1443.    if (rc == LB_ERR || rc == LB_ERRSPACE)
  1444.      {
  1445.       MessageBox(NULL,"Insufficient memory available for processing",
  1446.                 "* ERROR *",MB_ICONEXCLAMATION | MB_OK) ;
  1447.       }
  1448.  
  1449.  
  1450.    W_ItemCnt++ ;
  1451.    for (i = 0; i < 79; i++)
  1452.       prtline[i] = ' ' ;
  1453.    prtline[79] = 0x00 ;
  1454.  
  1455.  
  1456. }
  1457.  
  1458. void Dir_Proc()
  1459. {
  1460.    Num_Dir++ ;
  1461.  
  1462.  
  1463.      SetDlgItemInt(hMain, W_Dirs, Num_Dir, FALSE) ;
  1464.  
  1465. }
  1466.