{*********************************************************

 SlavaNap source code.

 Copyright 2001,2002 by SlavaNap development team
 Released under GNU General Public License

 Latest version is available at
 http://www.slavanap.org

**********************************************************

 Unit: form

 Main application form
 This form is used only because of MS Windows bug.
 If several forms (in this case ServerForm and SettingsForm)
 override CreateParams procedure, alt-tab switching would
 be incorrect. To fix this I had to create another form,
 make it application's main form and hide it.
 This form also used to detect another SlavaNap instance.  

*********************************************************}
unit form;

interface

uses
  Windows, Messages, SysUtils, Classes2, Graphics, Controls, Forms, Dialogs, ShellApi;

type
  TSlavaNapMain = class(TForm)
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  SlavaNapMain: TSlavaNapMain;

implementation

uses vars;

{$R *.DFM}

procedure TSlavaNapMain.FormCreate(Sender: TObject);
begin
 Caption:='SlavaNap';
end;

procedure TSlavaNapMain.FormDestroy(Sender: TObject);
begin
  Caption:='n/a';
  if not restarting then exit;
  sleep(1000);
  ShellExecute(0,'open',PChar(ParamStr(0)),PChar('-copy'),PChar(ApplicationDir),SW_SHOWNORMAL);
end;

end.
 
