
procedure lblClockPropertiesOnClick;
begin
  ShellExecute(0,'open','RunDLL32.exe','Shell32.dll,Control_RunDLL TimeDate.cpl,,0','',1);
end;

{procedure chkShowCaptionClick;
begin
  edtCaption.Enabled:=not chkShowCaption.checked;
end;}

procedure chkShowCaptionClick(sender);
begin
  edtCaption.Enabled:=not chkShowCaption.checked;
end;

procedure InitTimeZone;
var
  fn:string;
  //lst:TStrings;
  //i:integer;
  inifn:TIniFile;
begin
  fn:=WidgetPath+'TimeZone.dat';
  if FileExists(fn) then
  begin
  	inifn:=TIniFile.Create(fn);
	  try
	    inifn.ReadSection('TimeZone',cbbTimeZone.Items);
    finally
  	  inifn.free;
  	end;
  end;
end;

procedure InitIni;
begin
  chkShowCaption.checked:=GetSettingInt('ShowCaption',0)=1;
  edtCaption.Enabled:=chkShowCaption.checked;
  edtCaption.text:=GetSetting('Caption','中  国');
  cbbTimeZone.ItemIndex:=GetSettingInt('TimeZoneIndex',39);
  chkisFlicker.checked:=GetSettingInt('isFlicker',1)=1;
  chkis24Hour.checked:=GetSettingInt('is24Hour',1)=1;
  chkisFullHourPlay.checked:=GetSettingInt('isFullHourPlay',1)=1;
  chkisHalfHourPlay.checked:=GetSettingInt('isHalfHourPlay',1)=1;
  chkCustomColor.checked:=GetSettingInt('CustomColor',0)=1;
  edtColor.text:=GetSetting('Color','$C08080');
  shpColor.Color:=StrToColor(edtColor.text,$C08080);
  shpColor.ColorTo:=shpColor.Color;
end;

procedure SaveIni;
begin
  if chkShowCaption.checked then SetSetting('ShowCaption',1)
    else SetSetting('ShowCaption',0);
  SetSetting('Caption',edtCaption.text);
  SetSetting('TimeZoneIndex',cbbTimeZone.ItemIndex);
  SetSetting('TimeZone',copy(cbbTimeZone.Text,6,6));
  if chkisFlicker.checked then SetSetting('isFlicker',1)
    else SetSetting('isFlicker',0);
  if chkis24Hour.checked then SetSetting('is24Hour',1)
    else SetSetting('is24Hour',0);
  if chkisFullHourPlay.checked then SetSetting('isFullHourPlay',1)
    else SetSetting('isFullHourPlay',0);
  if chkisHalfHourPlay.checked then SetSetting('isHalfHourPlay',1)
    else SetSetting('isHalfHourPlay',0);
  if chkCustomColor.checked then SetSetting('CustomColor',1)
    else SetSetting('CustomColor',0);
  SetSetting('Color',edtColor.text);
end;

procedure OnSettingInit;
begin
  xspfrm.beginupdate;
  chkShowCaption.OnClick:='chkShowCaptionClick';
  edtColor.OnChange:='OnEditChange';
  shpColor.OnClick:='OnshpColorClick';
  shpColor.cursor:=-21;//crHandPoint
  InitTimeZone;
  InitIni;
  xspfrm.endupdate;
  cbbTimeZone.OnSelect:='OnSelected';
end;

//--- Widget设置窗口关闭事件，当按下设置窗口的确定按钮时会触发此事件 ---
//通过设置返回值来改变是否允许确认,当result为False时不关闭设置窗口
function OnSettingClose(iResult);
begin
  result:=true;
  SaveIni;
end;

procedure OnSelected(sender);
var
  fn:string;
  inifn:TIniFile;
begin
  fn:=WidgetPath+'TimeZone.dat';
  if FileExists(fn) then
  begin
  	inifn:=TIniFile.Create(fn);
	  try
	    edtCaption.text:=inifn.ReadString('TimeZone',cbbTimeZone.Text,'');
    finally
  	  inifn.free;
  	end;
  end;
end;

procedure OnEditChange(sender);
begin
  xspfrm.beginupdate;
  shpColor.Color:=StrToColor(edtColor.text,$C08080);
  shpColor.ColorTo:=shpColor.Color;
  xspfrm.endupdate;
  //ShowTrayHint('提示',edtColor.text);
end;

procedure OnshpColorClick(sender);
var
  dlgColor:TColorDialog;
begin
  dlgColor:=TColorDialog.create(WidgetSetting);
  try
    dlgColor.Color:=shpColor.Color;
    if dlgColor.Execute then
    begin
		  xspfrm.beginupdate;
      shpColor.Color:=dlgColor.Color;
  		shpColor.ColorTo:=shpColor.Color;
  		edtColor.text:=ColorToHtmlStr(shpColor.Color);
		  xspfrm.endupdate;
   end;
  finally
    dlgColor.free;
  end;
end;
