home *** CD-ROM | disk | FTP | other *** search
/ Stars of Shareware: Windows Tools / SOS-WIN_TOOLS.ISO / programm / divers / ecotrash / trash.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1994-02-18  |  21.1 KB  |  765 lines

  1. Program Trash;
  2.  
  3. {***********************************************************************
  4.  
  5.                      The first ecologic trash !!
  6.  
  7.  
  8.         By Sebastien Stormacq (c) 1993 - FNDP Namur - Belgium
  9.  
  10. ***********************************************************************}         
  11.  
  12.  
  13. {$R TRASH}
  14.  
  15. Uses
  16.  WinTypes,WinProcs,Win31,ShellAPI,WObjects,Strings, WinDos, BWCC, LZExpand;
  17.  
  18. Const
  19.   AppName      = 'Trash Can';
  20.   id_path      = 101;
  21.   id_Recycle   = 400;
  22.   cm_show      = 991;
  23.   cm_empty     = 992;
  24.   cm_ontop     = 995;
  25.   id_pathname  = 996;
  26.   id_filelist  = 997;
  27.   id_help      = 998;
  28.   Title        = 'Eco Taxe : ' + #13;
  29.  
  30. Type
  31.   PTrashWin = ^TTrashWin;
  32.   TTrashWin = Object(TWindow)
  33.  
  34.                 LExtension          : PStrCollection;
  35.                 msg_Title           : array[0..30] of char;
  36.                 ontop               : boolean;
  37.                 currency            : array[0..4] of char;
  38.  
  39.                 Constructor Init(AParent : PWindowsObject; AName : PChar);
  40.  
  41.                 Destructor Done;
  42.                   Virtual;
  43.  
  44.                 Procedure SetupWindow;
  45.                   Virtual;
  46.  
  47.                 Function GetClassName : PChar;
  48.                   Virtual;
  49.  
  50.                 Procedure GetWindowClass(Var AWndClass : TWndClass);
  51.                   Virtual;
  52.  
  53.                 Procedure WMSysMessage(Var msg : TMessage);
  54.                   Virtual wm_SysCommand;
  55.  
  56.                 Procedure Show_message(Var msg : TMessage);
  57.                   Virtual cm_first + cm_show;
  58.  
  59.                 Procedure Empty_Trash(Var msg : TMessage);
  60.                   Virtual cm_first + cm_empty;
  61.  
  62.                 Procedure WMQueryOpen(Var Msg : TMessage);
  63.                   Virtual wm_QueryOpen;
  64.  
  65.                 Procedure WMDropFiles(var Msg : TMessage);
  66.                   Virtual wm_first + wm_DropFiles;
  67.  
  68.                 Procedure FileDropped(FileName : PChar;
  69.                                       Var DropPos : TPoint;
  70.                                       InClient : Boolean);
  71.                   Virtual;
  72.  
  73.                 Procedure OnTopProc(var msg : TMessage);
  74.                   Virtual wm_first + cm_ontop;
  75.  
  76.                 Procedure Make_Message;
  77.               End;
  78.  
  79.  TMyApp = Object(TApplication)
  80.             Procedure InitMainWindow;
  81.               Virtual;
  82.           End;
  83.  
  84.  PEmpty = ^TEmpty;  
  85.  TEmpty = Object(TDialog)
  86.             path_name  : PStatic;
  87.             File_List  : PListBox;
  88.             MainWind   : PTrashWin;
  89.  
  90.             Constructor Init(AParent : PWindowsObject; AName : PChar);
  91.             Procedure SetupWindow;
  92.               Virtual;
  93.             Procedure OK(var msg : TMessage);
  94.               Virtual id_first + id_ok;
  95.             Procedure Help(Var msg : TMessage);
  96.               Virtual id_first + id_help;
  97.             Procedure Recycle(var msg : Tmessage);
  98.               Virtual id_first + id_recycle;
  99.             Function  GetSelFile : PChar;
  100.             End;
  101.  
  102.  PToWhere = ^TToWhere;
  103.  TToWhere = Object(TDialog)
  104.  
  105.             ppath     : PEdit;
  106.             path      : array[0..144] of char;
  107.             father    : PEmpty;
  108.             bt_ok     : PButton;
  109.  
  110.             Constructor Init(AParent : PWindowsObject; AName : PChar);
  111.             Destructor  Done;
  112.               Virtual;
  113.             Procedure SetupWindow;
  114.               Virtual;
  115.             Procedure OK(var msg : TMessage);
  116.               Virtual id_first + id_ok;
  117.             Procedure CheckEdit(var msg : TMessage);
  118.               Virtual id_first + id_path;
  119.             end;
  120.  
  121. var
  122.    config_show_message : boolean;
  123.    config_move_to_dir  : array[0..144] of char;
  124.    a_file              : array[0..13] of char;
  125.    MyApp               : TMyApp;
  126.    ecotax              : LongInt;
  127. {---------------------------------------------------}
  128.  
  129. { --- Application Methods --- }
  130.  
  131. Procedure TMyApp.InitMainWindow;
  132.  
  133. Begin
  134.   MainWindow := New(PTrashWin,Init(nil,AppName));
  135. End;
  136.  
  137. {---------------------------------------------------}
  138. Constructor TTrashWin.Init;
  139.  
  140. Begin
  141.      TWindow.Init(Aparent, AName);
  142.  
  143.      LExtension := New(PStrCollection,Init(10,10));
  144. End;
  145.  
  146. {---------------------------------------------------}
  147. Destructor TTrashWin.Done;
  148.  
  149. Begin
  150.      TWindow.Done;
  151.  
  152.      Dispose(LExtension,Done)
  153. End;
  154. {---------------------------------------------------}
  155.  
  156. { --- Window Methods --- }
  157.  
  158. Procedure TTrashWin.Make_Message;
  159.  
  160. var
  161.     tmp_ecotax     : integer;
  162.     st_ecotax      : string[9];
  163.     nt_ecotax      : array[0..9] of char;
  164.  
  165. Begin
  166.   StrCopy(msg_Title,'');
  167.   tmp_ecotax := ecotax div 1024;
  168.   Str(tmp_ecotax,st_ecotax);
  169.   StrPCopy(nt_ecotax,st_ecotax);
  170.   StrCat(msg_Title,Title);
  171.   StrCat(msg_Title,nt_ecotax);
  172.   StrCat(msg_Title,' ');
  173.   StrCat(msg_Title, currency);
  174. End;
  175. {---------------------------------------------------}
  176. Procedure TTrashWin.SetupWindow;
  177.  
  178. var menu               : hmenu;
  179.     show_msg,
  180.     nt_ontop           : array[0..3]  of char;
  181.     config_list_file,
  182.     temp               : array[0..70] of char;
  183.     extension          : array[0..4]  of char;
  184.     dirInfo            : TSearchRec;
  185.     file_mask          : array[0..127] of char;
  186.  
  187.     win_dir            : array[0..80] of char;
  188.     buffer             : TOfStruct;
  189.  
  190. Begin
  191.   TWindow.SetupWindow;
  192.  
  193.   SetCursor(LoadCursor(0,idc_wait));
  194.  
  195.   DragAcceptFiles(hWindow,True); { Inform Windows that we accept file drops }
  196.  
  197.   {Append two new item to the system menu}
  198.   menu := GetSystemMenu(hWindow,false);
  199.   AppendMenu(menu,mf_separator,0,Nil);
  200.   AppendMenu(menu,mf_string,cm_show,'&Show Messages');
  201.   AppendMenu(menu,mf_string,cm_ontop,'&On Top');
  202.  
  203.   {test the trash.ini file existence}
  204.   GetWindowsDirectory(win_dir,80);
  205.   StrCat(win_dir,'\trash.ini');
  206.   {if it doesn't exist create it with default values}
  207.   if LZOpenFile(win_dir,buffer,of_exist) < 0 then begin
  208.      WritePrivateProfileString('Configuration','Show_Message','Yes',win_dir);
  209.      if GetEnvVar('TEMP')<>NIL then begin
  210.                                  StrCopy(temp, GetEnvVar('TEMP'));
  211.                                  StrCat(temp,'\TRASH')
  212.                                  end
  213.                                 else StrCopy(temp,'c:\trash');
  214.  
  215.      WritePrivateProfileString('Configuration','Move_To',temp,win_dir);
  216.      WritePrivateProfileString('Configuration','On_Top','Yes',win_dir);
  217.      WritePrivateProfileString('Configuration','Reusable','.TXT .DOC .WRI',win_dir);
  218.      end;
  219.  
  220.  
  221.  
  222.   GetPrivateProfileString('Configuration','Show_Message','Yes',show_msg,4,'trash.ini');
  223.   if StrComp(show_msg,'Yes')=0 then begin
  224.      CheckMenuItem(Menu,cm_show,mf_ByCommand Or mf_Checked);
  225.      config_show_message := TRUE
  226.      end
  227.   else Begin
  228.      CheckMenuItem(Menu,cm_show,mf_ByCommand Or mf_UnChecked);
  229.      config_show_message := FALSE
  230.      end;
  231.  
  232.   
  233.   AppendMenu(menu,mf_separator,0,Nil);
  234.   AppendMenu(menu,mf_string,cm_empty,'&Empty Trash...');
  235.  
  236.   {Disabled the items Maximize and Restore}
  237.   ModifyMenu(menu,sc_restore,mf_bycommand or mf_grayed,0,'Restore');
  238.   ModifyMenu(menu,sc_MAximize,mf_bycommand or mf_grayed,0,'Maximize');
  239.  
  240.   {Get the directory_name where the files will be stored}
  241.   GetPrivateProfileString('Configuration','Move_To',GetEnvVar('Temp'),config_move_to_dir,30,'trash.ini');
  242.  
  243.  
  244.   {Get the local currency in the win.ini file}
  245.   GetProfileString('intl','sCurrency','FB',currency,4);
  246.  
  247.   {Get the ontop flag}
  248.   GetPrivateProfileString('Configuration','On_Top','Yes',nt_ontop,4,'trash.ini');
  249.   if StrComp(nt_ontop,'Yes')=0 then begin
  250.      ontop := TRUE;
  251.      CheckMenuItem(Menu,cm_ontop,mf_ByCommand Or mf_Checked);
  252.      end
  253.   else begin
  254.      ontop := false;
  255.      CheckMenuItem(menu,cm_ontop,mf_bycommand or mf_unchecked);
  256.   end;
  257.  
  258.   if ontop then SetWindowPos(hWindow,hwnd_topmost,0,0,0,0,swp_nosize or swp_nomove) {Put the icon on top of another windows}
  259.            else SetWindowPos(hWindow,hwnd_notopmost,0,0,0,0,swp_nosize or swp_nomove);
  260.            
  261.   {Get the list of ReUsable files}
  262.   GetPrivateProfileString('Configuration','Reusable','.TXT',config_list_file,69,'trash.ini');
  263.   StrCopy(temp,'');
  264.  
  265.   while StrScan(config_list_file,'.')<>nil do
  266.   begin
  267.      StrLCopy(extension,config_list_file,4);
  268.  
  269.      LExtension^.Insert(StrNew(extension));
  270.      config_list_file[0] := '/';
  271.      if StrScan(config_list_file,'.') <> nil then StrCopy(temp,StrScan(config_list_file,'.'));
  272.      StrCopy(Config_list_file,'');
  273.      StrCopy(config_list_file,temp);
  274.      StrCopy(temp,'');
  275.   End;
  276.  
  277.   ecotax := 0;
  278.   StrCopy(file_mask,config_move_to_dir);
  279.   StrCat(File_mask,'\*.*');
  280.   FindFirst(file_mask,faanyfile, DirInfo);
  281.  
  282.   While DosError = 0 do begin
  283.       ecotax := ecotax + DirInfo.Size;
  284.       FindNext(DirInfo)
  285.       End;
  286.  
  287.   Make_Message;
  288.  
  289.   SetWindowText(hWindow,msg_Title); {Set the text beyond the icon}
  290.   if ecotax = 0 then Begin
  291.      ModifyMenu(menu,cm_empty,mf_bycommand or mf_grayed,cm_empty,'&Empty Trash...');
  292.      SetClassWord(HWindow,gcw_HIcon,LoadIcon(HInstance,'Empty_Trash'))
  293.      End
  294.   else SetClassWord(HWindow,gcw_HIcon,LoadIcon(HInstance,'Full_Trash'));
  295.  
  296.  
  297.   InvalidateRect(HWindow,Nil,True);
  298.   SetCursor(LoadCursor(0,idc_arrow));
  299.   UpdateWindow(HWindow);
  300.  
  301. End;  {SetupWindow}
  302.  
  303. {---------------------------------------------------}
  304.  
  305. Procedure TTrashWin.WMDropFiles;
  306.  
  307. Var
  308.  NumFiles : word;
  309.  FileName : array[0..127] of char;
  310.  i : word;
  311.  DropPoint : TPoint;
  312.  InClientArea : boolean;
  313.  
  314. Begin
  315.  { Msg.wParam contains a handle to the "drop info" }
  316.  
  317.  { First, find out how many files were dropped }
  318.  NumFiles := DragQueryFile(Msg.wParam,$FFFF,Nil,0);
  319.  
  320.  { Next, find out where the file was dropped }
  321.  InClientArea := DragQueryPoint(Msg.wParam,DropPoint);
  322.  
  323.  { Finally, retrieve the dropped files and call the virtual method
  324.    "FileDropped" }
  325.  For i := 0 to Pred(NumFiles) Do
  326.  Begin
  327.    DragQueryFile(Msg.wParam,i,FileName,Pred(Sizeof(FileName)));
  328.    FileDropped(FileName,DropPoint,InClientArea);
  329.  End;
  330.  
  331.  { Cleanup - tell Windows that we're done with the "drop info" }
  332.  DragFinish(Msg.wParam);
  333.  
  334. End {WMDropFiles};
  335.  
  336. {---------------------------------------------------}
  337.  
  338. Procedure TTrashWin.FileDropped(FileName : PChar;
  339.                                        Var DropPos : TPoint;
  340.                                        InClient : Boolean);
  341.  
  342. Const msg_txt = 'Your file is not reusable.'+#13+#13+'You have to pay an ecotaxe.';
  343.  
  344. Var
  345.   TrashFile    : File;
  346.   ext          : array [0..4] of char;
  347.   ReUsable     : Boolean;
  348.   size         : LongInt;
  349.   DirInfo      : TSearchRec;
  350.   OpenBuffer   : TOfStruct;
  351.   Real_FileName: array[0..12] of char;
  352.   New_FileName : array[0..144] of char;
  353.   lzfile_source,
  354.   lzfile_dest  : integer;
  355.   menu         : hMenu;
  356.   copy_ok      : boolean;
  357.  
  358.   temp         : array[0..80] of char;
  359.  
  360. procedure Check_ReUsability(item : pchar); far;
  361.  
  362. Begin
  363.   if not reusable then ReUsable := ReUsable or (StrComp(ext,item)=0)
  364. end;
  365.  
  366. Begin
  367.   {exit if you try to trash a file from the trash directory}
  368.   if not(StrPos(FileName,config_move_to_dir) = nil) then exit;
  369.  
  370.   if ecotax>0 then SetClassWord(HWindow,gcw_HIcon,LoadIcon(HInstance,'Open_trash'))
  371.               else SetClassWord(HWindow,gcw_HIcon,LoadIcon(HInstance,'Empty_Open_trash'));
  372.   InvalidateRect(HWindow,Nil,True);
  373.   UpdateWindow(hwindow);
  374.  
  375.   SetCursor(LoadCursor(0,idc_wait));
  376.  
  377.   ReUsable := false;
  378.  
  379.   if StrScan(FileName,'.') <> nil then StrLCopy(ext,StrScan(FileName,'.'),4);
  380.  
  381.   LExtension^.ForEach(@Check_ReUsability);
  382.  
  383.   if not ReUsable and config_show_message then
  384.      MessageBox(HWindow,msg_txt,'Ministerial decision',mb_ok or mb_IconExclamation);
  385.    
  386.   FindFirst(FileName,faAnyFile,DirInfo);
  387.  
  388.   StrCopy(temp,'The file ');
  389.   StrCat(temp,DirInfo.name);
  390.   StrCat(temp,' is read-only.');
  391.   StrCat(temp,#13);
  392.   StrCAt(temp,'It won''t be deleted.');
  393.   if (DirInfo.attr AND faReadOnly) = faReadOnly then MessageBox(0,temp,'WARNING',MB_OK);
  394.  
  395.   ecotax := ecotax + DirInfo.size;
  396.   if ecotax > 0 then begin
  397.      menu := GetSystemMenu(hWindow,false);
  398.      ModifyMenu(menu,cm_empty,mf_bycommand or mf_enabled,cm_empty,'&Empty Trash...');
  399.      end;
  400.     
  401.   Make_Message;
  402.   SetWindowtext(hWindow,msg_Title);
  403.  
  404.   {get the real file name - without the path - }
  405.   StrCopy(Real_filename,DirInfo.Name);
  406.  
  407.   StrCopy(New_FileName,config_move_to_dir);
  408.  
  409.   if LZOpenFile(New_FileName, OpenBuffer, of_exist)=-1 then CreateDir(New_FileName);
  410.  
  411.   StrCat(New_FileName,'\');
  412.   StrCat(New_FileName,Real_FileName);
  413.  
  414.   lzfile_source := LZOpenFile(FileName, OpenBuffer, of_read);
  415.   lzfile_dest   := LZOpenFile(New_FileName, OpenBuffer, of_create);
  416.   copy_ok := not(LZCopy(lzfile_source,lzfile_dest) < 0);
  417.   LZClose(lzfile_source);
  418.   LZClose(lzfile_dest);
  419.  
  420.   if copy_ok then begin
  421.      Assign(TrashFile,FileName);
  422.      {$i-}
  423.      Erase(TrashFile);
  424.      {$i+}
  425.      end;
  426.  
  427.   SetClassWord(HWindow,gcw_HIcon,LoadIcon(HInstance,'Full_trash'));
  428.   InvalidateRect(HWindow,Nil,True);
  429.   UpdateWindow(HWindow);
  430.  
  431.  
  432.   SetCursor(LoadCursor(0,idc_arrow));
  433.  
  434. End {FileDropped};
  435.  
  436. {---------------------------------------------------}
  437.  
  438. Procedure TTrashWin.WMSysMessage(Var Msg : TMessage);
  439.  
  440. Begin
  441.   Case Msg.wParam of
  442.     cm_Show   : Show_Message(Msg);
  443.     cm_Empty  : Empty_Trash(msg);
  444.     cm_ontop  : OnTopProc(Msg);
  445.     Else DefWndProc(Msg);
  446.   End;
  447. End {WMSysCommand};
  448.  
  449. {---------------------------------------------------}
  450. Procedure TTrashWin.Show_Message;
  451.  
  452. var menu   : hmenu;
  453.     state  : boolean;
  454.  
  455. Begin
  456.  
  457.      menu  := GetSystemMenu(hwindow,false);
  458.      
  459.      if CheckMenuItem(menu,cm_show,mf_bycommand or mf_checked) then
  460.         Begin
  461.           CheckMenuItem(menu,cm_show,mf_bycommand or mf_unchecked);
  462.           config_show_message := false;
  463.           WritePrivateProfileString('Configuration','Show_Message','No','Trash.ini')
  464.           End
  465.  
  466.      else Begin
  467.           CheckMenuItem(menu,cm_show,mf_bycommand or mf_checked);
  468.           config_show_message := true;
  469.           WritePrivateProfileString('Configuration','Show_Message','Yes','Trash.ini')
  470.           end;
  471. End;
  472.  
  473. {---------------------------------------------------}
  474. Procedure TTrashWin.Empty_Trash;
  475.  
  476. var
  477.    EmptyDlg : TEmpty;
  478.    fm_hwnd  : hwnd;
  479.    menu     : hMenu;
  480.    return   : integer;
  481.  
  482. begin
  483.   SetClassWord(hWindow,gcw_HIcon,LoadIcon(HInstance,'Open_trash'));
  484.   InvalidateRect(HWindow,Nil,True);
  485.   SetCursor(LoadCursor(0,idc_wait));
  486.   UpdateWindow(HWindow);
  487.  
  488.   EmptyDlg.Init(@Self,'EmptyDlg');
  489.  
  490.   EmptyDlg.Execute;
  491.   if (ecotax=0) then begin
  492.      SetClassWord(HWindow,gcw_HIcon,LoadIcon(HInstance,'Empty_trash'));
  493.      InvalidateRect(HWindow,Nil,True);
  494.      SetCursor(LoadCursor(0,idc_arrow));
  495.      UpdateWindow(HWindow);
  496.      end;
  497.  
  498.   if (ecotax>0) then begin
  499.      SetClassWord(HWindow,gcw_HIcon,LoadIcon(HInstance,'Full_trash'));
  500.      InvalidateRect(HWindow,Nil,True);
  501.      SetCursor(LoadCursor(0,idc_arrow));
  502.      UpdateWindow(HWindow);
  503.      end;
  504.   
  505.   EmptyDlg.Done;
  506.  
  507.   Make_Message;
  508.   SetWindowtext(hWindow,msg_title);
  509.  
  510.   if ecotax = 0 then begin
  511.      menu := GetSystemMenu(Hwindow,false);
  512.      ModifyMenu(menu,cm_empty,mf_bycommand or mf_grayed,cm_empty,'&Empty Trash...');
  513.      end;
  514. End;
  515.  
  516. {---------------------------------------------------}
  517.  
  518. Procedure TTrashWin.WMQueryOpen(Var Msg : TMessage);
  519.  
  520. var msg_temp : TMessage;
  521.  
  522. Begin
  523.   if ecotax <> 0 then Empty_Trash(msg_temp);
  524.       
  525.   Msg.Result := 0;       { Deny open }
  526.  
  527. End {WMQueryOpen};
  528.  
  529. {---------------------------------------------------}
  530. Procedure TTrashWin.OnTopProc;
  531.  
  532. Var
  533.    nt_ontop : array [0..3] of char;
  534.    menu     : hMenu;
  535.  
  536. Begin                        
  537.  
  538.   menu := GetSystemMenu(hWindow,FALSE);
  539.  
  540.   if ontop then begin
  541.      ontop := False;
  542.      CheckMenuItem(Menu,cm_ontop,mf_ByCommand Or mf_UnChecked);
  543.      StrCopy(nt_ontop,'No');
  544.      end
  545.   else begin
  546.      ontop := True;
  547.      CheckMenuItem(menu,cm_ontop,mf_bycommand or mf_checked);
  548.      StrCopy(nt_ontop,'Yes');
  549.   end;
  550.  
  551.   if ontop then SetWindowPos(hWindow,hwnd_topmost,0,0,0,0,swp_nosize or swp_nomove) {Put the icon on top of another windows}
  552.            else SetWindowPos(hWindow,hwnd_notopmost,0,0,0,0,swp_nosize or swp_nomove);
  553.            
  554.   WritePrivateProfileString('Configuration','On_Top',nt_ontop,'trash.ini');
  555.  
  556. end;
  557.  
  558. {---------------------------------------------------}
  559. Function TTrashWin.GetClassName;
  560.  
  561. Begin
  562.   GetClassName := AppName;
  563. End {GetClassName};
  564.  
  565. {---------------------------------------------------}
  566.  
  567. Procedure TTrashWin.GetWindowClass(Var AWndClass : TWndClass);
  568.  
  569. Begin
  570.   TWindow.GetWindowClass(AWndClass);
  571.  
  572.   AWndClass.hIcon := LoadIcon(HInstance,'empty_trash');
  573. End {GetWindowClass};
  574.  
  575. {---------------------------------------------------}
  576. Constructor TEmpty.Init;
  577.  
  578. Begin
  579.      TDialog.Init(AParent, AName);
  580.      path_name := New(PStatic, InitResource(@Self, id_pathname,127));
  581.      file_list := New(PListBox, InitResource(@Self, id_filelist));
  582.      MainWind  := New(PTrashWin);
  583. End;
  584. {---------------------------------------------------}
  585. Procedure TEmpty.SetupWindow;
  586.  
  587. var
  588.     FileName  : array[0..144] of char;
  589.  
  590. begin
  591.      Tdialog.SetupWindow;
  592.      StrCopy(FileName,config_move_to_dir);
  593.      DlgDirList(hWindow, FileName, id_filelist, id_pathname, ddl_archive);
  594.      file_list^.SetSelIndex(0);
  595. End;
  596. {---------------------------------------------------}
  597. Procedure TEmpty.Ok;
  598.  
  599. var DirInfo   : TSearchRec;
  600.     FileName  : array[0..144] of char;
  601.     TrashFile : File;
  602.  
  603. Begin
  604.   StrCopy(FileName,'');
  605.   StrCopy(FileName,config_move_to_dir);
  606.   StrCat(FileName,'\*.*');
  607.   FindFirst(FileName, faArchive + faHidden + faSysFile + faReadOnly, DirInfo);
  608.  
  609.   while DosError = 0 do
  610.      Begin
  611.         StrCopy(FileName,'');
  612.         StrCopy(FileName,config_move_to_dir);
  613.         StrCat(FileName,'\');
  614.         StrCat(FileName,DirInfo.Name);
  615.         Assign(TrashFile,FileName);
  616.         {$i-}
  617.         Erase(TrashFile);
  618.         {$i+}
  619.         FindNext(DirInfo);
  620.      End;
  621.  
  622.   ecotax := 0;
  623.  
  624.   TDialog.Ok(msg);
  625. End;
  626.  
  627. {---------------------------------------------------}
  628. Procedure TEmpty.Recycle;
  629.  
  630. var
  631.     FileName  : array[0..144] of char;
  632.     DirInfo   : TSearchRec;
  633.  
  634. Begin
  635.  file_list^.GetSelString(a_file,13);
  636.  
  637.  Application^.ExecDialog(New(PToWhere,Init(@Self,'ToWhere')));
  638.  
  639.  StrCopy(FileName,config_move_to_dir);
  640.  DlgDirList(hWindow, FileName, id_filelist, id_pathname, ddl_archive);
  641.  file_list^.SetSelIndex(0);
  642.  
  643.  StrCopy(FileName,'');
  644.  StrCopy(FileName,config_move_to_dir);
  645.  ecotax := 0;
  646.  StrCat(FileName,'\*.*');
  647.  FindFirst(fileName,faanyfile, DirInfo);
  648.  
  649.  While DosError = 0 do begin
  650.      ecotax := ecotax + DirInfo.Size;
  651.      FindNext(DirInfo)
  652.      End;
  653. End;
  654.  
  655. {---------------------------------------------------}
  656. Function TEmpty.GetSelFile;
  657.  
  658. Begin
  659.      GetSelFile := a_file;
  660. End;
  661.  
  662. {---------------------------------------------------}
  663. Constructor TToWhere.Init;
  664.  
  665. Begin
  666.      TDialog.Init(Aparent, AName);
  667.      ppath  := New(PEdit, InitResource(@Self,id_path,145));
  668.      bt_ok  := New(PButton, InitResource(@Self,id_OK));
  669.      father := new(pempty);
  670. End;
  671.  
  672. {---------------------------------------------------}
  673. Destructor TToWhere.Done;
  674.  
  675. Begin
  676.      TDialog.Done;
  677.      Dispose(father);
  678. End;
  679. {---------------------------------------------------}
  680.  
  681. Procedure TToWhere.SetupWindow;
  682.  
  683. var directory : array[0..144] of char;
  684.  
  685. Begin
  686.      TDialog.SetupWindow;
  687.      GetWindowsDirectory(directory,144);
  688.      ppath^.SetText(directory);
  689. end;
  690. {---------------------------------------------------}
  691. Procedure TToWhere.Ok;
  692.  
  693. var
  694.    copy_ok       : Boolean;
  695.    lzfile_source,
  696.    lzfile_dest   : integer;
  697.    OpenBuffer    : TOfStruct;
  698.    TrashFile     : File;
  699.    FileName,
  700.    new_FileName  : array[0..144] of char;
  701.  
  702.    temp          : string[144];
  703.    temp_len      : byte;
  704.    erreur        : integer;
  705.  
  706. Begin
  707.  
  708.   StrCopy(FileName,'');
  709.   StrCat(FileName,config_move_to_dir);
  710.   StrCat(FileName,'\');
  711.   StrCat(FileName,father^.GetSelFile);
  712.  
  713.   StrCopy(New_FileName,'');
  714.   ppath^.GetText(New_FileName,144);
  715.   if StrComp(StrEnd(New_FileName)-1,'\') <> 0 then StrCat(New_FileName,'\');
  716.   StrCat(New_FileName,father^.GetSelFile);
  717.  
  718.   lzfile_source := LZOpenFile(FileName, OpenBuffer, of_read);
  719.   lzfile_dest   := LZOpenFile(New_FileName, OpenBuffer, of_create);
  720.   copy_ok := not(LZCopy(lzfile_source,lzfile_dest) < 0);
  721.   LZClose(lzfile_source);
  722.   LZClose(lzfile_dest);
  723.  
  724.   if copy_ok then begin
  725.      Assign(TrashFile,FileName);
  726.      {$i-}
  727.      Erase(TrashFile);
  728.      {$i+}
  729.      end
  730.   else MessageBox(hWindow,'The file is not moved',
  731.                   'File Error',mb_ok);
  732.  
  733.   TDialog.Ok(msg);
  734. End;
  735.  
  736. {---------------------------------------------------}
  737. Procedure TToWhere.CheckEdit;
  738.  
  739. var New_FileNAme : array[0..144] of char;
  740.  
  741. Begin
  742.      if msg.lparamhi = en_change then Begin
  743.         ppath^.GetText(New_FileName,144);
  744.         if StrComp(New_FileNAme,'')=0 then EnableWindow(bt_ok^.hWindow,false)
  745.                                       else EnableWindow(bt_ok^.hWindow,true);
  746.         end;
  747. End;
  748.  
  749. {---------------------------------------------------}
  750. Procedure TEmpty.Help;
  751.  
  752. Begin
  753.     Application^.ExecDialog(New(PDialog,Init(@Self,'About')));
  754. End;
  755.  
  756. {---------------------------------------------------}
  757. Begin
  758.   CmdShow := sw_ShowMinNoActive;
  759.  
  760.   MyApp.Init(AppName);
  761.   MyApp.Run;
  762.   MyApp.Done;
  763. End.
  764.  
  765.