Also wenn Du nun einen kompletten Reset Deines Programms willst dann...
Code:
unit Unit1;
interface
uses
Windows, SysUtils, Forms, StdCtrls, Controls, Classes,
ShellAPI; // <- die
Unit ShellAPI wird für ShellExecute benötigt !!!
type
TForm1 = class(TForm)
Button1: TButton;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure Button1Click(Sender: TObject);
end;
var
Form1: TForm1;
Reset: Boolean = FALSE;
implementation
{$R *.dfm}
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
if Reset then begin
ShellExecute(Self.Handle, 'open', PChar(Application.ExeName), '',
PChar(ExtractFilePath(Application.ExeName)), SW_SHOWNORMAL);
Action := caFree;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Reset := TRUE;
Form1.Close();
end;
end.
...ansonsten wenn Du nur die den Index der ListBox zurücksetzen
Code:
if (ListBox.Items.Count > 0) then ListBox.ItemIndex := 0 else ListBox1.ItemIndex := -1;
Wenn es das war was du wolltest