{**************************
Stock script Ver1.0 by snowfox
History:
  2006-06-14: + create this file
**************************}
var
  i: Integer;
  url:string;
  ts1:TTabSheet;
  lblType,lblCode,ReadmeText,ReadmeText2:TLabel;
  cbbType:TComboBox;
  edtCode:TEdit;
  
procedure CreateTab1;
begin
  //--- Tab 1 ---
  ts1:=TTabSheet.Create(pgc);
  ts1.PageControl:=pgc;
  ts1.Caption:='股票设置';
  
	lblType:=TLabel.create(self);
	with lblType do
	begin
    parent:=ts1;
    left:=16; top:=20; width:=60;
    caption:='股票类型：';
	end;
	cbbType:=TComboBox.create(self);
	with cbbType do
	begin
	  parent:=ts1;
	  left:=80; top:=16; width:=145;
    Style:=csDropDownList;
    Items.add('上海股票');
    Items.add('深圳股票');
    ItemIndex:=0;
	end;

	lblCode:=TLabel.create(self);
	with lblCode do
	begin
    parent:=ts1;
    left:=16; top:=60; width:=144;
    caption:='请输入要查询的股票代码：';
	end;
  edtCode:=TEdit.create(self);
  with edtCode do
  begin
    parent:=ts1;
    left:=16; top:=82; width:=113;
  end;
  
  ReadmeText:=TLabel.create(self);
  with ReadmeText do
  begin
    parent:=ts1;
    left:=16; top:=150; width:=200;
    caption:='提示：使用本皮肤需要联网，股价每隔10分钟自动更新。';  
    wordwrap:=True;
    height:=30;    
  end;
  
  ReadmeText2:=TLabel.create(self);
  with ReadmeText2 do
  begin
    parent:=ts1;
    left:=16; top:=190; width:=200;
    caption:='股价信息仅供参考，请以交易所行情为准!';  
    wordwrap:=True;
    height:=30;    
  end;  
end;  
  

//Init Skin form setting
procedure InitSetting;
var
	s:string;
	inifn:TIniFile;
begin
  inifn:=TIniFile.create(SkinFileName);
  with inifn do
  try
    cbbType.ItemIndex:=ReadInteger('system','StockType',0);
    edtCode.text:=ReadString('system','StockCode','');
    
  finally
    inifn.free;
  end;
end;

//save Skin form setting
function SaveSetting:boolean;
var
	s,aPlayer:string;
	inifn:TIniFile;
	i:integer;
	isChange:boolean;
begin
  result:=false;
  inifn:=TIniFile.create(SkinFileName);
  with inifn do
  try
    s:=ReadString('system','StockCode','');
    if (s<>edtCode.text) or (cbbType.ItemIndex<>ReadInteger('system','StockType',0)) then
    begin
      WriteInteger('system','StockType',cbbType.ItemIndex);
      WriteString('system','StockCode',edtCode.text);
		  isChange:=true;
		end;

  finally
    inifn.free;
  end;
  
  if isChange then
  begin
  url:='http://chart.stock.sohu.com/chart/bf/'+inttostr(cbbType.ItemIndex)+'/'+edtCode.text+'.png';
  GetIDHttpFile(url,'SaveFileName='+SkinPath+'Stock.png');
  	result:=true;
    InitSkin; 
    //RefreshSkin;
  end;
end;


begin
  CreateTab1;
  InitSetting;
  
end.