?? frmtp.pas
字號:
unit frmtp;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Menus, ExtCtrls, Buttons, ComCtrls, StdCtrls, myedit, Spin, mycomm;
type
Tfrmtpsend = class(TForm)
Panel1: TPanel;
MainMenu1: TMainMenu;
N1: TMenuItem;
tpnewfile: TMenuItem;
tpopenfile: TMenuItem;
tpsavefile: TMenuItem;
tpsaveas: TMenuItem;
tpclosefile: TMenuItem;
N7: TMenuItem;
tpexit: TMenuItem;
tpsend: TMenuItem;
Panel2: TPanel;
stpnew: TSpeedButton;
stpopen: TSpeedButton;
stpsave: TSpeedButton;
stpclose: TSpeedButton;
screenstart: TSpeedButton;
screenend: TSpeedButton;
screenfront: TSpeedButton;
screenback: TSpeedButton;
stpsend: TSpeedButton;
scom1: TSpeedButton;
scom2: TSpeedButton;
tpedit: TRichEdit;
StatusBar1: TStatusBar;
OpenDialog1: TOpenDialog;
SaveDialog1: TSaveDialog;
pcom1: TMenuItem;
pcom2: TMenuItem;
Label1: TLabel;
Label5: TLabel;
dispcolor: TComboBox;
Comdispmode: TComboBox;
Label2: TLabel;
Comhidemode: TComboBox;
Label3: TLabel;
Label4: TLabel;
Label6: TLabel;
Combofont: TComboBox;
Label7: TLabel;
Combosize: TComboBox;
Bevel1: TBevel;
myedit1: Tmyedit;
Label8: TLabel;
Combospeed: TComboBox;
timecheck: TCheckBox;
Label9: TLabel;
Edit2: TEdit;
Label10: TLabel;
Comscreenno: TComboBox;
Button1: TButton;
SpeedButton1: TSpeedButton;
SpeedButton2: TSpeedButton;
ProgressBar1: TProgressBar;
SpinEdit1: TSpinEdit;
CheckItalic: TCheckBox;
CheckBold: TCheckBox;
CheckUnderline: TCheckBox;
CheckStrikeOut: TCheckBox;
SpeedButton3: TSpeedButton;
Bevel2: TBevel;
SpeedButton4: TSpeedButton;
N2: TMenuItem;
djs: TCheckBox;
Label11: TLabel;
mycomm1: Tmycomm;
Label12: TLabel;
Label13: TLabel;
Label14: TLabel;
SpinEdit2: TSpinEdit;
SpinEdit3: TSpinEdit;
Label15: TLabel;
Label16: TLabel;
Label17: TLabel;
SpinEdit4: TSpinEdit;
SpinEdit5: TSpinEdit;
Label18: TLabel;
ComboBox1: TComboBox;
procedure FormCreate(Sender: TObject);
procedure tpeditChange(Sender: TObject);
procedure screenstartClick(Sender: TObject);
procedure screenendClick(Sender: TObject);
procedure screenfrontClick(Sender: TObject);
procedure screenbackClick(Sender: TObject);
procedure ComdispmodeChange(Sender: TObject);
procedure tpnewfileClick(Sender: TObject);
procedure tpopenfileClick(Sender: TObject);
procedure tpsavefileClick(Sender: TObject);
procedure tpsaveasClick(Sender: TObject);
procedure tpclosefileClick(Sender: TObject);
procedure tpsendClick(Sender: TObject);
procedure scom1Click(Sender: TObject);
procedure scom2Click(Sender: TObject);
procedure tpexitClick(Sender: TObject);
procedure dispcolorDrawItem(Control: TWinControl; Index: Integer;
Rect: TRect; State: TOwnerDrawState);
procedure dispcolorChange(Sender: TObject);
procedure ComhidemodeChange(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure CombofontChange(Sender: TObject);
procedure CombosizeChange(Sender: TObject);
procedure CombospeedChange(Sender: TObject);
procedure tpeditEnter(Sender: TObject);
procedure myedit1DblClick(Sender: TObject);
procedure myedit1mouseup(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure myedit1Click(Sender: TObject);
procedure Edit2KeyUp(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure SpeedButton1Click(Sender: TObject);
procedure tpeditKeyUp(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure tpeditMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure tpeditKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure SpinEdit1Change(Sender: TObject);
procedure CheckItalicClick(Sender: TObject);
procedure CheckBoldClick(Sender: TObject);
procedure CheckUnderlineClick(Sender: TObject);
procedure CheckStrikeOutClick(Sender: TObject);
procedure SpeedButton3Click(Sender: TObject);
procedure SpeedButton4Click(Sender: TObject);
procedure N2Click(Sender: TObject);
procedure SpinEdit2Change(Sender: TObject);
procedure SpinEdit3Change(Sender: TObject);
procedure SpinEdit4Change(Sender: TObject);
procedure SpinEdit5Change(Sender: TObject);
procedure ComboBox1Change(Sender: TObject);
private
tpeditchangflag,modify,copykeyflag:boolean;
com:integer;
SAVETOTALNUM:integer;
tpcounter,tptotal:integer;
dispmode,hidemode,stoptime,movespeed,disptimeh,disptimem,closeh,closem,dweek:array[0..260] of integer;
editselectlen,tpeditpos:longint;
Year, Month, Day, Hour, Min, Sec, MSec,week: Word;
tpfilename,edittxt:string;
procedure setpara;
procedure inittpdata;
procedure initnewtp;
procedure loadtpdata;
procedure savetpfile;
procedure sendtpdata;
procedure sendtpeditdata;
procedure editsenddata;
public
sendbuf:array[0..520] of array[0..255] of array[0..255] of byte;
end;
var
frmtpsend: Tfrmtpsend;
const
TPTOTALNUM=260;
SCREENCOLOR:array[0..2] of int64=($ff,$ff00,$ffff);
bmm:array[0..7] of byte=($80,$40,$20,$10,8,4,2,1);
implementation
uses Unit1, fillcolor, Unit2, nameunit;
{$R *.DFM}
procedure Tfrmtpsend.tpeditKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
var
k,klen:integer;
begin
editselectlen:=tpedit.SelLength;
if editselectlen=0 then
begin
SpeedButton4.Enabled:=false;
SpeedButton3.Enabled:=false;
CheckBold.Enabled:=false;
CheckItalic.Enabled:=false;
CheckUnderline.Enabled:=false;
CheckStrikeOut.Enabled:=false;
end
else
begin
SpeedButton4.Enabled:=true;
SpeedButton3.Enabled:=true;
CheckBold.Enabled:=true;
CheckItalic.Enabled:=true;
CheckUnderline.Enabled:=true;
CheckStrikeOut.Enabled:=true;
end;
if Shift=[ssCtrl] then
begin
if key=byte('V') then copykeyflag:=true
else copykeyflag:=false;
end
else if editselectlen=0 then
begin
copykeyflag:=false;
myedit1.tppos:=tpedit.selstart;
tpeditchangflag:=false;
tpedit.SelAttributes.Color:=SCREENCOLOR[dispcolor.itemindex];
tpedit.SelAttributes.Name:=combofont.text;
val(combosize.Text,klen,k);
tpedit.selattributes.size:=klen;
tpedit.SelAttributes.Style:=[];
{if CheckBold.Checked then tpedit.SelAttributes.Style:= tpedit.SelAttributes.Style+[fsBold];
if CheckItalic.Checked then tpedit.SelAttributes.Style:= tpedit.SelAttributes.Style+[fsItalic];
if CheckUnderline.Checked then tpedit.SelAttributes.Style:= tpedit.SelAttributes.Style+[fsUnderline];
if CheckStrikeOut.Checked then tpedit.SelAttributes.Style:= tpedit.SelAttributes.Style+[fsStrikeOut];}
tpeditchangflag:=true;
modify:=true;
end;
end;
procedure Tfrmtpsend.tpeditMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var
k,k1:integer;
begin
editselectlen:=tpedit.SelLength;
if editselectlen=0 then
begin
tpeditchangflag:=false;
val(combosize.Text,k1,k);
tpedit.SelAttributes.size:=k1;
tpedit.SelAttributes.Name:=combofont.text;
tpedit.SelAttributes.color:=SCREENCOLOR[dispcolor.itemindex];
tpedit.SelAttributes.Style:=[];
{ if CheckBold.Checked then tpedit.SelAttributes.Style:= tpedit.SelAttributes.Style+[fsBold];
if CheckItalic.Checked then tpedit.SelAttributes.Style:= tpedit.SelAttributes.Style+[fsItalic];
if CheckUnderline.Checked then tpedit.SelAttributes.Style:= tpedit.SelAttributes.Style+[fsUnderline];
if CheckStrikeOut.Checked then tpedit.SelAttributes.Style:= tpedit.SelAttributes.Style+[fsStrikeOut];}
tpeditchangflag:=true;
SpeedButton4.Enabled:=false;
SpeedButton3.Enabled:=false;
CheckBold.Enabled:=false;
CheckItalic.Enabled:=false;
CheckUnderline.Enabled:=false;
CheckStrikeOut.Enabled:=false;
end
else
begin
SpeedButton4.Enabled:=true;
SpeedButton3.Enabled:=true;
CheckBold.Enabled:=true;
CheckItalic.Enabled:=true;
CheckUnderline.Enabled:=true;
CheckStrikeOut.Enabled:=true;
end;
myedit1.tppos:=tpedit.selstart;
setpara;
end;
procedure Tfrmtpsend.tpeditChange(Sender: TObject);
var
i,j,colorno,fontnameno:integer;
k,k1,k2,klen,kpos,kcolor:longint;
str1:string;
begin
if tpeditchangflag=false then exit;
myedit1.txt:=tpedit.Text;
k2:=0;
{ if CheckBold.Checked then k2:=k2+$80;
if CheckItalic.Checked then k2:=k2+$40;
if CheckUnderline.Checked then k2:=k2+$20;
if CheckStrikeOut.Checked then k2:=k2+$10;}
val(combosize.Text,k1,k);
klen:=length(tpedit.text);
k:=length(edittxt);
if (klen=k) then
begin
if modify then
myedit1.movepara(myedit1.tppos,editselectlen,tpedit.selstart-editselectlen,dispcolor.itemindex,k1,combofont.ItemIndex,k2)
else
myedit1.movepara(myedit1.tppos,editselectlen,tpedit.selstart,dispcolor.itemindex,k1,combofont.ItemIndex,k2);
tpedit.SelLength:=0;
end
else if copykeyflag then
begin
kpos:=tpedit.selstart;
for i:=kpos+k-klen to kpos-1 do
begin
tpedit.selstart:=i;
tpedit.SelLength:=1;
kcolor:=tpedit.SelAttributes.Color;
k1:=tpedit.SelAttributes.Size;
str1:=tpedit.SelAttributes.name;
k2:=0;
{ if (fsBold in tpedit.SelAttributes.Style) then k2:=k2+$80;
if (fsItalic in tpedit.SelAttributes.Style) then k2:=k2+$40;
if (fsUnderline in tpedit.SelAttributes.Style) then k2:=k2+$20;
if (fsStrikeOut in tpedit.SelAttributes.Style) then k2:=k2+$10;}
colorno:=0;
for j:=0 to 2 do
begin
if kcolor=SCREENCOLOR[j] then
begin
colorno:=j;
break;
end;
end;
fontnameno:=Combofont.Items.Count-1;
for j:=0 to Combofont.Items.Count-1 do
begin
if Combofont.Items.Strings[j]=str1 then
begin
fontnameno:=j;
break;
end;
end;
myedit1.insertpara(i,1,klen,colorno,k1,fontnameno,k2);
end;
tpedit.selstart:=kpos;
end
else
myedit1.changepara(myedit1.tppos,editselectlen,klen,k,dispcolor.itemindex,k1,combofont.ItemIndex,k2);
myedit1.writestr;
editselectlen:=tpedit.SelLength;
edittxt:=tpedit.Text;
myedit1.tppos:=tpedit.selstart;
modify:=false;
setpara;
end;
procedure Tfrmtpsend.tpeditKeyUp(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if myedit1.Tppos<>tpedit.selstart then
begin
modify:=false;
myedit1.tppos:=tpedit.selstart;
setpara;
end;
editselectlen:=tpedit.SelLength;
if editselectlen=0 then
begin
SpeedButton4.Enabled:=false;
SpeedButton3.Enabled:=false;
CheckBold.Enabled:=false;
CheckItalic.Enabled:=false;
CheckUnderline.Enabled:=false;
CheckStrikeOut.Enabled:=false;
end
else
begin
SpeedButton4.Enabled:=true;
SpeedButton3.Enabled:=true;
CheckBold.Enabled:=true;
CheckItalic.Enabled:=true;
CheckUnderline.Enabled:=true;
CheckStrikeOut.Enabled:=true;
end;
end;
procedure Tfrmtpsend.setpara;
begin
tpcounter:=myedit1.Tpcount;
tptotal:=myedit1.tptotal;
myedit1.change;
if tptotal<tpcounter then tpcounter:=tptotal;
if djs.Checked then
begin
comdispmode.itemindex:=dispmode[tpcounter];
comhidemode.itemindex:=hidemode[tpcounter];
SpinEdit1.Value:=stoptime[tpcounter];
combospeed.ItemIndex:=movespeed[tpcounter];
SpinEdit2.Value:=disptimeh[tpcounter];
SpinEdit3.Value:=disptimem[tpcounter];
SpinEdit4.Value:=closeh[tpcounter];
SpinEdit5.Value:=closem[tpcounter];
ComboBox1.ItemIndex:=dweek[tpcounter]
end
else
begin
comdispmode.itemindex:=dispmode[tpcounter];
comhidemode.itemindex:=hidemode[tpcounter];
combospeed.ItemIndex:=movespeed[tpcounter];
SpinEdit1.Value:=stoptime[tpcounter];
SpinEdit2.Value:=0;
SpinEdit3.Value:=0;
SpinEdit4.Value:=0;
SpinEdit5.Value:=0;
ComboBox1.ItemIndex:=0
end;
if tpcounter>0 then SpeedButton1.Enabled:=true
else SpeedButton1.Enabled:=false;
statusbar1.panels[0].text:='第'+inttostr(tpcounter)+'幕';
statusbar1.panels[1].text:='共'+inttostr(tptotal)+'幕';
if tpcounter>0 then
begin
if tptotal=tpcounter then
begin
screenend.enabled:=false;
screenback.enabled:=false;
end
else
begin
screenend.enabled:=true;
screenback.enabled:=true;
end;
if tpcounter<2 then
begin
screenstart.enabled:=false;
screenfront.enabled:=false;
end
else
begin
screenstart.enabled:=true;
screenfront.enabled:=true;
end;
end
else
begin
screenend.enabled:=false;
screenback.enabled:=false;
screenstart.enabled:=false;
screenfront.enabled:=false;
end;
scom1.visible:=false;
scom2.visible:=false;
end;
procedure Tfrmtpsend.screenstartClick(Sender: TObject);
begin
myedit1.Tpcount:=1;
tpedit.SelStart:=myedit1.tppos;
setpara;
end;
procedure Tfrmtpsend.screenendClick(Sender: TObject);
begin
myedit1.Tpcount:=myedit1.tptotal;
tpedit.SelStart:=myedit1.tppos;
setpara;
end;
procedure Tfrmtpsend.screenfrontClick(Sender: TObject);
begin
myedit1.Tpcount:=myedit1.Tpcount-1;
tpedit.SelStart:=myedit1.tppos;
setpara;
end;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -