www.pudn.com > delphi-Sdk3000-ocx.zip > OsdSet.pas, change:2005-05-20,size:9011b


unit OsdSet; 
 
interface 
 
uses 
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, 
  Dialogs, StdCtrls, sdk3000; 
 
type 
  TformOsdSet = class(TForm) 
    GroupBox1: TGroupBox; 
    checkShow1: TCheckBox; 
    editHeight1: TEdit; 
    Label1: TLabel; 
    Label2: TLabel; 
    editWidth1: TEdit; 
    Label4: TLabel; 
    editSpacing1: TEdit; 
    Label5: TLabel; 
    editLeft1: TEdit; 
    Label6: TLabel; 
    editTop1: TEdit; 
    Label7: TLabel; 
    editText1: TEdit; 
    btnFont1: TButton; 
    btnBkColor1: TButton; 
    GroupBox2: TGroupBox; 
    Label3: TLabel; 
    Label8: TLabel; 
    Label9: TLabel; 
    Label10: TLabel; 
    Label11: TLabel; 
    checkShow2: TCheckBox; 
    editHeight2: TEdit; 
    editWidth2: TEdit; 
    editSpacing2: TEdit; 
    editLeft2: TEdit; 
    editTop2: TEdit; 
    btnFont2: TButton; 
    btnBkColor2: TButton; 
    btnOk: TButton; 
    btnCancel: TButton; 
    dlgFont: TFontDialog; 
    dlgColor: TColorDialog; 
    procedure FormShow(Sender: TObject); 
    procedure btnFont1Click(Sender: TObject); 
    procedure btnBkColor1Click(Sender: TObject); 
    procedure btnFont2Click(Sender: TObject); 
    procedure btnBkColor2Click(Sender: TObject); 
    procedure btnOkClick(Sender: TObject); 
    procedure btnCancelClick(Sender: TObject); 
    procedure FormCreate(Sender: TObject); 
  private 
    m_bSetTextColor : Boolean;// 文本OSD颜色是否设置过 
    m_bSetTextFont  : Boolean;// 文本OSD字体是否设置过 
    m_osdText : OSDPARAM;     // 保存字体及颜色设置 
 
    m_bSetDateColor : Boolean;// 文本OSD颜色是否设置过 
    m_bSetDateFont  : Boolean;// 文本OSD字体是否设置过 
    m_osdDate : OSDPARAM;     // 保存字体及颜色设置 
    { Private declarations } 
  public 
    { Public declarations } 
  end; 
 
var 
  formOsdSet: TformOsdSet; 
 
implementation 
 
uses Global; 
 
{$R *.dfm} 
var 
s_osdText : OSDPARAM; 
s_bToShow : Boolean; 
s_ToPoint : TPoint; 
s_bToTransparent : Boolean; 
s_strToText : String; 
 
s_osdDate : OSDPARAM; 
s_bDoShow : Boolean; 
s_DoPoint : TPoint; 
s_bDoTransparent : Boolean; 
 
procedure InitOsdSetGlobal(); 
begin 
    s_osdText.cfHeight := 12; 
    s_osdText.cfWidth := 10; 
    s_osdText.cfWeight := 400; 
    s_osdText.cfSpacing := 0; 
    s_osdText.cfItalic := False; 
    s_osdText.cfUnderline := False; 
    s_osdText.cfStrikeOut := False; 
    s_osdText.cfBkColor := clWhite; 
    s_osdText.cfTextColor := clBlack; 
    s_osdText.cfFaceName := ''; 
    s_bToShow := False;; 
    s_ToPoint.X := 0; 
    s_ToPoint.Y := 0; 
    s_bToTransparent := True; 
    s_strToText := 'Text OSD'; 
 
    s_osdDate.cfHeight := 12; 
    s_osdDate.cfWidth := 10; 
    s_osdDate.cfWeight := 400; 
    s_osdDate.cfSpacing := 0; 
    s_osdDate.cfItalic := False; 
    s_osdDate.cfUnderline := False; 
    s_osdDate.cfStrikeOut := False; 
    s_osdDate.cfBkColor := clWhite; 
    s_osdDate.cfTextColor := clBlack; 
    s_osdDate.cfFaceName := ''; 
    s_bDoShow := False;; 
    s_DoPoint.X := 0; 
    s_DoPoint.Y := 20; 
    s_bDoTransparent := True; 
end; 
 
procedure TformOsdSet.FormCreate(Sender: TObject); 
begin 
    InitOsdSetGlobal(); 
end; 
 
procedure TformOsdSet.FormShow(Sender: TObject); 
begin 
    m_bSetTextColor := False; 
    m_bSetTextFont := False; 
    m_bSetDateColor := False; 
    m_bSetDateFont := False; 
     
    //取得文本OSD信息 
    checkShow1.Checked := s_bToShow; 
    editHeight1.Text := IntToStr(s_osdText.cfHeight); 
    editWidth1.Text := IntToStr(s_osdText.cfWidth); 
    editSpacing1.Text := IntToStr(s_osdText.cfSpacing); 
    editLeft1.Text := IntToStr(s_ToPoint.X); 
    editTop1.Text := IntToStr(s_ToPoint.Y); 
    editText1.Text := s_strToText; 
 
    //取得时间OSD信息 
    checkShow2.Checked :=  s_bDoShow; 
    editHeight2.Text := IntToStr(s_osdDate.cfHeight); 
    editWidth2.Text := IntToStr(s_osdDate.cfWidth); 
    editSpacing2.Text := IntToStr(s_osdDate.cfSpacing); 
    editLeft2.Text := IntToStr(s_DoPoint.X); 
    editTop2.Text := IntToStr(s_DoPoint.Y); 
end; 
 
procedure TformOsdSet.btnFont1Click(Sender: TObject); 
begin 
    dlgFont.Font.Name := s_osdText.cfFaceName; 
    dlgFont.Font.Color := s_osdText.cfTextColor; 
 
    dlgFont.Font.Style := []; 
    If s_osdText.cfItalic Then 
        dlgFont.Font.Style := dlgFont.Font.Style + [fsItalic]; 
    If s_osdText.cfStrikeOut Then 
        dlgFont.Font.Style := dlgFont.Font.Style + [fsStrikeOut]; 
    If s_osdText.cfUnderline Then 
        dlgFont.Font.Style := dlgFont.Font.Style + [fsUnderline]; 
    If s_osdText.cfWeight = 700 Then 
        dlgFont.Font.Style := dlgFont.Font.Style + [fsBold]; 
 
    If dlgFont.Execute() Then 
    begin 
        m_bSetTextFont := True; 
        StrCopy(m_osdText.cfFaceName, PChar(dlgFont.Font.Name)); 
        m_osdText.cfTextColor := dlgFont.Font.Color; 
        m_osdText.cfItalic := (fsItalic in dlgFont.Font.Style); 
        m_osdText.cfStrikeOut := (fsStrikeOut in dlgFont.Font.Style); 
        m_osdText.cfUnderline := (fsUnderline in dlgFont.Font.Style); 
        If fsBold in dlgFont.Font.Style then 
            m_osdText.cfWeight := 700 
        Else 
            m_osdText.cfWeight := 400; 
    end; 
end; 
 
procedure TformOsdSet.btnBkColor1Click(Sender: TObject); 
begin 
    s_bToTransparent := False; 
    dlgColor.Color := s_osdText.cfBkColor; 
    If dlgColor.Execute() Then 
    begin 
        m_bSetTextColor := True; 
        m_osdText.cfBkColor := dlgColor.Color; 
    end 
end; 
 
procedure TformOsdSet.btnFont2Click(Sender: TObject); 
begin 
    dlgFont.Font.Name := s_osdDate.cfFaceName; 
    dlgFont.Font.Color := s_osdDate.cfTextColor; 
 
    dlgFont.Font.Style := []; 
    If s_osdDate.cfItalic Then 
        dlgFont.Font.Style := dlgFont.Font.Style + [fsItalic]; 
    If s_osdDate.cfStrikeOut Then 
        dlgFont.Font.Style := dlgFont.Font.Style + [fsStrikeOut]; 
    If s_osdDate.cfUnderline Then 
        dlgFont.Font.Style := dlgFont.Font.Style + [fsUnderline]; 
    If s_osdDate.cfWeight = 700 Then 
        dlgFont.Font.Style := dlgFont.Font.Style + [fsBold]; 
 
    If dlgFont.Execute() Then 
    begin 
        m_bSetDateFont := True;  
        StrCopy(m_osdDate.cfFaceName, PChar(dlgFont.Font.Name)); 
        m_osdDate.cfTextColor := dlgFont.Font.Color; 
        m_osdDate.cfItalic := (fsItalic in dlgFont.Font.Style); 
        m_osdDate.cfStrikeOut := (fsStrikeOut in dlgFont.Font.Style); 
        m_osdDate.cfUnderline := (fsUnderline in dlgFont.Font.Style); 
        If fsBold in dlgFont.Font.Style then 
            m_osdDate.cfWeight := 700 
        Else 
            m_osdDate.cfWeight := 400; 
    end; 
end; 
 
procedure TformOsdSet.btnBkColor2Click(Sender: TObject); 
begin 
    s_bDoTransparent := False; 
    dlgColor.Color := s_osdDate.cfBkColor; 
    If dlgColor.Execute() Then 
    begin 
        m_bSetDateColor := True; 
        m_osdDate.cfBkColor := dlgColor.Color; 
    end 
end; 
 
procedure TformOsdSet.btnOkClick(Sender: TObject); 
begin 
    //取得新的文本OSD信息 
    s_bToShow := checkShow1.Checked; 
    s_osdText.cfHeight := StrToInt(editHeight1.Text); 
    s_osdText.cfWidth := StrToInt(editWidth1.Text); 
    s_osdText.cfSpacing := StrToInt(editSpacing1.Text); 
    s_ToPoint.X := StrToInt(editLeft1.Text); 
    s_ToPoint.Y := StrToInt(editTop1.Text); 
    s_strToText := editText1.Text; 
 
    If m_bSetTextFont Then 
    begin 
        StrCopy(s_osdText.cfFaceName, m_osdText.cfFaceName); 
        s_osdText.cfTextColor := m_osdText.cfTextColor; 
        s_osdText.cfItalic := m_osdText.cfItalic; 
        s_osdText.cfStrikeOut := m_osdText.cfStrikeOut; 
        s_osdText.cfUnderline := m_osdText.cfUnderline; 
        s_osdText.cfWeight := m_osdText.cfWeight; 
    end; 
 
    If m_bSetTextColor Then 
        s_osdText.cfBkColor := m_osdText.cfBkColor; 
 
    //更新文本OSD 
    VCASetTextOSD(g_nCard, ToVcbool(s_bToShow), PAnsiChar(s_strToText), s_ToPoint, ToVcbool(s_bToTransparent), s_osdText, g_hWnd); 
 
    //取得时间OSD信息 
    s_bDoShow := checkShow2.Checked; 
    s_osdDate.cfHeight := StrToInt(editHeight2.Text); 
    s_osdDate.cfWidth := StrToInt(editWidth2.Text); 
    s_osdDate.cfSpacing := StrToInt(editSpacing2.Text); 
    s_DoPoint.X := StrToInt(editLeft2.Text); 
    s_DoPoint.Y := StrToInt(editTop2.Text); 
 
    If m_bSetDateFont Then 
    begin 
        StrCopy(s_osdDate.cfFaceName, m_osdDate.cfFaceName); 
        s_osdDate.cfTextColor := m_osdDate.cfTextColor; 
        s_osdDate.cfItalic := m_osdDate.cfItalic; 
        s_osdDate.cfStrikeOut := m_osdDate.cfStrikeOut; 
        s_osdDate.cfUnderline := m_osdDate.cfUnderline; 
        s_osdDate.cfWeight := m_osdDate.cfWeight; 
    end; 
 
    If m_bSetDateColor Then 
        s_osdDate.cfBkColor := m_osdDate.cfBkColor; 
         
    //更新时间OSD 
    VCASetDateTimeOSD(g_nCard, ToVcbool(s_bDoShow), s_DoPoint, ToVcbool(s_bDoTransparent), s_osdDate, g_hWnd); 
 
    //关闭此窗口 
    Close(); 
end; 
 
procedure TformOsdSet.btnCancelClick(Sender: TObject); 
begin 
    //关闭此窗口 
    Close(); 
end; 
 
end.