const
  Count=11;

var
  Index:integer;
  

procedure RefreshPreview;
begin
  Beginupdate;
  if Index>Count then 
    Index:=Index mod Count
  else if Index<1 then
    Index:=Index+Count;
  imgPreview.FileName:=WidgetPath+'images\'+inttostr(Index)+'.png';
  lblIndex.caption:=inttostr(Index)+'/'+inttostr(Count);
  Endupdate;
end;

procedure InitIni;
begin
  Index:=GetSetting('Index',1);
  if Index<>0 then RefreshPreview;
end;

procedure SaveIni;
begin
  SetSetting('Index',Index);
end;

procedure OnSettingInit;
begin
  Index:=0;
  Beginupdate;
  InitIni;
  Endupdate;
end;

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

