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

  1. {**************************************************************************}
  2. {                                                                          }
  3. {    Calmira shell for Microsoft« Windows(TM) 3.1                          }
  4. {    Source Release 2.0                                                    }
  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 Shutdown;
  24.  
  25. interface
  26.  
  27. uses WinTypes, WinProcs, Classes, Graphics, Forms, Controls, Buttons,
  28.   StdCtrls, ExtCtrls, Messages;
  29.  
  30. type
  31.   TQuitDlg = class(TForm)
  32.     OKBtn: TBitBtn;
  33.     CancelBtn: TBitBtn;
  34.     rbDOS: TRadioButton;
  35.     rbQuit: TRadioButton;
  36.     rbRestart: TRadioButton;
  37.     rbReboot: TRadioButton;
  38.     Bevel1: TBevel;
  39.     Image1: TImage;
  40.     procedure OKBtnClick(Sender: TObject);
  41.     procedure FormCreate(Sender: TObject);
  42.     procedure FormShow(Sender: TObject);
  43.     procedure rbDOSDblClick(Sender: TObject);
  44.     procedure FormClose(Sender: TObject; var Action: TCloseAction);
  45.     procedure Image1DblClick(Sender: TObject);
  46.   private
  47.     { Private declarations }
  48.   public
  49.     { Public declarations }
  50.   end;
  51.  
  52.  
  53. implementation
  54.  
  55. {$R *.DFM}
  56.  
  57. uses MiscUtil, Settings, Desk, Task, IniFiles;
  58.  
  59. {var QuitDlg: TQuitDlg;}
  60.  
  61.  
  62. procedure TQuitDlg.OKBtnClick(Sender: TObject);
  63. begin
  64.   ShowHourglass;
  65.   Desktop.Save;
  66.   case GetRadioIndex([rbDOS, rbQuit, rbRestart, rbReboot]) of
  67.    0: ExitWindows(0, 0);
  68.    1: Application.Terminate;
  69.    2: ExitWindows(EW_RESTARTWINDOWS, 0);
  70.    3: ExitWindows(EW_REBOOTSYSTEM, 0);
  71.   end;
  72. end;
  73.  
  74. procedure TQuitDlg.FormCreate(Sender: TObject);
  75. begin
  76.   rbQuit.Enabled := not IsShell;
  77. end;
  78.  
  79. procedure TQuitDlg.FormShow(Sender: TObject);
  80. begin
  81.   SetSysModalWindow(Handle);
  82. end;
  83.  
  84. procedure TQuitDlg.rbDOSDblClick(Sender: TObject);
  85. begin
  86.   OKBtn.Click;
  87. end;
  88.  
  89.  
  90. procedure TQuitDlg.FormClose(Sender: TObject; var Action: TCloseAction);
  91. begin
  92.   { After the system modal state, the taskbar needs a nudge to its
  93.     message queue to repaint.  Previously, this was provided naturally
  94.     by the mouse hook, but a bug fix changed PostMessage to SendMessage
  95.     which doesn't have the same effect.  WM_GETTEXTLENGTH is relatively
  96.     harmless! }
  97.  
  98.   PostMessage(TaskBar.Handle, WM_GETTEXTLENGTH, 0, 0);
  99. end;
  100.  
  101. procedure TQuitDlg.Image1DblClick(Sender: TObject);
  102. begin
  103.   with TIniFile.Create('system.ini') do
  104.   begin
  105.     if IsShell then
  106.       WriteString('Boot', 'Shell', 'progman.exe')
  107.     else
  108.       WriteString('Boot', 'Shell', Application.Exename);
  109.     Free;
  110.   end;
  111.   OKBtn.Click;
  112. end;
  113.  
  114. end.
  115.