delphi 一起解剖灰鸽子VIP1.2源码4_92shopping.tk_百度空间
图片:

我们继续分解 看系统设置框的代码

unit SysInf;

interface

uses
   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
   Dialogs, DynamicSkinForm, SkinCtrls, StdCtrls, SkinBoxCtrls, ComCtrls,
   SkinTabs, Mask,mmsystem, LangFrm;

type
   TSysShezhi = class(TLangForm)
PageControl1: TspSkinPageControl;
spDynamicSkinForm1: TspDynamicSkinForm;
TabSheet1: TspSkinTabSheet;
RadioBox1: TspSkinCheckRadioBox;
Label1: TspSkinStdLabel;
Label2: TspSkinStdLabel;
Label3: TspSkinStdLabel;
Label5: TspSkinStdLabel;
Label4: TspSkinStdLabel;
Button1: TspSkinButton;
Button2: TspSkinButton;
Button3: TspSkinButton;
Button4: TspSkinButton;
Button5: TspSkinButton;
FilenameEdit1: TspSkinEdit;
FilenameEdit2: TspSkinEdit;
FilenameEdit3: TspSkinEdit;
FilenameEdit4: TspSkinEdit;
FilenameEdit5: TspSkinEdit;
OpenDialog1: TOpenDialog;
TabSheet2: TspSkinTabSheet;
Label6: TspSkinStdLabel;
TimerEdit: TspSkinEdit;
Label7: TspSkinStdLabel;
spSkinStdLabel3: TspSkinStdLabel;
Label8: TspSkinStdLabel;
PortEdit: TspSkinEdit;
Button6: TspSkinButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
procedure FilenameEdit1Change(Sender: TObject);
procedure FilenameEdit2Change(Sender: TObject);
procedure FilenameEdit3Change(Sender: TObject);
procedure FilenameEdit4Change(Sender: TObject);
procedure FilenameEdit5Change(Sender: TObject);
procedure RadioBox1Click(Sender: TObject);
procedure FilenameEdit1ButtonClick(Sender: TObject);
procedure FilenameEdit2ButtonClick(Sender: TObject);
procedure FilenameEdit3ButtonClick(Sender: TObject);
procedure FilenameEdit4ButtonClick(Sender: TObject);
procedure FilenameEdit5ButtonClick(Sender: TObject);
procedure Button6Click(Sender: TObject);
   private
{ Private declarations }
   public
{ Public declarations }
   end;

var
   SysShezhi: TSysShezhi;

implementation
uses
   Main;
{$R *.dfm}
//这几个按钮是播放声音的,有没有发现,每次都要播放一次空文件?
//做用什么?不太明白,不管它,反正知道怎么用就好了
procedure TSysShezhi.Button1Click(Sender: TObject);
begin
try
sndplaysound('',snd_async);
sndplaysound(Pchar(FilenameEdit1.Text),snd_async);
except
end;
end;

procedure TSysShezhi.Button2Click(Sender: TObject);
begin
try
sndplaysound('',snd_async);
sndplaysound(Pchar(FilenameEdit2.Text),snd_async);
except
end;
end;

procedure TSysShezhi.Button3Click(Sender: TObject);
begin
try
sndplaysound('',snd_async);
sndplaysound(Pchar(FilenameEdit3.Text),snd_async);
except
end;
end;

procedure TSysShezhi.Button4Click(Sender: TObject);
begin
try
sndplaysound('',snd_async);
sndplaysound(Pchar(FilenameEdit4.Text),snd_async);
except
end;
end;

procedure TSysShezhi.Button5Click(Sender: TObject);
begin
try
sndplaysound('',snd_async);
sndplaysound(Pchar(FilenameEdit5.Text),snd_async);
except
end;
end;
   //当输入框有变化的时候,写入配置文件
procedure TSysShezhi.FilenameEdit1Change(Sender: TObject);
begin
try
   HgzVip.Myinifile.writestring('Operation', 'Sound1', FilenameEdit1.Text);
   HgzVip.OnSLine:= FilenameEdit1.Text;
except
end;
end;

procedure TSysShezhi.FilenameEdit2Change(Sender: TObject);
begin
try
   HgzVip.Myinifile.writestring('Operation', 'Sound2', FilenameEdit2.Text);
   HgzVip.OffSLine:=FilenameEdit2.Text;
except
end;
end;

procedure TSysShezhi.FilenameEdit3Change(Sender: TObject);
begin
try
   HgzVip.Myinifile.writestring('Operation', 'Sound3', FilenameEdit3.Text);
   HgzVip.UpIPok:=FilenameEdit3.Text;
except
end;
end;

procedure TSysShezhi.FilenameEdit4Change(Sender: TObject);
begin
try
   HgzVip.Myinifile.writestring('Operation', 'Sound4', FilenameEdit4.Text);
   HgzVip.FileSup:=FilenameEdit4.Text;
except
end;
end;

procedure TSysShezhi.FilenameEdit5Change(Sender: TObject);
begin
try
   HgzVip.Myinifile.writestring('Operation', 'Sound5', FilenameEdit5.Text);
   HgzVip.FileSDown:= FilenameEdit5.Text;
except
end;
end;
//这里是判断打勾与否,然后改变HgzVip.isSound:=True;的值,
//顺便把播放声音与否的选项配置写进配置文件里
procedure TSysShezhi.RadioBox1Click(Sender: TObject);
begin
if RadioBox1.Checked then
   begin
   HgzVip.isSound:=True;
   HgzVip.Myinifile.writestring('Operation', 'OnSound','1')
   end else begin
   HgzVip.isSound:=True;
   HgzVip.Myinifile.writestring('Operation', 'OnSound','0');
   end;
end;
   //这个是点击文本框右边的按钮事件,打开一个打开文件框 选定一个文件
procedure TSysShezhi.FilenameEdit1ButtonClick(Sender: TObject);
begin
if OpenDialog1.Execute then
FilenameEdit1.Text:=OpenDialog1.FileName;
end;

procedure TSysShezhi.FilenameEdit2ButtonClick(Sender: TObject);
begin
if OpenDialog1.Execute then
FilenameEdit2.Text:=OpenDialog1.FileName;
end;

procedure TSysShezhi.FilenameEdit3ButtonClick(Sender: TObject);
begin
if OpenDialog1.Execute then
FilenameEdit3.Text:=OpenDialog1.FileName;
end;

procedure TSysShezhi.FilenameEdit4ButtonClick(Sender: TObject);
begin
if OpenDialog1.Execute then
FilenameEdit4.Text:=OpenDialog1.FileName;
end;

procedure TSysShezhi.FilenameEdit5ButtonClick(Sender: TObject);
begin
if OpenDialog1.Execute then
FilenameEdit5.Text:=OpenDialog1.FileName;
end;
//这个是 系统设置 里的设置按钮点击事件
//
procedure TSysShezhi.Button6Click(Sender: TObject);
var
   ii: string;
begin
try
   HgzVip.Myinifile.writestring('Operation', 'TimerOut', TimerEdit.Text);
   HgzVip.Timer4.Interval:=Strtoint(TimerEdit.Text);
except
   HgzVip.Timer4.Interval:=Strtoint(TimerEdit.Text);
   TimerEdit.Text:='20000';
end;
   try
   //获取配置文件里的相应字段值
II:=HgzVip.Myinifile.Readstring('LocalPort', 'AutoSxport', '80');
if ii<> PortEdit.text then //如果和输入框的值不一样 就做更改
begin
   HgzVip.AutoSxport:=StrtoInt(portEdit.text);
   HgzVip.Myinifile.writestring('LocalPort', 'AutoSxport',portEdit.text);
try //并且还要改变本地的灰鸽子客户端的服务端口 让它立时生效
   HgzVip.IdTCPServer1.Active :=False;   //先停服务
   HgzVip.IdTCPServer1.Bindings.Clear;   //端口信息清掉
   HgzVip.IdTCPServer1.DefaultPort :=HgzVip.AutoSxport;   //改端口
   HgzVip.IdTCPServer1.Active :=True; //开服务
except
   Showmessage(Translate('ZhuanTai81','修改自动上线端口失败!无法打开端口: ')+inttostr(HgzVip.AutoSxport));
end;
   Showmessage(Translate('ZhuanTai82','修改自动上线端口成功!'));
   HgzVip.SportEdit.Text := portEdit.text;
end;
   except   //异常处理
Showmessage(Translate('ZhuanTai83','修改自动上线端口失败!'));
   end;
end;

end.


//总的来说这个单元没有太高深的技术要点,主要是配置信息的更改 配置文件的读写操作
//不过TimerEdit: TspSkinEdit; 类型的控件倒是有意思,里面有一个属性 bottenmode 当这个属性为true时会右边出现一个按钮,并且可以触发按钮事件。否则就是一个普通的文本框了
//这里可以学习的是 打开文件控件 OpenDialog1: TOpenDialog;的一个使用方法

procedure TSysShezhi.FilenameEdit1ButtonClick(Sender: TObject);
begin
if OpenDialog1.Execute then
FilenameEdit1.Text:=OpenDialog1.FileName;
end;

看到了么,打开本地文件 返回路径+文件名其实就这么简单。

//还有一个可以学习的地方 就是 spDynamicSkinForm1: TspDynamicSkinForm;皮肤控件啦,其实每个使用皮肤的窗口都有一个这样的控件,这个控件里的SkinData属性要指向HgzVip.spSkinData1 就可以让这个窗口的风格皮肤和HgzVip 一致了。所以说 ,所有的其他窗体 都有一个这样的控件,属性也这样设置,这样就可以和主窗体保持一直的风格哦。


郑重声明:资讯 【delphi 一起解剖灰鸽子VIP1.2源码4_92shopping.tk_百度空间】由 发布,版权归原作者及其所在单位,其原创性以及文中陈述文字和内容未经(企业库qiyeku.com)证实,请读者仅作参考,并请自行核实相关内容。若本文有侵犯到您的版权, 请你提供相关证明及申请并与我们联系(qiyeku # qq.com)或【在线投诉】,我们审核后将会尽快处理。
—— 相关资讯 ——