home *** CD-ROM | disk | FTP | other *** search
/ PC Open 19 / pcopen19.iso / Zipped / CALMIR21.ZIP / SOURCE.ZIP / SRC / DISKPROP.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1998-02-20  |  4.7 KB  |  154 lines

  1. {**************************************************************************}
  2. {                                                                          }
  3. {    Calmira shell for Microsoft« Windows(TM) 3.1                          }
  4. {    Source Release 2.1                                                    }
  5. {    Copyright (C) 1997-1998 Li-Hsin Huang                                 }
  6. {                                                                          }
  7. {    This program is free software; you can redistribute it and/or modify  }
  8. {    it under the terms of the GNU General Public License as published by  }
  9. {    the Free Software Foundation; either version 2 of the License, or     }
  10. {    (at your option) any later version.                                   }
  11. {                                                                          }
  12. {    This program is distributed in the hope that it will be useful,       }
  13. {    but WITHOUT ANY WARRANTY; without even the implied warranty of        }
  14. {    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         }
  15. {    GNU General Public License for more details.                          }
  16. {                                                                          }
  17. {    You should have received a copy of the GNU General Public License     }
  18. {    along with this program; if not, write to the Free Software           }
  19. {    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.             }
  20. {                                                                          }
  21. {**************************************************************************}
  22.  
  23. unit Diskprop;
  24.  
  25. interface
  26.  
  27. uses
  28.   Classes, SysUtils, Graphics, Controls, Forms, StdCtrls, Buttons, ExtCtrls, 
  29.   TabNotBk, BarGauge, LabelSel;
  30.  
  31. type
  32.   TDiskDialog = class(TForm)
  33.     OKBtn: TBitBtn;
  34.     Notebook: TTabbedNotebook;
  35.     Label10: TLabel;
  36.     DriveLetter: TLabel;
  37.     Label11: TLabel;
  38.     DriveType: TLabel;
  39.     Label12: TLabel;
  40.     DriveSize: TLabel;
  41.     Label13: TLabel;
  42.     DriveFree: TLabel;
  43.     Label14: TLabel;
  44.     DriveImage: TImage;
  45.     Label1: TLabel;
  46.     VolLabel: TLabel;
  47.     Bevel1: TBevel;
  48.     LabelSel: TLabelSelect;
  49.     Gauge: TWin95Gauge;
  50.     UsedLabel: TLabel;
  51.     procedure FormShow(Sender: TObject);
  52.     procedure DriveImageClick(Sender: TObject);
  53.     procedure FormCreate(Sender: TObject);
  54.     procedure DriveTypeMouseDown(Sender: TObject; Button: TMouseButton;
  55.       Shift: TShiftState; X, Y: Integer);
  56.   private
  57.     { Private declarations }
  58.   public
  59.     { Public declarations }
  60.   end;
  61.  
  62.  
  63. procedure DiskPropExecute(drive : Char);
  64.  
  65. implementation
  66.  
  67. {$R *.DFM}
  68.  
  69. uses Strings, Drives, Resource, FileCtrl, Settings,
  70.   Files, Environs, WinTypes, FileMan, MiscUtil;
  71.  
  72. {
  73. var
  74.   DiskDialog: TDiskDialog;
  75. }
  76.  
  77. procedure TDiskDialog.FormShow(Sender: TObject);
  78. var
  79.   dnum : Integer;
  80.   drive : Char;
  81.   dtype : TDriveType;
  82.   size, free : Longint;
  83.   vol : string;
  84. begin
  85.   drive := DriveLetter.Caption[1];
  86.   dnum := DriveNumber(drive);
  87.   dtype := GuessDriveType(drive);
  88.   DriveType.Caption := DriveDesc[dtype];
  89.   DriveImage.Picture.Icon := icons.Drive[dtype];
  90.  
  91.   ShowHourglass;
  92.   size := DiskSize(dnum);
  93.   if size <> -1 then free := DiskFree(dnum);
  94.  
  95.   if size <> -1 then begin
  96.     DriveSize.Caption := FormatByte(size, 2);
  97.     if size > 1024 then DriveSize.Hint := FormatByteLong(size);
  98.     DriveFree.Caption := FormatByte(free, 2);
  99.     if free > 1024 then DriveFree.Hint := FormatByteLong(free);
  100.  
  101.     if dtype = dtNetwork then vol := GetNetworkVolume(drive)
  102.     else vol := GetVolumeID(drive);
  103.     if vol > '' then VolLabel.Caption := vol;
  104.  
  105.     if size > 1024 then begin
  106.       size := size div 1024;
  107.       free := free div 1024;
  108.     end;
  109.  
  110.     Gauge.MaxValue := size;
  111.     Gauge.Progress := size - free;
  112.  
  113.     UsedLabel.Caption := Format('%d%%', [Gauge.GetPercentDone]);
  114.   end;
  115.  
  116.   with Gauge do begin
  117.     ForeColor := Colors[ccPercent];
  118.     BackColor := Colors[ccPercentBack];
  119.     {Font.Color := Colors[ccPercentText];}
  120.   end;
  121.   Environment.Values['CURRENTDRIVE'] := drive;
  122. end;
  123.  
  124. procedure TDiskDialog.DriveImageClick(Sender: TObject);
  125. begin
  126.   DefaultExec(DiskProg, '', '', SW_SHOW);
  127. end;
  128.  
  129. procedure DiskPropExecute(drive : Char);
  130. begin
  131.   ShowHourglass;
  132.   with TDiskDialog.Create(Application) do
  133.   try
  134.     DriveLetter.Caption := Upcase(drive);
  135.     ShowModal;
  136.   finally
  137.     Free;
  138.   end;
  139. end;
  140.  
  141. procedure TDiskDialog.FormCreate(Sender: TObject);
  142. begin
  143.   OKBtn.Cancel := True;
  144.   Notebook.PageIndex := 0;
  145. end;
  146.  
  147. procedure TDiskDialog.DriveTypeMouseDown(Sender: TObject;
  148.   Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
  149. begin
  150.   if Button = mbLeft then LabelSel.Overlay(Sender as TLabel);
  151. end;
  152.  
  153. end.
  154.