*--------------------------------------------------------------------------------------------------------------------------------------------------------
* (EN) AUTOGENERATED - ATTENTION!! - NOT INTENDED FOR EXECUTION!! USE ONLY FOR MERGING CHANGES AND STORING WITH SCM TOOLS!!
*--------------------------------------------------------------------------------------------------------------------------------------------------------
*< FOXBIN2PRG: Version="1.21" SourceFile="solution.vcx" CPID="1252" /> (Solo para binarios VFP 9 / Only for VFP 9 binaries)
*
*
DEFINE CLASS cmdclose AS commandbutton 		&& Close button
 	*< CLASSDATA: Baseclass="commandbutton" Timestamp="" Scale="Pixels" Uniqueid="" />

	*<PropValue>
		Cancel = .T.
		Caption = "Close"
		FontBold = .F.
		FontName = "MS Sans Serif"
		FontSize = 8
		Height = 23
		Name = "cmdclose"
		Width = 72
	*</PropValue>
	
	PROCEDURE Click
		IF TYPE("THISFORM.Parent") = "O"
			THISFORMSET.Release
		ELSE
			THISFORM.Release
		ENDIF
	ENDPROC

	PROCEDURE Error
		LPARAMETERS nError, cMethod, nLine
		LOCAL lnChoice
		#DEFINE CR CHR(13)
		DO CASE
			CASE nError = 1545 && Uncommitted changes
			*------------------------------------
				#DEFINE MSG1_LOC "Do you want to save your changes?"
				#DEFINE MSG2_LOC "Uncommitted Changes"
				lnChoice = MESSAGEBOX(MSG1_LOC, 4+48+0, MSG2_LOC)
				DO CASE
					CASE lnChoice = 6 && yes
						=TABLEUPDATE(.T., .T.)
					CASE lnChoice = 7 && no
						=TABLEREVERT(.T.)
				ENDCASE
				OTHERWISE  && Unanticipated error
			*--------------------------------------	
				#DEFINE NUM_LOC "Error Number: "
				#DEFINE PROG_LOC "Program: "
				#DEFINE CAP_LOC "ERROR"
				lcMsg = NUM_LOC + ALLTRIM(STR(nError)) + CR + CR + ;
						MESSAGE()+ CR + CR + PROG_LOC + PROGRAM(1)
				lnChoice = MESSAGEBOX(lcMsg, 2+48+512, CAP_LOC)
				DO CASE
					CASE lnChoice = 3 &&Abort
						CANCEL
					CASE lnChoice = 4 &&Retry
						RETRY
					CASE lnChoice = 5 &&Ignore
						RETURN
				ENDCASE
		ENDCASE
		
	ENDPROC

ENDDEFINE

DEFINE CLASS resizable AS custom 
 	*< CLASSDATA: Baseclass="custom" Timestamp="" Scale="Pixels" Uniqueid="" />

	*<DefinedPropArrayMethod>
		*m: addtoarray
		*m: adjustcontrols		&& call from resize event of a form to adjust the placement and size of contained objects.
		*m: loopthroughcontrols
		*m: reset		&& Resets the Timer control so that it starts counting from 0.
		*m: setposition
		*m: setsize
		*p: initialformheight
		*p: initialformwidth
		*p: initialresize		&& Is this the first time the controls are being adjusted?
		*p: repositionlist
		*p: resizelist
		*a: acontrolstats[1,5]
	*</DefinedPropArrayMethod>

	PROTECTED acontrolstats,initialformheight,initialformwidth,initialresize
	*<PropValue>
		Height = 19
		initialformheight = 0
		initialformwidth = 0
		initialresize = .T.
		Name = "resizable"
		repositionlist = Commandbutton Combobox Checkbox Listbox Form Grid Textbox Label Shape Editbox Olecontrol Pageframe Image Spinner
		resizelist = Commandbutton Combobox Checkbox Listbox Form Grid Textbox Label Shape Editbox Olecontrol Pageframe Image Spinner
		Width = 27
	*</PropValue>
	
	PROTECTED PROCEDURE addtoarray
		LPARAMETERS oControl
		nLen = ALEN(THIS.aControlStats,1)
		THIS.aControlStats[nLen,1] = oControl.Top / THIS.InitialFormHeight
		THIS.aControlStats[nLen,2] = oControl.Left / THIS.InitialFormWidth
		THIS.aControlStats[nLen,3] = oControl.Height / THIS.InitialFormHeight
		THIS.aControlStats[nLen,4] = oControl.Width / THIS.InitialFormWidth
		THIS.aControlStats[nLen,5] = IIF(TYPE("oControl.FontSize") = 'U', 0, oControl.FontSize)
		DIMENSION THIS.aControlStats[nLen+1, 5]
		
	ENDPROC

	PROCEDURE adjustcontrols		&& call from resize event of a form to adjust the placement and size of contained objects.
		IF THIS.InitialResize
			THIS.LoopThroughControls("INITIALIZE_AND_ADJUST")
			THIS.InitialResize = .F.
		ELSE
			THIS.LoopThroughControls("ADJUST")
		ENDIF
	ENDPROC

	PROCEDURE Init
		THIS.InitialFormHeight = THISFORM.Height
		THIS.InitialFormWidth = THISFORM.Width
	ENDPROC

	PROTECTED PROCEDURE loopthroughcontrols
		LPARAMETERS cTask
		* Valid parameters for cTask are 'Initialize_And_Adjust' and 'Adjust'
		cTask = UPPER(cTask)
		
		nOldDecimal = SET("DECIMAL")
		SET DECIMAL TO 18
		
		nPos = 0
		THISFORM.LockScreen = .T.
		FOR m.i = 1 TO THISFORM.ControlCount
			oControl = THISFORM.Controls[m.i]
				nPos = nPos + 1
				If cTask = 'INITIALIZE_AND_ADJUST'
					THIS.AddToArray(oControl)
				ENDIF
				IF oControl.Class$THIS.ResizeList
					THIS.SetSize(oControl, nPos)
				ENDIF
				IF oControl.Class$THIS.RepositionList
					THIS.SetPosition(oControl, nPos)
				ENDIF
				
			*A pageframe can contain only pages
			IF THISFORM.Controls[m.i].Baseclass$"Pageframe"
				*Loop through each page of the pageframe
				FOR m.j = 1 TO THISFORM.Controls[m.i].PageCount
					WITH THISFORM.Controls[m.i].pages[m.j]
						*loop through all the controls on the page
						FOR m.k = 1 TO .ControlCount
							nPos = nPos + 1
							IF cTask = 'INITIALIZE_AND_ADJUST'
								THIS.AddToArray(.Controls[m.k])
							ENDIF
							IF oControl.Class$THIS.ResizeList
								THIS.SetSize(oControl, nPos)
							ENDIF
							IF oControl.Class$THIS.RepositionList
								THIS.SetPosition(oControl, nPos)
							ENDIF
						ENDFOR
					ENDWITH
				ENDFOR
			ENDIF			
		ENDFOR
		
		THISFORM.LockScreen = .F.
		SET DECIMAL TO nOldDecimal
	ENDPROC

	PROCEDURE reset		&& Resets the Timer control so that it starts counting from 0.
		* Call the reset method when you add a control to the form at runtime.
		THIS.InitialResize = .T.
		DIMENSION THIS.aControlStats[1,5]
		THIS.InitialFormHeight = THISFORM.Height
		THIS.InitialFormWidth = THISFORM.Width
		
	ENDPROC

	PROTECTED PROCEDURE setposition
		LPARAMETERS oControl, nPos
		oControl.Top = THISFORM.Height * THIS.aControlStats[nPos,1]
		oControl.Left = THISFORM.Width * THIS.aControlStats[nPos,2]
		
	ENDPROC

	PROTECTED PROCEDURE setsize
		LPARAMETERS oControl, nPos
		oControl.Width = THISFORM.Width * THIS.aControlStats[nPos,4]
		IF !oControl.Baseclass $ "Textbox Spinner"
			oControl.Height = THISFORM.Height * THIS.aControlStats[nPos,3]
		ENDIF
		
		
	ENDPROC

ENDDEFINE

DEFINE CLASS resizable_class AS custom 
 	*< CLASSDATA: Baseclass="custom" Timestamp="" Scale="Pixels" Uniqueid="" />

	*<DefinedPropArrayMethod>
		*m: addtoarray
		*m: adjustcontrols		&& call from resize event of a form to adjust the placement and size of contained objects.
		*m: loopthroughcontrols
		*m: reset		&& Resets the Timer control so that it starts counting from 0.
		*m: setposition
		*m: setsize
		*p: initialformheight
		*p: initialformwidth
		*p: initialresize		&& Is this the first time the controls are being adjusted?
		*p: repositionlist
		*p: resizelist
		*a: acontrolstats[1,5]
	*</DefinedPropArrayMethod>

	PROTECTED acontrolstats,initialformheight,initialformwidth,initialresize
	*<PropValue>
		Height = 19
		initialformheight = 0
		initialformwidth = 0
		initialresize = .T.
		Name = "resizable"
		repositionlist = Commandbutton Combobox Checkbox Listbox Form Grid Textbox Label Shape Editbox Olecontrol Pageframe Image Spinner
		resizelist = Commandbutton Combobox Checkbox Listbox Form Grid Textbox Label Shape Editbox Olecontrol Pageframe Image Spinner
		Width = 27
	*</PropValue>
	
	PROTECTED PROCEDURE addtoarray
		LPARAMETERS oControl
		nLen = ALEN(THIS.aControlStats,1)
		THIS.aControlStats[nLen,1] = oControl.Top / THIS.InitialFormHeight
		THIS.aControlStats[nLen,2] = oControl.Left / THIS.InitialFormWidth
		THIS.aControlStats[nLen,3] = oControl.Height / THIS.InitialFormHeight
		THIS.aControlStats[nLen,4] = oControl.Width / THIS.InitialFormWidth
		THIS.aControlStats[nLen,5] = IIF(TYPE("oControl.FontSize") = 'U', 0, oControl.FontSize)
		DIMENSION THIS.aControlStats[nLen+1, 5]
		
	ENDPROC

	PROCEDURE adjustcontrols		&& call from resize event of a form to adjust the placement and size of contained objects.
		IF THIS.InitialResize
			THIS.LoopThroughControls("INITIALIZE_AND_ADJUST")
			THIS.InitialResize = .F.
		ELSE
			THIS.LoopThroughControls("ADJUST")
		ENDIF
	ENDPROC

	PROCEDURE Init
		THIS.InitialFormHeight = THISFORM.Height
		THIS.InitialFormWidth = THISFORM.Width
	ENDPROC

	PROTECTED PROCEDURE loopthroughcontrols
		LPARAMETERS cTask
		* Valid parameters for cTask are 'Initialize_And_Adjust' and 'Adjust'
		cTask = UPPER(cTask)
		
		nOldDecimal = SET("DECIMAL")
		SET DECIMAL TO 18
		
		nPos = 0
		THISFORM.LockScreen = .T.
		FOR m.i = 1 TO THISFORM.ControlCount
			oControl = THISFORM.Controls[m.i]
				nPos = nPos + 1
				If cTask = 'INITIALIZE_AND_ADJUST'
					THIS.AddToArray(oControl)
				ENDIF
				IF oControl.Class$THIS.ResizeList
					THIS.SetSize(oControl, nPos)
				ENDIF
				IF oControl.Class$THIS.RepositionList
					THIS.SetPosition(oControl, nPos)
				ENDIF
				
			*A pageframe can contain only pages
			IF THISFORM.Controls[m.i].Baseclass$"Pageframe"
				*Loop through each page of the pageframe
				FOR m.j = 1 TO THISFORM.Controls[m.i].PageCount
					WITH THISFORM.Controls[m.i].pages[m.j]
						*loop through all the controls on the page
						FOR m.k = 1 TO .ControlCount
							nPos = nPos + 1
							IF cTask = 'INITIALIZE_AND_ADJUST'
								THIS.AddToArray(.Controls[m.k])
							ENDIF
							IF oControl.Class$THIS.ResizeList
								THIS.SetSize(oControl, nPos)
							ENDIF
							IF oControl.Class$THIS.RepositionList
								THIS.SetPosition(oControl, nPos)
							ENDIF
						ENDFOR
					ENDWITH
				ENDFOR
			ENDIF			
		ENDFOR
		
		THISFORM.LockScreen = .F.
		SET DECIMAL TO nOldDecimal
	ENDPROC

	PROCEDURE reset		&& Resets the Timer control so that it starts counting from 0.
		* Call the reset method when you add a control to the form at runtime.
		THIS.InitialResize = .T.
		DIMENSION THIS.aControlStats[1,5]
		THIS.InitialFormHeight = THISFORM.Height
		THIS.InitialFormWidth = THISFORM.Width
		
	ENDPROC

	PROTECTED PROCEDURE setposition
		LPARAMETERS oControl, nPos
		oControl.Top = THISFORM.Height * THIS.aControlStats[nPos,1]
		oControl.Left = THISFORM.Width * THIS.aControlStats[nPos,2]
		
	ENDPROC

	PROTECTED PROCEDURE setsize
		LPARAMETERS oControl, nPos
		oControl.Width = THISFORM.Width * THIS.aControlStats[nPos,4]
		IF !oControl.Baseclass $ "Textbox Spinner"
			oControl.Height = THISFORM.Height * THIS.aControlStats[nPos,3]
		ENDIF
		
		
	ENDPROC

ENDDEFINE

DEFINE CLASS resizable_name AS resizable_class OF "solution.vcx" 
 	*< CLASSDATA: Baseclass="custom" Timestamp="" Scale="Pixels" Uniqueid="" />

	#INCLUDE "c:\program files\microsoft visual foxpro 8\foxpro.h"
	*<PropValue>
		Name = "resizable_name"
	*</PropValue>
	
	PROCEDURE loopthroughcontrols
		LPARAMETERS cTask
		* Valid parameters for cTask are 'Initialize_And_Adjust' and 'Adjust'
		cTask = UPPER(cTask)
		
		nOldDecimal = SET("DECIMAL")
		SET DECIMAL TO 18
		
		nPos = 0
		THISFORM.LockScreen = .T.
		FOR m.i = 1 TO THISFORM.ControlCount
			oControl = THISFORM.Controls[m.i]
				nPos = nPos + 1
				If cTask = 'INITIALIZE_AND_ADJUST'
					THIS.AddToArray(oControl)
				ENDIF
				IF oControl.Name$THIS.ResizeList
					THIS.SetSize(oControl, nPos)
				ENDIF
				IF oControl.Name$THIS.RepositionList
					THIS.SetPosition(oControl, nPos)
				ENDIF
				
			*A pageframe can contain only pages
			IF THISFORM.Controls[m.i].Baseclass$"Pageframe"
				*Loop through each page of the pageframe
				FOR m.j = 1 TO THISFORM.Controls[m.i].PageCount
					WITH THISFORM.Controls[m.i].pages[m.j]
						*loop through all the controls on the page
						FOR m.k = 1 TO .ControlCount
							nPos = nPos + 1
							IF cTask = 'INITIALIZE_AND_ADJUST'
								THIS.AddToArray(.Controls[m.k])
							ENDIF
							IF oControl.Class$THIS.ResizeList
								THIS.SetSize(oControl, nPos)
							ENDIF
							IF oControl.Class$THIS.RepositionList
								THIS.SetPosition(oControl, nPos)
							ENDIF
						ENDFOR
					ENDWITH
				ENDFOR
			ENDIF			
		ENDFOR
		
		THISFORM.LockScreen = .F.
		SET DECIMAL TO nOldDecimal
	ENDPROC

ENDDEFINE

DEFINE CLASS resizer AS control 
 	*< CLASSDATA: Baseclass="control" Timestamp="" Scale="Pixels" Uniqueid="" />

	*-- OBJECTDATA items order determines ZOrder / El orden de los items OBJECTDATA determina el ZOrder 
	*< OBJECTDATA: ObjPath="Label1" UniqueID="" Timestamp="" />

	*<DefinedPropArrayMethod>
		*m: onresize
		*p: nlastheight
		*p: nlastwidth
	*</DefinedPropArrayMethod>

	*<PropValue>
		BackStyle = 0
		BorderWidth = 0
		Comment = "*:OnResize=RB"
		Height = 14
		Name = "resizer"
		nlastheight = 0
		nlastwidth = 0
		Width = 14
	*</PropValue>

	ADD OBJECT 'Label1' AS label WITH ;
		AutoSize = .T., ;
		BackStyle = 0, ;
		Caption = "o", ;
		FontName = "Marlett", ;
		Height = 14, ;
		Left = 0, ;
		Name = "Label1", ;
		Top = 0, ;
		Width = 14
		*< END OBJECT: BaseClass="label" />
	
	PROCEDURE Init
		*
		* Save the original form size
		*
		THIS.nLastHeight = ThisForm.Height
		THIS.nLastWidth  = ThisForm.Width
		
		IF ThisForm.MinHeight = -1
		   *
		   * Make the design height the minimum if not otherwise specified
		   *
		   ThisForm.MinHeight = ThisForm.Height
		ENDIF
		
		IF ThisForm.MinWidth = -1
		   *
		   * Make the design width the minimum if not otherwise specified
		   *
		   ThisForm.MinWidth = ThisForm.Width
		ENDIF
		
		*
		* Move this control to the right bottom of the form
		*
		THIS.Top  = ThisForm.Height - THIS.Height + 2
		THIS.Left = ThisForm.Width  - This.Width  + 2
		
		*
		* Make sure the border style is resizable
		*
		ThisForm.BorderStyle = 3
		
	ENDPROC

	PROCEDURE onresize
		*
		* Call this method from the Form.Resize event
		*
		LOCAL ARRAY laObjects[1]
		LOCAL lnCount,lnI, loObject, lnDeltaHeight,  lnDeltaWidth
		LOCAL lcOnResize, lcHeight, lcWidth, lnAtPos
		
		*
		* Lock the screen
		*
		ThisForm.LockScreen = .T.
		
		*
		* Calculate the change in height since the last resize
		*
		lnDeltaHeight = ThisForm.Height - THIS.nLastHeight
		lnDeltaWidth  = ThisForm.Width  - THIS.nLastWidth
		
		*
		* Build an array of objects
		*
		lnCount = Obj2Arr(@laObjects, ThisForm)
		
		FOR lnI = 1 TO lnCount
		   *
		   * Get the object
		   *
		   loObject = laObjects[lnI]
		   
		   IF TYPE('loObject.Comment') <> 'C'
		      *
		      * No comment property, skip control
		      LOOP
		   ENDIF
		   
		   lnAtPos = ATCC('*:OnResize=', loObject.Comment)
		   IF lnAtPos = 0
		      *
		      * No On resize specified, skip control
		      *
		      LOOP
		   ENDIF
		   
		   *
		   * Determine the actions to be preformed
		   *
		   lcOnResize = UPPER(PADR(SUBSTR(loObject.Comment, lnAtPos + 11), 2))
		   lcHeight   = RIGHT(lcOnResize, 1)
		   lcWidth    = LEFT(lcOnResize, 1)
		   
		   *
		   * Chanhe the Height/Top of needed
		   DO CASE
		      CASE lcHeight = 'C'
		         *
		         * Center verticaly
		         *
		         loObject.Top    = loObject.Top    + ROUND(lnDeltaHeight / 2, 0)
		         
		      CASE lcHeight = 'B'
		         *
		         * Align with bottom
		         *
		         loObject.Top    = loObject.Top    + lnDeltaHeight
		         
		      CASE lcHeight = 'S'
		         *
		         * Resize object vertically
		         *
		         loObject.Height = loObject.Height + lnDeltaHeight
		   ENDCASE
		   
		   DO CASE
		      CASE lcWidth = 'C'
		         *
		         * Center horizontally
		         *
		         loObject.Left  = loObject.Left  + ROUND(lnDeltaWidth / 2, 0)
		         
		      CASE lcWidth = 'R'
		         *
		         * Align to right site
		         *
		         loObject.Left  = loObject.Left  + lnDeltaWidth
		         
		      CASE lcWidth = 'S'
		         *
		         * Size object horizontally
		         *
		         loObject.Width = loObject.Width + lnDeltaWidth
		   ENDCASE
		ENDFOR
		
		*
		* Remember the current form size
		*
		THIS.nLastHeight = ThisForm.Height
		THIS.nLastWidth  = ThisForm.Width
		
		*
		* Unlock the form to show changes
		*
		ThisForm.LockScreen = .F.
		
	ENDPROC

ENDDEFINE
