VFP progress bar class author: unknown Posted by: unknown Hits: 301 articles entry: windshadow
Using a progress bar in the application can visually display the percentage of the current processing completed, the traditional implementation method of this function is to process directly in the program source code, which is obviously a heavy and lack of flexibility. 1. Building a class schedule should contain two objects: a graphic of a display processing process and a label for a percentage value. First, create a custom class based on the inclusive, named ProgressBar, and create a graphic Barshape, height and progressbar in it, and the width is preset to 0, and the graph is set to light. (Such as light blue). Add label objects TXTLABEL, location, width enough to accomplish the maximum body 100%, color is dark. In view of the actual application, the size of this control is to interact, so the encoding of the init event for the ProgressBar control is: this.barshape.Height = this.HeightThis.barshape.Width = 0this.txtLabel.Alignment = 2THIS. TXTLABEL.LEFT = (this.width-this.txtlabel.width) /2this.txtLabel.top = (this.height-this.txtLabel.Height) /2this.txtLabel.caption = 0% this.Percent = 0 Custom Attributes Percent is used to track changes in the current percentage of records; custom method SHOW is used to display this change while graphics and text. Method Show code: parameters lppercent * - legality test if lppercent <0 lppercent = 0 endif if lppercent> 100 lppercent = 100 Endif * - Refresh display this.Percent = lppercentthis.barshape.width = this.width * (LPPERCENT / 100) this.txtLabel.caption = Allt (Str (LPPercent)) % this.refresh This time, the progress bar class is designed to store it in a custom class library, assume that the class library is: MYLIB.VCX. 2. Application Example Ren a custom class library MYLIB.VCX once in the VFP, you can act as a timer or loop can be activated by timer or looping in the application form.