PARAMETERS volba
LOCAL m.jedenstol, m.sii, m.hodnota, povyberane
SELECT pomsstl
REPLACE ALL vybrane WITH .f.
m.povyberane=thisform.vybranestoly 
DO WHILE .t.
	IF AT("--",m.povyberane,2)>0
		m.sii=LEFT(m.povyberane,AT("--",m.povyberane,2)+1)
		m.povyberane=SUBSTR(m.povyberane,LEN(m.sii)+1)
		m.jedenstol=VAL(STRTRAN(m.sii,"--",""))
		SELECT pomsstl
		REPLACE vybrane WITH .t. FOR id=m.jedenstol
	ELSE
		EXIT
	ENDIF 
ENDDO

DO CASE 
	CASE m.volba="0"
	CASE m.volba="1"
*	"Zarovnať ľavý okraj"
		SELECT MIN(left) as x FROM pomsstl WHERE service_area_id=thisform.actmiestnost and vybrane INTO CURSOR aass
		IF RECCOUNT("aass")=1
			SELECT aass
			GO TOP 
			m.hodnota=aass.x
			SELECT pomsstl
			REPLACE left WITH m.hodnota FOR service_area_id=thisform.actmiestnost and vybrane
			thisform.room_changed=.t.
		ENDIF 
	CASE m.volba="2"
*	"Zarovnať pravý okraj"
		SELECT Max(left+width) as x FROM pomsstl WHERE service_area_id=thisform.actmiestnost and vybrane INTO CURSOR aass
		IF RECCOUNT("aass")=1
			SELECT aass
			GO TOP 
			m.hodnota=aass.x
			SELECT pomsstl
			REPLACE left WITH m.hodnota-width FOR service_area_id=thisform.actmiestnost and vybrane
			thisform.room_changed=.t.
		ENDIF 
	CASE m.volba="3"
*	"Zarovnať horný okraj"
		SELECT MIN(top) as x FROM pomsstl WHERE service_area_id=thisform.actmiestnost and vybrane INTO CURSOR aass
		IF RECCOUNT("aass")=1
			SELECT aass
			GO TOP 
			m.hodnota=aass.x
			SELECT pomsstl
			REPLACE top WITH m.hodnota FOR service_area_id=thisform.actmiestnost and vybrane
			thisform.room_changed=.t.
		ENDIF 
	CASE m.volba="4"
*	"Zarovnať spodný okraj"
		SELECT Max(top+height) as x FROM pomsstl WHERE service_area_id=thisform.actmiestnost and vybrane INTO CURSOR aass
		IF RECCOUNT("aass")=1
			SELECT aass
			GO TOP 
			m.hodnota=aass.x
			SELECT pomsstl
			REPLACE top WITH m.hodnota-height FOR service_area_id=thisform.actmiestnost and vybrane
			thisform.room_changed=.t.
		ENDIF 
	CASE m.volba="5"
*	"Zarovnať šírku na najmenší"
		SELECT MIN(width) as x FROM pomsstl WHERE service_area_id=thisform.actmiestnost and vybrane INTO CURSOR aass
		IF RECCOUNT("aass")=1
			SELECT aass
			GO TOP 
			m.hodnota=aass.x
			SELECT pomsstl
			REPLACE width WITH m.hodnota FOR service_area_id=thisform.actmiestnost and vybrane
			thisform.room_changed=.t.
		ENDIF 
	CASE m.volba="6"
*	"Zarovnať šírku na najväčší"
		SELECT MAX(width) as x FROM pomsstl WHERE service_area_id=thisform.actmiestnost and vybrane INTO CURSOR aass
		IF RECCOUNT("aass")=1
			SELECT aass
			GO TOP 
			m.hodnota=aass.x
			SELECT pomsstl
			REPLACE width WITH m.hodnota FOR service_area_id=thisform.actmiestnost and vybrane
			thisform.room_changed=.t.
		ENDIF 
	CASE m.volba="7"
*	"Zarovnať výšku na najmenší"
		SELECT MIN(height) as x FROM pomsstl WHERE service_area_id=thisform.actmiestnost and vybrane INTO CURSOR aass
		IF RECCOUNT("aass")=1
			SELECT aass
			GO TOP 
			m.hodnota=aass.x
			SELECT pomsstl
			REPLACE height WITH m.hodnota FOR service_area_id=thisform.actmiestnost and vybrane
			thisform.room_changed=.t.
		ENDIF 
	CASE m.volba="8"
*	"Zarovnať výšku na najväčší"
		SELECT MAX(height) as x FROM pomsstl WHERE service_area_id=thisform.actmiestnost and vybrane INTO CURSOR aass
		IF RECCOUNT("aass")=1
			SELECT aass
			GO TOP 
			m.hodnota=aass.x
			SELECT pomsstl
			REPLACE height WITH m.hodnota FOR service_area_id=thisform.actmiestnost and vybrane
			thisform.room_changed=.t.
		ENDIF 
ENDCASE  
DO pozavirej WITH "aass"
IF thisform.room_changed 
	m.xx=Amembers(cleny,thisform.pageframe1.page2,2)
	SELECT pomsstl
	SCAN FOR vybrane
		m.sii = ALLTRIM(STR(pomsstl.id,10, 0))
		m.Sii = STRTRAN(m.sii,".","_")
	    m.Sii = STRTRAN(m.sii,",","_")
		IF ASCAN(cleny,'CMDNUMBTN&sii')>0
			THISFORM.pageframe1.page2.cmdnumbtn&sii..set_position(pomsstl.TOP, pomsstl.LEFT, pomsstl.HEIGHT, pomsstl.WIDTH) 
			THISFORM.pageframe1.page2.cmdnumbtn&sii..tooltiptext = "x:"+ALLTRIM(STR(pomsstl.left,20,10))+CHR(13)+CHR(10)+"y:"+ALLTRIM(STR(pomsstl.top,20,10))+CHR(13)+CHR(10)+"width:"+ALLTRIM(STR(pomsstl.width,20,10))+CHR(13)+CHR(10)+"height:"+ALLTRIM(STR(pomsstl.height,20,10))
			THISFORM.pageframe1.page2.cmdnumbtn&sii..refresh()
		ENDIF
	ENDSCAN 
	thisform.pageframe1.page2.shape1.Refresh()
ENDIF 
m.volba="  "
