home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC & Mediji 1997 April
/
PCM_9704.iso
/
bralci
/
st
/
glavni1.~pa
< prev
next >
Wrap
Text File
|
1997-02-27
|
13KB
|
398 lines
unit glavni1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, FileCtrl, Menus, ExtCtrls, Buttons;
type
Tmain = class(TForm)
srcFileBox: TFileListBox;
srcDirBox: TDirectoryListBox;
srcDriveBox: TDriveComboBox;
brisi: TButton;
trgFileBox: TFileListBox;
trgDirBox: TDirectoryListBox;
trgDriveBox: TDriveComboBox;
menu: TMainMenu;
Izhod1: TMenuItem;
Oprogramu1: TMenuItem;
Panel1: TPanel;
Label1: TLabel;
Label2: TLabel;
Label4: TLabel;
Label3: TLabel;
mnuOstalo: TMenuItem;
Prstornadisku1: TMenuItem;
VelikostDiska: TMenuItem;
Edit2: TEdit;
Button1: TButton;
Label5: TLabel;
Button2: TButton;
IconBar: TPanel;
SpeedButton1: TSpeedButton;
SpeedButton2: TSpeedButton;
SpeedButton3: TSpeedButton;
Button3: TButton;
SpeedButton4: TSpeedButton;
SpeedButton5: TSpeedButton;
procedure izhod(Sender: TObject);
procedure srcFileOnClick(Sender: TObject);
procedure brisiClick(Sender: TObject);
procedure Oprogramu1Click(Sender: TObject);
procedure srcFileBoxMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure Prstornadisku1Click(Sender: TObject);
procedure VelikostDiskaClick(Sender: TObject);
procedure trgFileBoxDragOver(Sender, Source: TObject; X, Y: Integer;
State: TDragState; var Accept: Boolean);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure srcDirBoxChange(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure srcDirBoxMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure trgDirBoxDragOver(Sender, Source: TObject; X, Y: Integer;
State: TDragState; var Accept: Boolean);
procedure trgDirBoxDragDrop(Sender, Source: TObject; X, Y: Integer);
procedure trgFileBoxDragDrop(Sender, Source: TObject; X, Y: Integer);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
main: Tmain;
KlikOK: Boolean;
implementation
uses oprg, kop_bris;
{$R *.DFM}
procedure Tmain.izhod(Sender: TObject);
begin
Application.Terminate;
end;
procedure Tmain.srcFileOnClick(Sender: TObject);
begin
Label1.Caption:=srcFileBox.FileName;
srcFileBox.FileEdit:= Edit2;
if (trgDirBox.Directory = 'D:\') or (trgDirBox.Directory='C:\') then
Label5.Caption:= trgDirBox.Directory + Edit2.Text
else
begin
Label5.Caption:= trgDirBox.Directory + '\' + Edit2.Text;
end;
end;
procedure Tmain.brisiClick(Sender: TObject);
var
i: integer;
srcFile:string;
begin
for i:=0 to srcFileBox.Items.Count - 1 do begin
if srcFileBox.Selected[i] then
begin
srcFile:=srcFileBox.Items.Strings[i];
DataModule1.delete(srcFile);
end;
end;
srcFileBox.Update;
trgFileBox.Update;
end;
procedure Tmain.Oprogramu1Click(Sender: TObject);
begin
vizitka.Show;
main.hide;
end;
procedure Tmain.srcFileBoxMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if Button=mbLeft then
with Sender as TFileListBox do
begin
if ItemAtPos(Point(X, Y), True) >= 0 then
BeginDrag(False);
end;
end;
procedure Tmain.trgFileBoxDragDrop(Sender, Source: TObject; X, Y: Integer);
var
iz, trgFile, trgDir, srcFile, v: string;
begin
trgDir:=trgDirBox.Directory;
iz:=Edit2.Text;
srcFile:=srcFileBox.FileName;
if (trgDir= 'D:\') or (trgDir='C:\') then
trgFile:= trgDir + iz
else
begin
trgFile:=trgDir + '\' + iz;
end;
DataModule1.copy(srcFile,trgFile);
srcFileBox.Update;
trgFileBox.Update;
end;
procedure Tmain.Prstornadisku1Click(Sender: TObject);
var
DiskFreeSpace: integer;
DiskFreeSpaceString: string;
begin
DiskFreeSpace:=DataModule1.ProstorNaDisku(0);
DiskFreeSpaceString:= IntToStr(DiskFreeSpace div 1024);
ShowMessage('Na disku ' + srcDriveBox.Drive + ': je Üe: ' + DiskFreeSpaceString + ' KB prostora');
end;
procedure Tmain.VelikostDiskaClick(Sender: TObject);
var
VelikostInteger: integer;
begin
VelikostInteger:= DataModule1.VelikostDiska(0);
ShowMessage('Disk ' + srcDriveBox.Drive + ': je velik '+ IntToStr(VelikostInteger div 1024) + ' KB.')
end;
procedure Tmain.trgFileBoxDragOver(Sender, Source: TObject; X, Y: Integer;
State: TDragState; var Accept: Boolean);
begin
If Source is TFileListBox then
Accept:=True;
If source is TDirectoryListBox then
Accept:=False;
end;
procedure Tmain.Button1Click(Sender: TObject);
var
i:integer;
srcFile: string;
trgFile: string;
begin
for i:=0 to srcFileBox.Items.Count - 1 do begin
if srcFileBox.Selected[i] then
begin
if (srcDirBox.Directory = 'D:\') or (srcDirBox.Directory = 'C:\') or (srcDirBox.Directory = 'A:\') or (srcDirBox.Directory = 'B:\') or (srcDirBox.Directory = 'F:\')then
begin
srcFile:=srcDirBox.Directory + srcFileBox.Items.Strings[i];
if (trgDirBox.Directory='C:\') or (trgDirBox.Directory='D:\') then
begin
trgFile:=trgDirBox.Directory + srcFileBox.Items.Strings[i];
end
else
begin
trgFile:=trgDirBox.Directory + '\' + srcFileBox.Items.Strings[i];
end;
DataModule1.copy(srcFile,trgFile);
end
else
begin
srcFile:=srcDirBox.Directory + '\' + srcFileBox.Items.Strings[i];
if (trgDirBox.Directory='C:\') or (trgDirBox.Directory='D:\') then
begin
trgFile:=trgDirBox.Directory + srcFileBox.Items.Strings[i];
end
else
begin
trgFile:=trgDirBox.Directory + '\' + srcFileBox.Items.Strings[i];
end;
DataModule1.copy(srcFile,trgFile);
end;
end;
end;
srcFileBox.Update;
trgFileBox.Update;
end;
procedure Tmain.Button2Click(Sender: TObject);
var
dirpart, dir:string;
begin
KlikOK:=InputQuery('Ustvarjanje novega direktorija', 'VpiÜi ime direktorija:', dirpart);
if KlikOK = True then
begin
if (srcDirBox.Directory='C:\') or (srcDirBox.Directory='D:\') then
dir:=srcDirBox.Directory + dirpart
else
begin
dir:=srcDirBox.Directory + '\' + dirpart;
end;
CreateDir(dir);
srcDirBox.Update;
trgDirBox.Update;
end;
end;
procedure Tmain.srcDirBoxChange(Sender: TObject);
begin
main.Caption:= Application.Title + ' - ' + srcDirBox.Directory;
end;
procedure Tmain.Button3Click(Sender: TObject);
var
deldir: string;
i:integer;
j:integer;
srcDirsOnly:string;
begin
for i:=0 to srcDirBox.Items.Count -1 do
begin
if srcDirBox.Selected[i] then
begin
if not ((srcDirBox.Directory = 'C:\') or (srcDirBox.Directory = 'D:\')) then
begin
for j:=1 to i do
begin
if j=1 then
begin
srcDirsOnly:=srcDirBox.Items.Strings[j];
end
else
begin
srcDirsOnly:=srcDirsOnly + '\'+ srcdirBox.Items.Strings[j];
end;
end;
end
else
begin
srcDirsOnly:=srcDirBox.Items.Strings[i];
end;
deldir:=srcDirBox.Items.Strings[0] + srcDirsOnly + '\';
srcDirBox.Directory:=srcDirBox.Drive + ':\';
trgDirBox.Directory:=srcDirBox.Drive + ':\';
RemoveDir(deldir);
srcDirBox.Update;
trgDirBox.Update;
break;
end;
end;
end;
procedure Tmain.srcDirBoxMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if Button=mbLeft then
with Sender as TDirectoryListBox do
begin
if ItemAtPos(Point(X, Y), True) >= 0 then
BeginDrag(False);
end;
end;
procedure Tmain.trgDirBoxDragOver(Sender, Source: TObject; X, Y: Integer;
State: TDragState; var Accept: Boolean);
begin
If Source is TDirectoryListBox then
Accept := True;
If Source is TFileListBox then
Accept := True;
end;
procedure Tmain.trgDirBoxDragDrop(Sender, Source: TObject; X, Y: Integer);
var
i:integer;
j:integer;
k:integer;
srcDirsOnly:string;
trgPoint:TPoint;
pos:integer;
trgDir:string;
srcFile:string;
begin
if Source = srcDirBox then
begin
for i:=0 to srcDirBox.Items.Count -1 do
begin
if srcDirBox.Selected[i] then
begin
if not ((srcDirBox.Directory = 'C:\') or (srcDirBox.Directory = 'D:\')) then
begin
for j:=1 to i do
begin
if j=1 then
begin
srcDirsOnly:=srcDirBox.Items.Strings[j];
end
else
begin
srcDirsOnly:=srcDirsOnly + '\'+ srcdirBox.Items.Strings[j];
end;
end;
end
else
begin
srcDirsOnly:=srcDirBox.Items.Strings[i];
end;
srcDirBox.Directory:=srcDirBox.Drive + ':\' + srcDirsOnly + '\';
srcFileBox.Update;
trgPoint.X:=X;
trgPoint.Y:=Y;
pos:=trgDirBox.ItemAtPos(trgPoint,False);
if pos = 0 then
begin
trgDir:=trgDirBox.Items.Strings[0] + srcDirsOnly + '\';
ForceDirectories(trgDir);
end
else
begin
trgDir:=trgDirBox.Items.Strings[0] + trgDirBox.Items.Strings[pos] + '\'+ srcDirsOnly + '\';
ForceDirectories(trgDir);
end;
if not (srcFileBox.Items.Count = 0) then
begin
for k:=0 to srcFileBox.Items.Count -1 do
begin
DataModule1.copy(srcDirBox.Directory + '\' + srcFileBox.Items.Strings[k], trgDir + srcFileBox.Items.Strings[k]);
end;
end;
srcDirBox.Update;
trgDirBox.Update;
Break;
end;
end;
end;
if Source = srcFileBox then
begin
trgPoint.X:=X;
trgPoint.Y:=Y;
srcFile:=srcFileBox.FileName;
for i:=0 to trgDirBox.Items.Count -1 do
begin
if trgDirBox.Selected[i] then
begin
if (trgDirBox.Directory = 'C:\') or (trgDirBox.Directory = 'D:\') then
begin
trgDir:=trgDirBox.Drive + ':\' + trgDirBox.Items.Strings[i];
end
else
begin
for j:=1 to trgDirBox.Items.Count -1 do
begin
trgDir:=trgDirBox.Drive + ':\' + trgDirBox.Items.Strings[j];
end;
end;
end;
ShowMessage(srcFile);
ShowMessage(trgDir);
end;
srcFileBox.Update;
trgDirBox.Update;
end;
end;
procedure Tmain.FormCreate(Sender: TObject);
begin
main.Caption:=Application.Title;
end;
end.