Saludos.
Mi aplicacion es Open Source, el usuario pude reubicar los controles, asignar tamaño, colores y fuentes.
1. En el sysmenu cree la opcion Activar modo diseño. Todos los controles les activo oControl:lDesign:=.T.
2. Si es MDI el usuario puede arrastrarlos con el mouse.
3. Al salir del formulario, guardo en un archivo plano la geometria de cada control.
4. Cuando se inicia la ventana ON INIT leo el archivo TXT y reubico los controles.
Code: Select all
// Programa : ADJCONTROL
// Fecha/Hora : 27/05/2003 02:34:45
// Propósito : Ajustar Controles
// Creado Por : Juan Navas
// Llamado por: MenuSys de los MDI y Dialogos con Controles
// Aplicación : Programación
// Tabla : Todas
#INCLUDE "DPXBASE.CH"
/*
// Prueba del Ajuste de Controles
*/
FUNCTION MAIN()
LOCAL oDlg,cNombre:="Nombre de Prueba",oGet
DEFINE DIALOG oDlg
@ 0,.5 SAY "Nombre de Prueba"
@ 1,.5 GET oGet VAR cNombre
@ 2,.5 BUTTON "Ajustar" ACTION CTRLSETSIZE(oGet) SIZE 40,15
@ 3,.5 BUTTON "Cerrar" ACTION oDlg:End() SIZE 40,15
ACTIVATE DIALOG oDlg
RETURN NIL
FUNCTION CTRLSETSIZE(oControl)
LOCAL oSize,bMove,oBtn1,oBtn2,oFont,nAdd:=4,nSep1:=40,I,oCol,cId,cTitle
LOCAL oGet1,oGet2,oGet3,oGet4,oBrw,aNames:={},oFont,aControls:={},oFontS,nLen,aDialogs,U,Z,oObjCtrl
DEFINE FONT oFontS NAME "CURIER" SIZE 0,-12
AADD(aNames ,{oControl:ClassName(),ctoo(oControl:nResult,"C"),""})
AADD(aControls,oControl)
nLen:=IIF(ValType(oControl:aControls)="A",LEN(oControl:aControls),0)
FOR I=1 TO nLen
cId :=CTOO(oControl:aControls[I]:nResult,"C")
cId :=IIF(cId=NIL,"NIL",cId)
cTitle :=oControl:aControls[I]:GetText()
AADD(aNames,{oControl:aControls[I]:ClassName(),cId,cTitle})
AADD(aControls,oControl:aControls[I])
IF oControl:aControls[i]:CLASSNAME()="TFOLDER"
// Agrega los Controles de los Folders
aDialogs:=oControl:aControls[I]:aDialogs
FOR U=1 TO LEN(aDialogs)
FOR Z=1 TO LEN(aDialogs[U]:aControls)
oObjCtrl:=aDialogs[U]:aControls[Z]
cId :=CTOO(oObjCtrl:nResult,"C")
cId :=IIF(cId=NIL,"NIL",cId)
cTitle :=oObjCtrl:GetText()
AADD(aNames,{"["+STRZERO(U,2)+"]"+oObjCtrl:ClassName(),cId,cTitle})
AADD(aControls,oObjCtrl)
NEXT Z
NEXT U
ENDIF
NEXT
oSize:=Dialog("Ajustar Coordenadas "+oControl:ClassName(),"DEFCTRL.EDT",NIL,oDp:oFrameDp,.F.)
oSize:nTop :=MAX(oControl:nTop,1)
oSize:nLeft :=oControl:nLeft
oSize:nWidth :=oControl:nWidth
oSize:nHeight:=oControl:nHeight
bMove:={||oControl:Move(oSize:nTop,oSize:nLeft,oSize:nWidth,oSize:nHeight,.T.),.T.}
// ERRORSYS(.T.)
// Mover
oBtn := TBtnBmp():New(05,05,12,12,,,"BITMAPS\ARROW1.BMP",,{|Self|(oSize:nTop-=nAdd,oSize:nLeft-=nAdd,EVAL(bMove))},,,,.F.,.F.,,,,,!.T.,)
oBtn := TBtnBmp():New(05,20,12,12,,,"BITMAPS\ARROW2.BMP",,{|Self|(oSize:nTop-=nAdd,EVAL(bMove))},,,,.F.,.F.,,,,,!.T.,)
oBtn := TBtnBmp():New(05,35,12,12,,,"BITMAPS\ARROW3.BMP",,{|Self|(oSize:nTop-=nAdd,oSize:nLeft+=nAdd,EVAL(bMove))},,,,.F.,.F.,,,,,!.T.,)
oBtn := TBtnBmp():New(18,35,12,12,,,"BITMAPS\ARROW4.BMP",,{|Self|(oSize:nLeft+=nAdd,EVAL(bMove))},,,,.F.,.F.,,,,,!.T.,)
oBtn := TBtnBmp():New(32,35,12,12,,,"BITMAPS\ARROW5.BMP",,{|Self|(oSize:nTop+=nAdd,oSize:nLeft+=nAdd,EVAL(bMove))},,,,.F.,.F.,,,,,!.T.,)
oBtn := TBtnBmp():New(32,20,12,12,,,"BITMAPS\ARROW6.BMP",,{|Self|(oSize:nTop+=nAdd,EVAL(bMove))},,,,.F.,.F.,,,,,!.T.,)
oBtn := TBtnBmp():New(32,05,12,12,,,"BITMAPS\ARROW7.BMP",,{|Self|(oSize:nTop+=nAdd,oSize:nLeft-=nAdd,EVAL(bMove))},,,,.F.,.F.,,,,,!.T.,)
oBtn := TBtnBmp():New(18,05,12,12,,,"BITMAPS\ARROW8.BMP",,{|Self|(oSize:nLeft-=nAdd,EVAL(bMove))},,,,.F.,.F.,,,,,!.T.,)
// Ampliar
oBtn := TBtnBmp():New(05,05+nSep1,12,12,,,"BITMAPS\ARROW1.BMP",,{|Self|(oSize:nTop-=nAdd,oSize:nLeft-=nAdd,oSize:nWidth+=nAdd,oSize:nHeight+=nAdd,EVAL(bMove))},,,,.F.,.F.,,,,,!.T.,)
oBtn := TBtnBmp():New(05,20+nSep1,12,12,,,"BITMAPS\ARROW2.BMP",,{|Self|(oSize:nTop-=nAdd,oSize:nHeight+=nAdd,EVAL(bMove))},,,,.F.,.F.,,,,,!.T.,)
oBtn := TBtnBmp():New(05,35+nSep1,12,12,,,"BITMAPS\ARROW3.BMP",,{|Self|(oSize:nTop-=nAdd,oSize:nWidth+=nAdd,oSize:nHeight+=nAdd,EVAL(bMove))},,,,.F.,.F.,,,,,!.T.,)
oBtn := TBtnBmp():New(18,35+nSep1,12,12,,,"BITMAPS\ARROW4.BMP",,{|Self|(oSize:nWidth+=nAdd,EVAL(bMove))},,,,.F.,.F.,,,,,!.T.,)
oBtn := TBtnBmp():New(32,35+nSep1,12,12,,,"BITMAPS\ARROW5.BMP",,{|Self|(oSize:nWidth+=nAdd,oSize:nHeight+=nAdd,EVAL(bMove))},,,,.F.,.F.,,,,,!.T.,)
oBtn := TBtnBmp():New(32,20+nSep1,12,12,,,"BITMAPS\ARROW6.BMP",,{|Self|(oSize:nHeight+=nAdd,EVAL(bMove))},,,,.F.,.F.,,,,,!.T.,)
oBtn := TBtnBmp():New(32,05+nSep1,12,12,,,"BITMAPS\ARROW7.BMP",,{|Self|(oSize:nWidth+=nAdd,oSize:nLeft-=nAdd,oSize:nHeight+=nAdd,EVAL(bMove))},,,,.F.,.F.,,,,,!.T.,)
oBtn := TBtnBmp():New(18,05+nSep1,12,12,,,"BITMAPS\ARROW8.BMP",,{|Self|(oSize:nWidth-=nAdd,EVAL(bMove))},,,,.F.,.F.,,,,,!.T.,)
// Coordenadas
@ 0.5,28 GET oGet1 VAR oSize:nTop picture "9999" valid EVAL(bMove)
@ 1.5,28 GET oGet2 VAR oSize:nLeft picture "9999" valid EVAL(bMove)
@ 2.5,28 GET oGet3 VAR oSize:nWidth picture "9999" valid EVAL(bMove)
@ 3.5,28 GET oGet4 VAR oSize:nHeight picture "9999" valid EVAL(bMove)
@ oGet1:nTop,oGet1:nLeft-35 SAY "L¦nea" PIXEL SIZE 30,NIL FONT oFontS
@ oGet2:nTop,oGet2:nLeft-35 SAY "Columna" PIXEL SIZE 30,NIL FONT oFontS
@ oGet3:nTop,oGet3:nLeft-35 SAY "Ancho" PIXEL SIZE 30,NIL FONT oFontS
@ oGet4:nTop,oGet4:nLeft-35 SAY "Alto" PIXEL SIZE 30,NIL FONT oFontS
TGet():New(1.4,2.4,{ | u | If(PCount()==0,nAdd,nAdd:= u ) },,,,"99",,,,,.F.,,.F.,,.F.,,.F.,.F.,,.F.,.f.,.f.,,.F.,,,,)
oBrw:= TXBrowse():New(oSize:oDlg )
oBrw:nColDividerStyle := 1
oBrw:nRowDividerStyle := 1
oBrw:lColDividerComplete := .t.
oBrw:nMarqueeStyle := 5
oBrw:bChange :={|oBrw|oControl:=aControls[oBrw:nArrayAt],oSize:nTop :=oControl:nTop ,oSize:nLeft :=oControl:nLeft ,oSize:nWidth :=oControl:nWidth,oSize:nHeight:=oControl:nHeight}
oBrw:SetArray(aNames)
oBrw:SetFont(oFont)
oBrw:lHScroll := .F.
oBrw:nRowSel := 1
oBrw:nTop := 58-10
oBrw:nLeft := 00
oBrw:nBottom := 110
oBrw:nRight := 180
oCol:=oBrw:aCols[1]
oCol:cHeader:="Control"
oCol:nWidth :=100
oCol:=oBrw:aCols[2]
oCol:cHeader:="ID"
oCol:nWidth :=20
oCol:=oBrw:aCols[3]
oCol:cHeader:="Contenido"
oCol:nWidth :=190
oBrw:CreateFromCode()
oBtn := TBtnBmp():New(120-5,05,15,15,,,"BITMAPS\FONT.BMP",,{|Self|oControl:SelFont()},,,,.F.,.F.,,,,,!.T.,)
oBtn := TBtnBmp():New(120-5,20,15,15,,,"BITMAPS\COLORS.BMP",,{|Self|oControl:SelColor()},,,,.F.,.F.,,,,,!.T.,)
oBtn := TBtnBmp():New(120-5,40,15,15,,,"BITMAPS\SAVEPRJ.BMP",,{|Self|oSize:Close()},,,,.F.,.F.,,,,,!.T.,)
EVAL(bMove)
oSize:Activate({||.T.})
// oControl:oWnd:SetFocus()})
RETURN NIL
FUNCTION CTRLMEMO(cFileEdt)
LOCAL oView,cMemo:=MEMOREAD(cFileEdt),oFont,lRet:=.F.
DEFINE FONT oFont NAME "CURIER" SIZE 0,-12
oView:=Dialog("Editar planos de Formulario "+cFileEdt,"VIEWMEMO.EDT")
@ .5,0 GET cMemo MULTILINE SIZE 325,150 FONT oFont
// TMultiGet():New(.5,0,{ | u | If(PCount()==0,cMemo,cMemo:= u ) },,325,150,oFont,.T.,,,,.F.,,.F.,,.F.,.F.,.F.,,,.F.,,)
@ 09,30 BUTTON " Grabar " ACTION MemoWrit(cFileEdt,cMemo)
@ 09,40 BUTTON " Cerrar " ACTION oView:Close()
oView:Activate()
RETURN lRet
// EOF