unit SelectCity;

interface

uses
	Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, StdCtrls;

type
	TfrmSelectCity = class(TForm)
		ListBox1: TListBox;
		btnOK: TButton;
		procedure btnOkClick(Sender: TObject);
		procedure ListBox1DblClick(Sender: TObject);
	private
		fSelectedIndex: Integer;
	public
		Property SelectedIndex: Integer read fSelectedIndex;
		function Execute: Boolean;
	end;

var
	frmSelectCity: TfrmSelectCity;

implementation

{$R *.dfm}

function TfrmSelectCity.Execute: Boolean;
begin
	Result := (ShowModal = mrOk);
end;

procedure TfrmSelectCity.btnOkClick(Sender: TObject);
begin
	if ListBox1.ItemIndex = -1 then
		fSelectedIndex := 0
	else
		fSelectedIndex := ListBox1.ItemIndex;
	self.Close;
end;

procedure TfrmSelectCity.ListBox1DblClick(Sender: TObject);
begin
	fSelectedIndex := ListBox1.ItemIndex;
	self.Close;
end;

end.
