unit Unit10;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Menus, VirtualTrees, DTDBTreeView, DTADOTree, ExtCtrls, sPanel,
  sSplitter, OleCtrls, SHDocVw, MSHTML, ShellAPI, MMSystem, ComCtrls,
  StdCtrls, sButton;

type
  TForm10 = class(TForm)
    WebBrowser1: TWebBrowser;
    sSplitter1: TsSplitter;
    sPanel2: TsPanel;
    sPanel1: TsPanel;
    TreeView1: TTreeView;
    MainMenu1: TMainMenu;
    N1: TMenuItem;
    N2: TMenuItem;
    N3: TMenuItem;
    N4: TMenuItem;
    N5: TMenuItem;
    N6: TMenuItem;
    N7: TMenuItem;
    N8: TMenuItem;
    N9: TMenuItem;
    sPanel3: TsPanel;
    sButton1: TsButton;
    sButton2: TsButton;
    procedure FormCreate(Sender: TObject);
    procedure TreeView1Click(Sender: TObject);
    procedure N2Click(Sender: TObject);
    procedure N3Click(Sender: TObject);
    procedure N4Click(Sender: TObject);
    procedure N7Click(Sender: TObject);
    procedure N6Click(Sender: TObject);
    procedure N8Click(Sender: TObject);
    procedure N9Click(Sender: TObject);
    procedure sButton1Click(Sender: TObject);
    procedure sButton2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form10: TForm10;
  s:String;


implementation

uses Datam;

{$R *.dfm}



procedure TForm10.FormCreate(Sender: TObject);
begin
 s:=ExtractFilePath(Application.ExeName);
  WebBrowser1.Navigate(s+'html\Косымша 1.htm');
end;


procedure TForm10.TreeView1Click(Sender: TObject);
begin
WebBrowser1.Navigate(GetCurrentDir+'\html\'+TreeView1.Selected.Text+'.htm');
end;

procedure TForm10.N2Click(Sender: TObject);
var vaIn, vaOut: OleVariant;
begin
  WebBrowser1.ControlInterface.ExecWB(OLECMDID_PRINTPREVIEW,
    OLECMDEXECOPT_PROMPTUSER, vaIn, vaOut);
end;

procedure TForm10.N3Click(Sender: TObject);
var vaIn, vaOut: OleVariant; 
begin
  WebBrowser1.ControlInterface.ExecWB(OLECMDID_PRINT,
      OLECMDEXECOPT_PROMPTUSER,vaIn, vaOut);
end;

procedure TForm10.N4Click(Sender: TObject);
begin
Close;
end;

procedure TForm10.N7Click(Sender: TObject);
begin
WebBrowser1.GoForward;
end;

procedure TForm10.N6Click(Sender: TObject);
begin
WebBrowser1.GoBack;
end;

procedure TForm10.N8Click(Sender: TObject);
begin
     WebBrowser1.Refresh;
end;

procedure TForm10.N9Click(Sender: TObject);
begin
     repeat
           Application.ProcessMessages;
     until WebBrowser1.ReadyState >= READYSTATE_COMPLETE;
     if WebBrowser1.Document <> nil then
     (Webbrowser1.Document as IHTMLDocument2).ParentWindow.Focus;
     keybd_event(VK_CONTROL, MapVirtualKey(VK_CONTROL, 0), 0, 0);
     keybd_event(Ord('F'), MapVirtualKey(Ord('F'), 0), 0, 0);
     keybd_event(Ord('F'), MapVirtualKey(Ord('F'), 0), KEYEVENTF_KEYUP, 0);
     keybd_event(VK_CONTROL, MapVirtualKey(VK_CONTROL, 0), KEYEVENTF_KEYUP, 0)
end;

procedure TForm10.sButton1Click(Sender: TObject);
begin
WebBrowser1.GoBack;
end;

procedure TForm10.sButton2Click(Sender: TObject);
begin
WebBrowser1.GoForward;
end;

end.
