www.pudn.com > OSD ²âÊÔ³ÌÐò.rar > Unit1.pas


unit Unit1; 
 
interface 
 
uses 
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, 
  Dialogs,  StdCtrls, ActiveX, UnitRmOSD, ExtCtrls, xlOSD, Buttons, 
  ComCtrls; 
 
type 
  TForm1 = class(TForm) 
    OpenDialog1: TOpenDialog; 
    btnCaption: TButton; 
    btnHide: TButton; 
    Memo2: TMemo; 
    edtBitmapFile: TEdit; 
    SpeedButton1: TSpeedButton; 
    Label1: TLabel; 
    GroupBox1: TGroupBox; 
    chbScroll: TCheckBox; 
    cmbScrollStyle: TComboBox; 
    Label2: TLabel; 
    Label3: TLabel; 
    udCaptionX: TUpDown; 
    Edit3: TEdit; 
    udCaptionY: TUpDown; 
    Edit4: TEdit; 
    Label4: TLabel; 
    Label5: TLabel; 
    Label6: TLabel; 
    Edit5: TEdit; 
    udRectx: TUpDown; 
    Label7: TLabel; 
    Edit6: TEdit; 
    udRecty: TUpDown; 
    Label8: TLabel; 
    Edit7: TEdit; 
    udRectWidth: TUpDown; 
    Label9: TLabel; 
    Edit8: TEdit; 
    udRectHeight: TUpDown; 
    GroupBox2: TGroupBox; 
    Label10: TLabel; 
    Edit9: TEdit; 
    udx: TUpDown; 
    Label11: TLabel; 
    Edit10: TEdit; 
    udy: TUpDown; 
    Label12: TLabel; 
    Edit11: TEdit; 
    udWidth: TUpDown; 
    Label13: TLabel; 
    Edit12: TEdit; 
    udHeight: TUpDown; 
    GroupBox3: TGroupBox; 
    Label14: TLabel; 
    Label15: TLabel; 
    Edit13: TEdit; 
    udBitmapx: TUpDown; 
    Edit14: TEdit; 
    udBitmapy: TUpDown; 
    chbUsePanel: TCheckBox; 
    btnShowBitmap: TButton; 
 
    procedure Button2Click(Sender: TObject); 
    procedure FormCreate(Sender: TObject); 
    procedure FormDestroy(Sender: TObject); 
    procedure btnCaptionClick(Sender: TObject); 
    procedure btnHideClick(Sender: TObject); 
    procedure SpeedButton1Click(Sender: TObject); 
    procedure btnShowBitmapClick(Sender: TObject); 
    procedure cmbScrollStyleChange(Sender: TObject); 
  private 
    FxlOSD: TxlOSD; 
  public 
    { Public declarations } 
  end; 
 
var 
  Form1: TForm1; 
  pOSD      : IRmStream; 
 
implementation 
 
 
{$R *.dfm} 
procedure TForm1.Button2Click(Sender: TObject); 
begin 
  if Opendialog1.Execute then 
  begin 
    SetOSDFromFile(Opendialog1.FileName); 
  end; 
end; 
 
 
procedure TForm1.FormCreate(Sender: TObject); 
begin 
  FxlOSD := TxlOSD.Create(self); 
end; 
 
procedure TForm1.FormDestroy(Sender: TObject); 
begin 
  if FxlOSD <> nil then 
    FxlOSD.Free; 
end; 
 
 
procedure TForm1.btnCaptionClick(Sender: TObject); 
var 
  i: Integer; 
begin 
  FxlOSD.Visible := False; 
  FxlOSD.IsShowBitmap := False; 
  if Memo2.Lines.Count > 0 then 
  begin 
    FxlOSD.Caption.Clear; 
    for i := 0 to Memo2.Lines.Count -1 do 
      FxlOSD.Caption.Add(Memo2.Lines.Strings[i]); 
  end; 
 
  FxlOSD.Scrolled := chbScroll.Checked; 
  FxlOSD.IsUsePanel := chbUsePanel.Checked; 
  if cmbScrollStyle.ItemIndex >= 0 then 
  begin 
    case cmbScrollStyle.ItemIndex of 
      0 : FxlOSD.ScrollStyle := ssLeftToRight; 
      1 : FxlOSD.ScrollStyle := ssRightToLeft; 
      2 : FxlOSD.ScrollStyle := ssTopToBottom; 
      3 : FxlOSD.ScrollStyle := ssBottomToTop; 
    end; 
  end; 
  FxlOSD.CaptionX := udCaptionX.Position; 
  FxlOSD.CaptionY := udCaptionY.Position; 
  FxlOSD.Rectx    := udRectx.Position; 
  FxlOSD.Recty    := udRecty.Position; 
  FxlOSD.RectWidth:= udRectWidth.Position; 
  FxlOSD.RectHeight := udRectHeight.Position; 
 
  FxlOSd.X := udx.Position; 
  FxlOSD.Y := udy.Position; 
  FxlOSd.Width := udWidth.Position; 
  FxlOSD.Height := udHeight.Position; 
 
  FxlOSD.BitmapX := udBitmapx.Position; 
  FxlOSD.BitmapY := udBitmapy.Position; 
 
  if edtBitmapFile.Text <> '' then 
    FxlOSD.BitmapFile := edtBitmapFile.Text; 
 
  FxlOSD.Visible := True; 
end; 
 
procedure TForm1.btnHideClick(Sender: TObject); 
begin 
  FxlOSD.Visible := False; 
end; 
 
procedure TForm1.SpeedButton1Click(Sender: TObject); 
begin 
  if Opendialog1.Execute then 
  begin 
    edtBitmapFile.Text := Opendialog1.FileName; 
  end; 
end; 
 
procedure TForm1.btnShowBitmapClick(Sender: TObject); 
begin 
  if edtBitmapFile.Text = '' then Exit; 
  FxlOSD.BitmapFile := edtBitmapFile.Text; 
 
  FxlOSD.Visible := False; 
  FxlOSD.IsShowBitmap := True; 
  FxlOSD.Scrolled := False; 
 
  FxlOSd.X := udx.Position; 
  FxlOSD.Y := udy.Position; 
  FxlOSd.Width := udWidth.Position; 
  FxlOSD.Height := udHeight.Position; 
 
  FxlOSD.BitmapX := udBitmapx.Position; 
  FxlOSD.BitmapY := udBitmapy.Position; 
 
  FxlOSD.Visible := True; 
end; 
 
procedure TForm1.cmbScrollStyleChange(Sender: TObject); 
begin 
  if cmbScrollStyle.ItemIndex >= 0 then 
  begin 
    if FxlOSd <> nil then 
    begin 
      case cmbScrollStyle.ItemIndex of 
        0 : FxlOSD.ScrollStyle := ssLeftToRight; 
        1 : FxlOSD.ScrollStyle := ssRightToLeft; 
        2 : FxlOSD.ScrollStyle := ssTopToBottom; 
        3 : FxlOSD.ScrollStyle := ssBottomToTop; 
      end; 
    end; 
  end; 
end; 
 
end.