unit locatech;

{$MODE Delphi}

interface

uses
  Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls;

type
  TLocateChoiceForm = class(TForm)
    OkBtn: TButton;
    ListBox1: TListBox;
    procedure OkBtnClick(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
  private
    exIndex:integer;
    Button:integer;
  public
    dev0,ini0:integer;
    capts:TStringList;
    choice:integer;
    Procedure execute;
    //function choice(dev0,ini0:integer; Capts:TstringList):integer;
  end;

var
  LocateChoiceForm: TLocateChoiceForm;

implementation
uses base,base2;
{$R *.lfm}

procedure TLocateChoiceForm.Execute;
begin
   Button:=0;
   Visible:=true;
   with Listbox1 do
      begin
        items.assign(Capts);
        if ini0=0 then
           ItemIndex:=exIndex
        else
           ItemIndex:=ini0-1;
        Height:=Items.Count*itemHeight+4;
      end;
   ClientHeight:=ListBox1.Height+ OkBtn.Height ;
   OkBtn.enabled:=true;
   BringToFront;
   repeat
          sleep(20);
          application.ProcessMessages;
   until Button<>0;
   with ListBox1 do
      begin
        if Button=1 then
           choice := ItemIndex + 1
        else
           choice := 0;
        exIndex:=ItemIndex;
      end;
   OkBtn.enabled:=false;
   Visible:=false;  // 2017.4.7 追加
end;

(*
function TLocateChoiceForm.choice(dev0,ini0:integer;Capts:TstringList):integer;
begin
   controlword:=OriginalCw;   //2014.1.20
   SetFPUMask(OriginalCW);     //2014.1.9
   Button:=0;
   Visible:=true;
   with Listbox1 do
      begin
        items.assign(Capts);
        if ini0=0 then
           ItemIndex:=exIndex
        else
           ItemIndex:=ini0-1;
        Height:=Items.Count*itemHeight+4;
      end;
   ClientHeight:=ListBox1.Height+ OkBtn.Height ;
   OkBtn.enabled:=true;
   BringToFront;
   repeat
          sleep(20);
          application.ProcessMessages;
   until Button<>0;
   with ListBox1 do
      begin
        if Button=1 then
           result := ItemIndex + 1
        else
           result := 0;
        exIndex:=ItemIndex;
      end;
   OkBtn.enabled:=false;
   controlword:= NormalCW;     //2014.1.20
   SetFPUMask(controlword);  //2014.1.9
end;
*)

procedure TLocateChoiceForm.OkBtnClick(Sender: TObject);
begin
    Button:=1;
end;

procedure TLocateChoiceForm.FormClose(Sender: TObject; var Action: TCloseAction);
begin
   Button:=-1;
end;

end.
