home *** CD-ROM | disk | FTP | other *** search
/ PC Open 19 / pcopen19.iso / Zipped / CALMIR21.ZIP / SOURCE.ZIP / SRC / CALMIRA.DPR < prev    next >
Encoding:
Text File  |  1998-02-20  |  6.1 KB  |  186 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. 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.   Compsys in 'COMPSYS.PAS' {Computer},
  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.   Iconic in 'ICONIC.PAS' {Iconic classes},
  54.   FileMan in 'FILEMAN.PAS' {File management},
  55.   Resource in 'RESOURCE.PAS' {Resources},
  56.   Directry in 'DIRECTRY.PAS' {Directories},
  57.   Settings in 'SETTINGS.PAS' {Settings},
  58.   Iconwin in 'ICONWIN.PAS' {Icon Windows},
  59.   Start in 'START.PAS' {Start Menu},
  60.   Progconv in 'PROGCONV.PAS' {Convert Dialog},
  61.   Referenc in 'REFERENC.PAS' {References},
  62.   Alias in 'ALIAS.PAS' {Aliases},
  63.   Tree in 'TREE.PAS' {Explorer},
  64.   Shutdown in 'SHUTDOWN.PAS' {Shutdown dialog},
  65.   Calform in 'CALFORM.PAS' {Modeless windows},
  66.   Fourdos in 'FOURDOS.PAS' {4DOS descriptions},
  67.   Refedit in 'REFEDIT.PAS' {Reference editor},
  68.   Menuedit in 'MENUEDIT.PAS' {Menu editor},
  69.   Strtprop in 'STRTPROP.PAS' {Start Properties},
  70.   Deskprop in 'DESKPROP.PAS' {Desktop Properties},
  71.   Binprop in 'BINPROP.PAS' {Bin Properties},
  72.   Taskprop in 'TASKPROP.PAS' {Taskbar Properties},
  73.   Sysprop in 'SYSPROP.PAS' {System Properties},
  74.   Fsysprop in 'FSYSPROP.PAS' {File System Props},
  75.   Askdrop in 'ASKDROP.PAS' {Ask Drop},
  76.   Select in 'SELECT.PAS' {Select File Dialog},
  77.   Tips in 'TIPS.PAS' {Tips of the Day},
  78.   Locale in 'LOCALE.PAS',
  79.   Task in 'TASK.PAS' {Taskbar},
  80.   Incsrch in 'INCSRCH.PAS' {Incremental Search},
  81.   Hooks in 'HOOKS.PAS' {Windows hooks},
  82.   CalMsgs in 'CALMSGS.PAS';
  83.  
  84. {$R *.RES}
  85.  
  86. {$D Calmira Source Release 2.0}
  87.  
  88. procedure LoadAndRun;
  89. var
  90.   s : string;
  91.   i : Integer;
  92. begin
  93.   { Reads and processes the Load= and Run= lines in WIN.INI.
  94.     Each "word" on the line represents a program, which should be
  95.     executed by the shell }
  96.  
  97.   with TIniFile.Create('win.ini') do
  98.   try
  99.     s := ReadString('Windows', 'Load', '');
  100.     while s > '' do
  101.       DefaultExec(GetWord(s, ' '), '', '', SW_SHOWMINNOACTIVE);
  102.  
  103.     s := ReadString('Windows', 'Run', '');
  104.     while s > '' do
  105.       DefaultExec(GetWord(s, ' '), '', '', SW_SHOWNORMAL);
  106.   finally
  107.     Free;
  108.   end;
  109.  
  110.   if ParamCount >= 1 then begin
  111.     s := '';
  112.     for i := 2 to ParamCount do AppendStr(s, ParamStr(i));
  113.     DefaultExec(ParamStr(1), s, '', SW_SHOW);
  114.   end;
  115. end;
  116.  
  117.  
  118. begin
  119.   { Only run one instance of Calmira }
  120.   if HPrevInst <> 0 then begin
  121.     PostMessage(HWND_BROADCAST, WM_CALMIRA, CM_PREVINSTANCE, 0);
  122.     Exit;
  123.   end;
  124.  
  125.   { Disable Windows error messages }
  126.   LastErrorMode := SetErrorMode(SEM_FAILCRITICALERRORS);
  127.   Screen.Cursor := crHourGlass;
  128.  
  129.   LoadSettings;
  130.   LoadResources;
  131.  
  132.   { The Splash form is the main form (!!!) }
  133.   Application.CreateForm(TSplashForm, SplashForm);
  134.   with SplashForm do
  135.   if ShowSplash then begin
  136.     Show;
  137.     Update;
  138.   end
  139.   else TotalHide;
  140.  
  141.   { Reset the cursor because TDesktop takes it over now }
  142.   Screen.Cursor := crDefault;
  143.  
  144.   { Create main application components -- the ordering is significant! }
  145.   Desktop := TDesktop.Create(Application);
  146.   Desktop.SetCursor(crHourGlass);
  147.   StartMenu := TStartMenu.Create(Application);
  148.   Application.CreateForm(TComputer, Computer);
  149.   Application.CreateForm(TBin, Bin);
  150.   Application.CreateForm(TProgressBox, ProgressBox);
  151.   Application.CreateForm(TTaskbar, Taskbar);
  152.   Taskbar.Update;
  153.  
  154.   MsgDlgButtonStyle := bsNew;
  155.  
  156.   Desktop.Load;
  157.   StartMenu.Load;
  158.  
  159.   SetErrorMode(LastErrorMode);
  160.  
  161.   SplashForm.TotalHide;
  162.  
  163.   Desktop.ReleaseCursor;
  164.  
  165.   ModulesLoaded;
  166.  
  167.   if IsShell then LoadAndRun;
  168.  
  169.   if (IsShell or (not ShellStartup)) and
  170.     (GetAsyncKeyState(VK_SHIFT) >= 0) then StartMenu.RunStartup;
  171.  
  172.   { Show About box the first time Calmira is run }
  173.  
  174.   if FirstRun then Computer.About.Click;
  175.  
  176.   if ShowDailyTips and
  177.     (DateToStr(Date) <> ini.ReadString('Calmira', 'DateLastRun', '')) then
  178.     ShowModalDialog(TTipDialog);
  179.  
  180.   if RestoreSys then Computer.WindowState := wsNormal;
  181.  
  182.   Application.Run;
  183.  
  184.   if IsShell then ExitWindows(0, 0);
  185. end.
  186.