var
  ColCount,RowCount:integer;	
	
function CheckRowCol;
var
  s:string;
	Row,Col:integer;
begin
  Result:=true;
	try
	  Row:=strtoint(edtRow.text);
		if (Row > 10 ) or (Row <=0) then 
		begin
		    showmessage('行数取值范围1~10！');
				Result:=false;
	     	exit;		
		end;
	except
		showmessage('行数输入有误！');
		Result:=false;
		exit;
	end;
	
	try
	  Col:=strtoint(edtCol.text);
		if (Col > 8 ) or (col <=1) then 
		begin
		  showmessage('列数取值范围2~8！');
		  Result:=false;
	    exit;		
		end;
	except
		showmessage('列数输入有误！');
		Result:=false;
		exit;
	end;
	RowCount:=Row;
	ColCount:=Col;
  Result:=true;
end;	
	

//读取配置
procedure InitSetting;
begin
  RowCount:=	GetSettingInt('RowCount',4);//行数	
	ColCount:=	GetSettingInt('ColCount',2);// 列数 
  edtRow.text:= inttostr(RowCount);
  edtCol.text:= inttostr(ColCount);
 
end;

//保存配置
procedure SaveSetting;
begin  
	//	设置	
  SetSettingInt('RowCount',RowCount);
  SetSettingInt('ColCount',ColCount);
end;

//--- Widget设置窗口初始化事件，当打开Widget设置窗口时会触发此事件 ---
procedure OnSettingInit;
begin
   InitSetting;
end;

procedure OnSettingApply;
begin
  if not CheckRowCol then exit;
  SaveSetting;
end;

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