unit Unit2; interface uses Windows, SysUtils, Classes, Graphics, Forms, Controls, Buttons, ExtCtrls, Spin, Dialogs, ImgList, StrUtils, Menus, StdCtrls, ComCtrls; type TOKBottomDlg = class(TForm) Panel1: TPanel; OKBtn: TButton; CancelBtn: TButton; PageControl1: TPageControl; TabSheet1: TTabSheet; Label2: TLabel; Edit1: TEdit; ListBox1: TListBox; PopupMenu1: TPopupMenu; N1: TMenuItem; PopupMenu2: TPopupMenu; MenuItem1: TMenuItem; BitBtn1: TBitBtn; Memo1: TMemo; Label3: TLabel; Edit2: TEdit; GroupBox4: TGroupBox; RadioButton6: TRadioButton; RadioButton7: TRadioButton; RadioButton4: TRadioButton; GroupBox5: TGroupBox; SpinEdit4: TSpinEdit; Label1: TLabel; Edit3: TEdit; procedure FormActivate(Sender: TObject); procedure FormCreate(Sender: TObject); procedure N1Click(Sender: TObject); procedure ListBox1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); procedure MenuItem1Click(Sender: TObject); procedure BitBtn1Click(Sender: TObject); procedure ListBox1MouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure SpinEdit4KeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); procedure ListBox1DblClick(Sender: TObject); private { Private declarations } public { Public declarations } Lb1,Lb2,Li: array [1..10] of TListBox; Tb: array [1..10] of TTabSheet; KolTb: Word; OldX,OldY: Integer; procedure NewTb(S1,S2: String); end; var OKBottomDlg: TOKBottomDlg; implementation uses Unit1; {$R *.dfm} procedure TOKBottomDlg.FormActivate(Sender: TObject); Var i,k,n,p:Word; S,S1:String; begin Memo1.SelectAll; For i:=1 to PageControl1.PageCount-1 do Lb2[i].Clear; if Pos(':',Edit2.Text)>0 then begin i:=1; S:=Edit2.Text; p:=Pos(':',S); While (p>0)and(ip)or(k<1) then k:=p; S1:=LeftStr(S,k-1); if S1>'' then begin n:=StrToInt(S1)-1; Lb2[i].Items.Add(Lb1[i].Items[n]); S:=RightStr(S,Length(S)-k); end else S:=RightStr(S,Length(S)-1); if k=p then i:=i+1; p:=Pos(':',S); end; end; Edit2.Text:=''; PageControl1.TabIndex:=0; Memo1.SetFocus; Edit1.SetFocus; end; procedure TOKBottomDlg.ListBox1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin OldX:=X; OldY:=Y; end; procedure TOKBottomDlg.MenuItem1Click(Sender: TObject); Var i:Integer; begin With PageControl1 do begin i:=0; While i0 then begin Lb1[TabIndex].Cursor:=crHelp; Lb2[TabIndex].Cursor:=crHelp; end; end; procedure TOKBottomDlg.ListBox1MouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); Var n:Integer; S:String; S2: PAnsiChar; begin With (Sender as TListBox) do if Cursor=crHelp then With PageControl1 do begin n:=ItemAtPos(Point(OldX,OldY),True); if not(n<0) then begin n:=StrToInt(LeftStr(Items[n],Pos('.',Items[n])-1))-1; S:=Form1.Direktoria+'\'+Li[TabIndex].Items[n]; if FileExists(S) then begin S:=Form1.Spravka+' '+S; S2:=Addr(S[1]); WinExec(S2,SW_SHOW); end else begin ShowMessage(Li[TabIndex].Items[n]); end; end; Lb1[TabIndex].Cursor:=crDefault; Lb2[TabIndex].Cursor:=crDefault; end; end; procedure TOKBottomDlg.FormClose(Sender: TObject; var Action: TCloseAction); Var i,j:Word; S:String; begin Edit2.Text:=''; For i:=1 to PageControl1.PageCount-1 do begin S:=''; if Lb2[i].Count>0 then For j:=0 to Lb2[i].Count-1 do S:=S+'.'+LeftStr(Lb2[i].Items[j],Pos('.',Lb2[i].Items[j])-1); Edit2.Text:=Edit2.Text+RightStr(S,Length(S)-1)+':'; end; end; procedure TOKBottomDlg.FormCreate(Sender: TObject); var i: Word; F: TextFile; Sp: TSplitter; S,St:String; begin KolTb:=0; OldX:=0; OldY:=0; i:=0; S:=Form1.Direktoria+'\resurs.csv'; if FileExists(S) then begin AssignFile(F,S); Reset(F); while not(Eof(F)) do begin Readln(F,S); if LeftStr(S,Pos(',',S)-1)='Name' then begin i:=0; S:=RightStr(S,Length(S)-Pos(',',S)); BitBtn1.Enabled:=true; KolTb:=KolTb+1; Tb[KolTb]:=TTabSheet.Create(PageControl1); Tb[KolTb].PageControl := PageControl1; Tb[KolTb].Caption :=S; Lb2[KolTb]:=TListBox.Create(Tb[KolTb]); with Lb2[KolTb] do begin Parent:=Tb[KolTb]; Align:=alRight; Width:=Trunc(Tb[KolTb].ClientWidth/2); OnDblClick:=MenuItem1Click; OnMouseDown:=ListBox1MouseDown; OnMouseUp:=ListBox1MouseUp; PopupMenu:=PopupMenu2; MultiSelect:=True; end; Sp:=TSplitter.Create(Tb[KolTb]); Sp.Parent:=Tb[KolTb]; Sp.Align:=alRight; Lb1[KolTb]:=TListBox.Create(Tb[KolTb]); with Lb1[KolTb] do begin Parent:=Tb[KolTb]; Align:=alClient; OnDblClick:=ListBox1DblClick; OnMouseDown:=ListBox1MouseDown; OnMouseUp:=ListBox1MouseUp; PopupMenu:=PopupMenu1; MultiSelect:=True; end; Li[KolTb]:=TListBox.Create(Tb[KolTb]); with Li[KolTb] do begin Parent:=Tb[KolTb]; Visible:=False; end end else begin i:=i+1; St:=LeftStr(S,Pos(',',S)-1); S:=RightStr(S,Length(S)-Pos(',',S)); Lb1[KolTb].Items.Add(IntToStr(i)+'.'+St); Li[KolTb].Items.Add(S); end; end; CloseFile(F); end; end; procedure TOKBottomDlg.NewTb(S1,S2: String); begin end; procedure TOKBottomDlg.SpinEdit4KeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); begin if Key=13 then ModalResult:=mrOk; end; procedure TOKBottomDlg.ListBox1DblClick(Sender: TObject); Var i:Word; begin With PageControl1 do For i:=0 to Lb1[TabIndex].Count-1 do if Lb1[TabIndex].Selected[i] then Lb2[TabIndex].Items.Add(Lb1[TabIndex].Items[i]); end; procedure TOKBottomDlg.N1Click(Sender: TObject); Var i:Word; S:String; begin S:=InputBox('Добавление ','Введите количество ресурсов:',''); if S>'' then For i:=1 to StrToInt(S) do ListBox1DblClick(Sender); end; end.