unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ImgList, ComCtrls, ToolWin, OleCtrls, SHDocVw, StdCtrls, Gauges, Buttons,
ExtCtrls;
type
TForm1 = class(TForm)
ToolBar1: TToolBar;
ToolButton1: TToolButton;
ToolButton2: TToolButton;
ToolButton3: TToolButton;
ToolButton4: TToolButton;
ToolButton5: TToolButton;
ToolButton6: TToolButton;
ToolButton7: TToolButton;
ToolButton8: TToolButton;
ToolButton9: TToolButton;
ImageList1: TImageList;
ImageList2: TImageList;
PageControl1: TPageControl;
WebBrowser1: TWebBrowser;
TabSheet1: TTabSheet;
TabSheet2: TTabSheet;
TabSheet3: TTabSheet;
TreeView1: TTreeView;
TreeView2: TTreeView;
ComboBox1: TComboBox;
ImageList3: TImageList;
GroupBox1: TGroupBox;
Edit1: TEdit;
BitBtn1: TBitBtn;
Splitter1: TSplitter;
BitBtn2: TBitBtn;
Gauge1: TGauge;
procedure ToolButton1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure TreeView1Click(Sender: TObject);
procedure TreeView2Click(Sender: TObject);
procedure TreeView1Expanded(Sender: TObject; Node: TTreeNode);
procedure TreeView2Expanded(Sender: TObject; Node: TTreeNode);
procedure ComboBox1Click(Sender: TObject);
procedure ToolButton3Click(Sender: TObject);
procedure ToolButton4Click(Sender: TObject);
procedure ToolButton6Click(Sender: TObject);
procedure Edit1Change(Sender: TObject);
procedure BitBtn2Click(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
procedure ToolButton9Click(Sender: TObject);
procedure WebBrowser1BeforeNavigate2(Sender: TObject;
const pDisp: IDispatch; var URL, Flags, TargetFrameName, PostData,
Headers: OleVariant; var Cancel: WordBool);
procedure ToolButton7Click(Sender: TObject);
procedure ToolButton10Click(Sender: TObject);
procedure SpeedButton1Click(Sender: TObject);
private
{ Private declarations }
HLIst:TStringList;
historyIndex:integer;
public
{ Public declarations }
end;
procedure ShowTest(a:TComponent);
external 'data\test.dll';
var
Form1: TForm1;
sum,ii:word;
tf:TSearchRec;
implementation
uses Unit2;
{$R *.DFM}
//Êëèê ïî TreeView
procedure ClickTreeView(tr:TTreeView;W:TWebBrowser;Path:ShortString);
begin
if (Tr.Selected.AbsoluteIndex<>-1)then
if fileexists(Path+inttostr(Tr.Selected.AbsoluteIndex)+'.teor')then
begin
W.Navigate(W.Path+Path+inttostr(Tr.Selected.AbsoluteIndex)+'.teor');
end;
end;
procedure ExpandedTreeView(tr:TTreeView);
var i:word;
begin
if (Tr.Items.Item[Tr.Selected.AbsoluteIndex].Expanded=true) then
for i:=0 to Tr.Items.Count-1 do
if (i<>Tr.Selected.AbsoluteIndex)and(Tr.Items.Item[i].Count>0) then
begin
Tr.Items.Item[i].ImageIndex:=0;
Tr.Items.Item[i].SelectedIndex:=0;
end;
if (Tr.Items.Item[Tr.Selected.AbsoluteIndex].Expanded=true) then
begin
Tr.Items.Item[Tr.Selected.AbsoluteIndex].ImageIndex:=2;
Tr.Items.Item[Tr.Selected.AbsoluteIndex].SelectedIndex:=2;
end;
Tr.Repaint;
end;
procedure TForm1.ToolButton1Click(Sender: TObject);
begin
PageControl1.Visible:=not PageControl1.Visible;
end;
procedure TForm1.FormCreate(Sender: TObject);
var i:Shortint;j:word;
begin
sum:=0;
Findfirst('data\teor\*.teor',0,tf);
repeat
j:=FindNext(tf);
sum:=sum+1;
until j<>0;
Findclose(tf);
Gauge1.MaxValue:=sum;
ii:=0;
HLIst:=TStringList.Create;
historyIndex:=-1;
if fileexists('data\taps\tap.mzm') then TreeView2.LoadFromFile('data\taps\tap.mzm')
else
begin
showmessage('Áèáëåîòåêà íå íàéäåíà. Ðàáîòà áóäåò çàâåðøåíà');
halt;
end;
if fileexists('data\teor\neg.mzm') then TreeView1.LoadFromFile('data\teor\neg.mzm')
else
begin
showmessage('Áèáëåîòåêà íå íàéäåíà. Ðàáîòà áóäåò çàâåðøåíà');
halt;
end;
if fileexists('data\term\ter.mzm') then ComboBox1.Items.LoadFromFile('data\term\ter.mzm')
else
begin
showmessage('Áèáëåîòåêà íå íàéäåíà. Ðàáîòà áóäåò çàâåðøåíà');
halt;
end;
//Ìàçìóí
for i:=0 to TreeView1.Items.Count-1 do
begin
if TreeView1.Items.Item[i].Count=0 then
begin
TreeView1.Items[i].ImageIndex:=1;
TreeView1.Items[i].SelectedIndex:=1;
end;
end;
//Òàïñûðìà
for i:=0 to TreeView2.Items.Count-1 do
begin
if TreeView2.Items.Item[i].Count=0 then
begin
TreeView2.Items[i].ImageIndex:=1;
TreeView2.Items[i].SelectedIndex:=1;
end;
end;
if FileExists(WebBrowser1.Path+'data\teor\t0.teor')then
WebBrowser1.Navigate(WebBrowser1.Path+'data\teor\t0.teor');
end;
procedure TForm1.TreeView1Click(Sender: TObject);
begin
ClickTreeView(TreeView1,WebBrowser1,'data\teor\t');
end;
procedure TForm1.TreeView2Click(Sender: TObject);
begin
ClickTreeView(TreeView2,WebBrowser1,'data\taps\l');
end;
procedure TForm1.TreeView1Expanded(Sender: TObject; Node: TTreeNode);
begin
ExpandedTreeView(TreeView1);
end;
procedure TForm1.TreeView2Expanded(Sender: TObject; Node: TTreeNode);
begin
ExpandedTreeView(TreeView2);
end;
procedure TForm1.ComboBox1Click(Sender: TObject);
begin
if (ComboBox1.ItemIndex<>-1)then
if fileexists('data\term\ter'+inttostr(ComboBox1.ItemIndex)+'.teor')then
begin
WebBrowser1.Navigate(WebBrowser1.Path+'data\term\ter'+inttostr(ComboBox1.ItemIndex)+'.teor');
end;
end;
procedure TForm1.ToolButton3Click(Sender: TObject);
begin
//Íàçàä
try
WebBrowser1.GoBack;
except
ToolButton3.Enabled:=false;
end;
end;
procedure TForm1.ToolButton4Click(Sender: TObject);
begin
//Ïåðåä
try
WebBrowser1.GoForward;
except
ToolButton4.Enabled:=false;
end;
end;
procedure TForm1.ToolButton6Click(Sender: TObject);
begin
try
WebBrowser1.ExecWB(OLECMDID_PRINT,1);
except
ShowMessage('Íåèçâåñòíàÿ îøèáêà!');
end;
end;
procedure TForm1.Edit1Change(Sender: TObject);
begin
ii:=0;
Gauge1.Progress:=ii;
BitBtn2.Show;
BitBtn1.hide;
end;
procedure TForm1.BitBtn2Click(Sender: TObject);
begin
BitBtn1.Show;
BitBtn2.hide;
Findfirst('data\teor\*.teor',0,tf);
ii:=0;
BitBtn1Click(Sender);
end;
procedure TForm1.BitBtn1Click(Sender: TObject);
var j:word;
f:TextFile;
s:string;
begin
Screen.Cursor:=crHourGlass;
repeat
Gauge1.Progress:=ii;
ii:=ii+1;
//if FileExists('data\teor\'+tf.Name)then
begin
AssignFile(f,'data\teor\'+tf.Name);reset(f);
repeat
readln(f,s);
for j:=1 to length(s)do
if Edit1.Text=copy(s,j,length(Edit1.Text))then
begin
Screen.Cursor:=crDefault;
WebBrowser1.Navigate(WebBrowser1.Path+'data\teor\'+tf.Name);
CloseFile(f);
Findnext(tf);
exit;
end;
until eof(f);
CloseFile(f);
Findnext(tf);
end;
until ii>sum;
FindClose(tf);
Screen.Cursor:=crDefault;
BitBtn2.Show;
BitBtn1.hide;
showmessage('Ïîèñê çàâåðøåí! ң'+Edit1.Text+'ң íå íàéäåí.' );
end;
procedure TForm1.ToolButton9Click(Sender: TObject);
begin
form2.ShowModal;
end;
procedure TForm1.WebBrowser1BeforeNavigate2(Sender: TObject;
const pDisp: IDispatch; var URL, Flags, TargetFrameName, PostData,
Headers: OleVariant; var Cancel: WordBool);
var NewIndex:integer;
begin
NewIndex:=HLIst.IndexOf(URL);
if NewIndex = -1 then
begin
if (historyIndex >= 0) and (historyIndex < HLIst.Count - 1) then
while HLIst.Count-1 > historyIndex do
HList.Delete(HistoryIndex);
HistoryIndex := HList.Add(URL);
end
else
HistoryIndex := NewIndex;
//My
if HList.Count > 0 then
ToolButton3.Enabled := HistoryIndex > 0
else
ToolButton3.Enabled := False;
if HList.Count > 0 then
ToolButton4.Enabled := HistoryIndex < HList.Count-1
else
ToolButton4.Enabled := False;
end;
procedure TForm1.ToolButton7Click(Sender: TObject);
begin
hide;
ShowTest(Self);
show;
end;
procedure TForm1.ToolButton10Click(Sender: TObject);
begin
Close;
end;
procedure TForm1.SpeedButton1Click(Sender: TObject);
begin
ToolBar1.Visible:=not ToolBar1.Visible;
end;
end.
|