2011-01-21

Using the CTL32 ProgressBar from FoxyPreviewer

Foxypreviewer.app is a collection of classes. Inside the APP there are several classes, that you can access directly using VFP.
Recently I received a request to show how the ctl32 progressbar could be used directly.

Thats's really simple ! The key command is NEWOBJECT(), that allows us to access classes from an external EXE or APP.
First of all the author of this gem, the CTL32 progressbar is Carlos Alloatti. For the complete information on how to use it, please go directly to the CTL32 website: www.ctl32.com.ar

Usage:


=DOTHERM(90, "Caption", "TitleBar") && shows the regular progressbar with 90%


=DOTHERM(-1, "Caption", "TitleBar") && the -1 value in the 1st parameter brings the marquee cool effect


=DOTHERM() && turns off the progressbar







* doTherm.prg
* =doTherm(90, "texto Label", "titulo")
* =doTherm(-1, "teste2", "titulo") && continuo
* =doTherm() && desliga

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("FoxyFreviewer.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