home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1998 April A / Pcwk4a98.iso / PROGRAM / DELPHI16 / Calmira / Src / SRC / CALMIRA.DPR < prev    next >
Text File  |  1997-02-15  |  6KB  |  174 lines

  1. {**************************************************************************}
  2. {                                                                          }
  3. {    Calmira shell for Microsoft« Windows(TM) 3.1                          }
  4. {    Source Release 1.0                                                    }
  5. {    Copyright (C) 1997  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. program Calmira;
  24.  
  25. uses
  26.   Forms,
  27.   WinProcs,
  28.   WinTypes,
  29.   SysUtils,
  30.   Controls,
  31.   Dialogs,
  32.   MiscUtil,
  33.   Classes,
  34.   Buttons,
  35.   IniFiles,
  36.   Files,
  37.   Strings,
  38.   Profile,
  39.   About in 'ABOUT.PAS' {About box},
  40.   Fileprop in 'FILEPROP.PAS' {File Properties},
  41.   Diskprop in 'DISKPROP.PAS' {Disk Properties},
  42.   Progress in 'PROGRESS.PAS' {Progress Box},
  43.   Replace in 'REPLACE.PAS' {Replace Box},
  44.   Splash in 'SPLASH.PAS' {Splash Form},
  45.   Openfile in 'OPENFILE.PAS' {Open File},
  46.   Runprog in 'RUNPROG.PAS' {Run},
  47.   Desk in 'DESK.PAS' {Desktop},
  48.   Sys in 'SYS.PAS' {System Window},
  49.   Shorts in 'SHORTS.PAS' {Shortcuts},
  50.   Filter in 'FILTER.PAS' {Filter},
  51.   Wastebin in 'WASTEBIN.PAS' {Bin},
  52.   Filefind in 'FILEFIND.PAS' {Find form},
  53.   Busy in 'BUSY.PAS' {Busy Box},
  54.   Iconic in 'ICONIC.PAS' {Iconic classes},
  55.   FileMan in 'FILEMAN.PAS' {File management},
  56.   Resource in 'RESOURCE.PAS' {Resources},
  57.   Directry in 'DIRECTRY.PAS' {Directories},
  58.   Settings in 'SETTINGS.PAS' {Settings},
  59.   Iconwin in 'ICONWIN.PAS' {Icon Windows},
  60.   Start in 'START.PAS' {Start Menu},
  61.   Progconv in 'PROGCONV.PAS' {Convert Dialog},
  62.   Referenc in 'REFERENC.PAS' {References},
  63.   Alias in 'ALIAS.PAS' {Aliases},
  64.   Tree in 'TREE.PAS' {Explorer},
  65.   Shutdown in 'SHUTDOWN.PAS' {Shutdown dialog},
  66.   Calform in 'CALFORM.PAS' {Modeless windows},
  67.   Fourdos in 'FOURDOS.PAS' {4DOS descriptions},
  68.   Refedit in 'REFEDIT.PAS' {Reference editor},
  69.   Menuedit in 'MENUEDIT.PAS' {Menu editor},
  70.   Strtprop in 'STRTPROP.PAS' {Start Properties},
  71.   Deskprop in 'DESKPROP.PAS' {Desktop Properties},
  72.   Binprop in 'BINPROP.PAS' {Bin Properties},
  73.   Taskprop in 'TASKPROP.PAS' {Taskbar Properties},
  74.   Calmsgs in 'CALMSGS.PAS' {Messages},
  75.   Sysprop in 'SYSPROP.PAS' {System Properties},
  76.   Fsysprop in 'FSYSPROP.PAS' {File System Props},
  77.   Askdrop in 'ASKDROP.PAS' {Ask Drop},
  78.   Debug in 'DEBUG.PAS' {Console},
  79.   Select in 'SELECT.PAS' {Select File Dialog};
  80.  
  81. {$R *.RES}
  82.  
  83.  
  84. procedure LoadAndRun;
  85. var
  86.   progs : string;
  87.   win : TIniFile;
  88. begin
  89.   { Reads and processes the Load= and Run= lines in WIN.INI.
  90.     Each "word" on the line represents a program, which should be
  91.     executed by the shell }
  92.  
  93.   win := TIniFile.Create('win.ini');
  94.   try
  95.     progs := win.ReadString('Windows', 'Load', '');
  96.     while progs > '' do
  97.       ExecuteFile(GetWord(progs), '', '', 'Open', SW_SHOWMINNOACTIVE);
  98.  
  99.     progs := win.ReadString('Windows', 'Run', '');
  100.     while progs > '' do
  101.       ExecuteFile(GetWord(progs), '', '', 'Open', SW_SHOWNORMAL);
  102.   finally
  103.     win.Free;
  104.   end;
  105. end;
  106.  
  107.  
  108. begin
  109.   { Only run one instance of Calmira }
  110.   if HPrevInst <> 0 then begin
  111.     PostMessage(HWND_BROADCAST, WM_CALMIRA, CM_PREVINSTANCE, 0);
  112.     Exit;
  113.   end;
  114.  
  115.   { Disable Windows error messages }
  116.   LastErrorMode := SetErrorMode(SEM_FAILCRITICALERRORS);
  117.   Screen.Cursor := crHourGlass;
  118.  
  119.   LoadSettings;
  120.   LoadResources;
  121.  
  122.   { The Splash form is the main form (!!!) }
  123.   Application.CreateForm(TSplashForm, SplashForm);
  124.  
  125.   with SplashForm do
  126.   if ShowSplash then begin
  127.     Show;
  128.     Update;
  129.   end
  130.   else TotalHide;
  131.  
  132.   { Reset the cursor because TDesktop takes it over now }
  133.   Screen.Cursor := crDefault;
  134.  
  135.   { Create main application components }
  136.   Desktop := TDesktop.Create(Application);
  137.   Desktop.SetCursor(crHourGlass);
  138.   StartMenu := TStartMenu.Create(Application);
  139.   Application.CreateForm(TSysWindow, SysWindow);
  140.   Application.CreateForm(TBin, Bin);
  141.   Application.CreateForm(TProgressBox, ProgressBox);
  142.   Application.CreateForm(TBusyBox, BusyBox);
  143.  
  144.   MsgDlgButtonStyle := bsNew;
  145.   if IsShell then LoadAndRun;
  146.  
  147.   Desktop.Load;
  148.   StartMenu.Load;
  149.   if IsShell or not ShellStartup then StartMenu.RunStartup;
  150.   SetErrorMode(LastErrorMode);
  151.  
  152.   { Hide splash form and free its contents }
  153.   with SplashForm do begin
  154.     TotalHide;
  155.     Panel.Free;
  156.   end;
  157.  
  158.   Desktop.ReleaseCursor;
  159.  
  160.   { Show About box the first time Calmira is run }
  161.   if FirstRun then SysWindow.About.Click;
  162.  
  163.   if LoadTaskbar then
  164.     ExecuteFile(ApplicationPath + 'taskbar.exe', '', '', 'Open', SW_SHOWNORMAL);
  165.  
  166.   if RestoreSys then SysWindow.WindowState := wsNormal;
  167.  
  168.   Application.Run;
  169.  
  170.   { Unload taskbar module }
  171.   if LoadTaskbar and (TaskBarWindow > 0) then
  172.     PostMessage(TaskBarWnd, WM_CALMIRA, CM_UNLOADTASKBAR, 0);
  173. end.
  174.