//读取配置
procedure InitIni;
begin
  cbbSkins.text:=GetSetting('Skin','LongGlass');
  edtDefIconSize.text:=GetSetting('DefIconSize','60');
  edtMaxIconSize.text:=GetSetting('MaxIconSize','128');
  chkAniStyle.checked:=GetSetting('AniStyle','1')='1';
  edtDelaySpeed.text:=GetSetting('DelaySpeed','7');
end;

//保存配置
procedure SaveIni;
begin
  SetSetting('Skin',cbbSkins.text);
  SetSetting('DefIconSize',edtDefIconSize.text);
  SetSetting('MaxIconSize',edtMaxIconSize.text);
  SetSetting('AniStyle',chkAniStyle.checked);
  SetSetting('DelaySpeed',edtDelaySpeed.text);
end;

//--- Widget设置窗口初始化事件，当打开Widget设置窗口时会触发此事件 ---
procedure OnSettingInit;
begin
  Beginupdate;
  cbbSkins.items.text:=GetPathList(WidgetPath+'images\bg\');
  InitIni;
  Endupdate;
end;

//--- 按下设置窗口的确定按钮时，触发此事件 ---
//通过设置返回值来改变是否允许确认,当result为False时不关闭设置窗口
function OnSettingClose(iResult);
var
  i,j:integer;
begin
  result:=true;
  try
    if trim(cbbSkins.text)='' then
    begin
      showmsg('请选择背景皮肤！');
      raise(''); 
    end;
    try
      i:=StrToInt(edtDefIconSize.text);
      if (i<24) or (i>256) then raise('');
      j:=StrToInt(edtMaxIconSize.text);
      if (i<24) or (i>256) then raise('');
      if i>j then
      begin
        showmsg('默认图标大小不能大于最大图标大小！');
        result:=false;
      end;
    except
      showmsg('请输入24-256之间的有效数字！');
      raise('');
    end;
    try
      i:=strtoint(edtDelaySpeed.text);
      if (i<1) or (i>10) then raise('');
    except
      showmsg('请输入1-10之间的有效数字！');
      raise('');
    end;
  except
    result:=false;
  end;
  if Result then
    SaveIni;
end;

