Traducción de una entrada del Blog de Cesar Chalom, donde nos muestra como utilizar la clase CTL32 ProgressBar de Carlos Alloatti, desde su FoxyPreviewer.
Usando el CTL32 ProgressBar de FoxyPreviewer
Artículo original: Using the CTL32 ProgressBar from FoxyPreviewer (http://weblogs.foxite.com/vfpimaging/archive/2011/01/21/13664.aspx)
Autor: Cesar Chalom (http://weblogs.foxite.com/vfpimaging)
Traducido por: Luis Maria Guayán (http://www.luismariaguayan.com.ar/articulos.htm)
Para: PortalFox (http://www.portalfox.com/)
Autor: Cesar Chalom (http://weblogs.foxite.com/vfpimaging)
Traducido por: Luis Maria Guayán (http://www.luismariaguayan.com.ar/articulos.htm)
Para: PortalFox (http://www.portalfox.com/)
FoxyPreviewer.App es una colección de clases. En su interior hay varias clases, que se pueden acceder directamente usando VFP.
Recientemente he recibido el requerimiento de mostrar como podria utilizar el CTL32 ProgressBar directamente.
!Eso es realmente simple! El comando es
NEWOBJECT()
, que nos permite acceder a las clases desde un archivo EXE o APP externo. En primer lugar el autor de esta joya, el CTL32 ProgressBar es Carlos Alloatti. Para obtener la información completa sobre cómo usarlo, por favor vaya directamente al sitio web de CTL32: http://www.ctl32.com.ar/
Uso:
=Dotherm(90, "Caption", "TitleBar") && Muestra la barra de progreso normal con el 90%
=DoTherm(-1, "Caption", "TitleBar") && El valor -1 en el primer parámetro muestra el efecto de marquesina
=DoTherm() && Desactiva la barra de progreso
Guardar el código de abajo como DOTHERM.PRG
* DOTHERM.PRG * =DoTherm(90, "Texto label", "Titulo") * =DoTherm(-1, "Teste2", "Titulo") && Continuo * =DoTherm() && Desactiva LPARAMETERS tnPercent, tcLabelText, tcTitleText IF NOT PEMSTATUS(_SCREEN , "oThermForm", 5) _SCREEN.ADDPROPERTY("oThermForm", "") ENDIF IF EMPTY(tnPercent) TRY _SCREEN.oThermForm.RELEASE() CATCH ENDTRY _SCREEN.oThermForm = NULL RETURN ENDIF IF TYPE("_Screen.oThermForm.Therm") <> "O" DO CreateTherm ENDIF LOCAL loThermForm AS FORM loThermForm = _SCREEN.oThermForm IF NOT EMPTY(tcLabelText) loThermForm.ThermLabel.CAPTION = tcLabelText ENDIF IF NOT EMPTY(tcTitleText) loThermForm.CAPTION = tcTitleText ENDIF IF tnPercent = -1 loThermForm.Therm.Marquee = .T. ELSE IF loThermForm.Therm.Marquee = .T. loThermForm.Therm.Marquee = .F. ENDIF loThermForm.Therm.VALUE = tnPercent ENDIF loThermForm.VISIBLE = .T. RETURN PROCEDURE CreateTherm LOCAL loForm AS FORM loForm = CREATEOBJECT("FORM") _SCREEN.oThermForm = loForm LOCAL lnBorder, liThermHeight, liThermWidth, liThermTop, liThermLeft lnBorder = 7 WITH loForm AS FORM .SCALEMODE = 3 && Pixels .HEIGHT = 48 .HALFHEIGHTCAPTION = .T. .WIDTH = 300 .AUTOCENTER = .T. .BORDERSTYLE = 3 && Fixed dialog .CONTROLBOX = .F. .CLOSABLE = .F. .MAXBUTTON = .F. .MINBUTTON = .F. .MOVABLE = .F. .ALWAYSONTOP = .T. .ALLOWOUTPUT = .F. .NEWOBJECT("Therm","ctl32_progressbar", "PR_ctl32_progressbar.vcx", LOCFILE("FoxyPreviewer.app")) .NEWOBJECT("ThermLabel", "Label") .ThermLabel.VISIBLE = .T. .ThermLabel.FONTBOLD = .T. .ThermLabel.TOP = 4 .ThermLabel.WIDTH = .WIDTH - (lnBorder * 2) .ThermLabel.ALIGNMENT = 2 && Center liThermHeight = .HEIGHT - (lnBorder * 2) - .ThermLabel.HEIGHT liThermWidth = .WIDTH - (lnBorder * 2) .VISIBLE = .T. ENDWITH liThermTop = lnBorder + 20 liThermLeft = lnBorder WITH loForm.Therm .TOP = liThermTop .LEFT = liThermLeft .HEIGHT = liThermHeight .WIDTH = liThermWidth .MarqueeSpeed = 30 .MarqueeAnimationSpeed = 30 .VISIBLE = .T. .CAPTION = "" ENDWITH ENDPROC
Quiero "Traducir" este código:
ResponderEliminarDEFINE CLASS TERMOMETRO AS form
SHOWWINDOW = 1
TOP = 196
LEFT = 142
HEIGHT = 75
WIDTH = 460
AUTOCENTER = .T.
BORDERSTYLE = 2
CLOSABLE = .F.
CONTROLBOX = .F.
MAXBUTTON = .F.
MINBUTTON = .F.
TITLEBAR = 0
ALWAYSONTOP = .F.
IPERCENTAGE = 0
IBASIS = 0
CCURRENTTASK = ''
SHPTHERMBARMAXWIDTH = 422
CTHERMREF = ""
NIMAGEN = 1
CONTADOR = 0
NAME = "thermometer"
ADD OBJECT LBLTITLE AS LABEL WITH FONTNAME = "ARIAL", FONTSIZE = 8, FONTBOLD = .T., BACKSTYLE = ;
0, BACKCOLOR = RGB(192, 192, 192), CAPTION = "", HEIGHT = 16, LEFT = 16, TOP = 11, WIDTH = ;
429, WORDWRAP = .F., NAME = "lblTitle"
ADD OBJECT LBLTASK AS LABEL WITH FONTNAME = "ARIAL", FONTSIZE = 7, BACKSTYLE = 0, BACKCOLOR = ;
RGB(192, 192, 192), FORECOLOR = RGB(0, 0, 0), CAPTION = "", HEIGHT = 50, LEFT = 16, TOP = ;
29, WIDTH = 429, WORDWRAP = .T., NAME = "lblTask"
* color del cuadro donde se pone la barra
ADD OBJECT CUADRO AS TEXTBOX WITH ENABLED = .F., BORDERSTYLE = 0, BACKSTYLE = 1, ;
DISABLEDBACKCOLOR = RGB(0, 0, 0), SPECIALEFFECT = 0, HEIGHT = 18, LEFT = 11, TOP = 50, ;
WIDTH = 437, NAME = "Cuadro"
* color de la barra que crece (Verde "Windows7")
ADD OBJECT SHPTHERMBAR AS SHAPE WITH BORDERSTYLE = 0, FILLCOLOR = RGB(0, 128, 32), FILLSTYLE = 0, ;
HEIGHT = 12, LEFT = 14, TOP = 53, WIDTH = 0, NAME = "shpThermBar"
ADD OBJECT LBLPERCENTAGE AS LABEL WITH FONTNAME = "ARIAL", FONTSIZE = 7, BACKSTYLE = 0, ;
CAPTION = "0%", FORECOLOR = RGB(0, 0, 0), HEIGHT = 15, LEFT = 425, TOP = 34, WIDTH = 30, ;
NAME = "lblPercentage"
**
PROCEDURE complete
PARAMETER M.CTASK
PRIVATE ISECONDS
IF PARAMETERS()=0
M.CTASK = 'Terminado'
ENDIF
THIS.UPDATE(100, M.CTASK)
ENDPROC
**
PROCEDURE UpdateTaskMessage
PARAMETER CTASK
THIS.CCURRENTTASK = M.CTASK
THIS.LBLTASK.CAPTION = THIS.CCURRENTTASK
ENDPROC
**
PROCEDURE update
PARAMETER IPROGRESS, CTASK
IF PARAMETERS()>=2 .AND. TYPE('m.cTask')='C'
THIS.CCURRENTTASK = M.CTASK
ENDIF
IF .NOT. THIS.LBLTASK.CAPTION==THIS.CCURRENTTASK
THIS.LBLTASK.CAPTION = THIS.CCURRENTTASK
ENDIF
IF THIS.IBASIS<>0
M.IPERCENTAGE = INT((M.IPROGRESS/THIS.IBASIS)*100)
ELSE
M.IPERCENTAGE = M.IPROGRESS
ENDIF
M.IPERCENTAGE = MIN(100, MAX(0, M.IPERCENTAGE))
IF M.IPERCENTAGE=THIS.IPERCENTAGE
RETURN
ENDIF
THIS.SHPTHERMBAR.WIDTH = INT((THIS.SHPTHERMBARMAXWIDTH)*M.IPERCENTAGE/100)
THIS.LBLPERCENTAGE.CAPTION = ALLTRIM(STR(M.IPERCENTAGE, 3))+'%'
THIS.IPERCENTAGE = M.IPERCENTAGE
ENDPROC
PROCEDURE Init
PARAMETER CTITLE, NOBARRA
DO CTL32.PRG
DO SYSTEM.APP
THIS.LBLTITLE.CAPTION = IIF(EMPTY(M.CTITLE), '', M.CTITLE)
LOCAL CCOLOR
IF FONTMETRIC(1, "MS Sans Serif", 8, '')<>13 .OR. FONTMETRIC(4, "MS Sans Serif", 8, '')<>2 .OR. ;
FONTMETRIC(6, "MS Sans Serif", 8, '')<>5 .OR. FONTMETRIC(7, "MS Sans Serif", 8, '')<>11
THIS.SETALL('FontName', "tahoma")
ENDIF
M.CCOLOR = RGBSCHEME(1, 2)
M.CCOLOR = 'rgb('+SUBSTR(M.CCOLOR, AT(',', M.CCOLOR, 3)+1)
*THIS.BACKCOLOR = &CCOLOR
THIS.BackColor=RGB(255,255,255)
IF NOBARRA
THIS.LBLPERCENTAGE.VISIBLE = .F.
THIS.SHPTHERMBAR.VISIBLE = .F.
THIS.CUADRO.VISIBLE = .F.
THIS.HEIGHT = 75
ENDIF
ENDPROC
a CTL32_progressbar, ¿Q es lo que debo cambiar? ya que supongo que no será mucho
Gracias
3008102508
ICQ 279 364 380
Face: +573008102508
MSN: eres_un_vago@hotmail.com
Mail: eres_un_vago@yahoo.es
Whatsapp: +573008102508
Skype: eres_un_vago