Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How does Progressbar work?
Message
De
03/06/2003 12:09:04
 
 
À
03/06/2003 11:24:16
Information générale
Forum:
Visual FoxPro
Catégorie:
Contrôles ActiveX en VFP
Divers
Thread ID:
00795703
Message ID:
00795744
Vues:
15
Hi Larry.

I have tried to add a progressbar to a screen and can't figure out how to make it work (this IS embarrassing). All I'm trying to do is show the progress while scanning through a fairly large table. I've given up. Please help.

This is what we had to say about it in Chapter 9 of MegaFox: 1002 Things You Wanted to Know About Extending VFP

How do I use the Windows progress bar? (Example: CH09.vcx::xTherm; frmprogbar.scx)

You can see, from Table 9.3 that the progress bar control is actually a class named ‘MSComCtlLib.ProgCtrl’ that is contained in MSComctl.ocx. We created, exactly as described above, a sub-class of this control, in our CH09.vcx visual class library, named ‘xTherm’.

If you examine this class, you will notice that the OleClass property (filled in when we selected the control from the dialog) includes the version number. Now, we did say that you should, where possible, avoid specifying the version number. However, even if you edit the class to remove the version number (you need to open the class library as a table and edit the Properties memo field directly to do this) it still appears in the property sheet. This is because the properties sheet shows the full name of class that was actually used to create the control, not merely the name that was defined in your class.

Setting up the progress bar class
The Progress Bar control, as illustrated in Figure 9.3, exposes several properties. However, for the moment we are only interested in three of them:

• Min Defines the lower limit (0%) of the range represented by the progress bar
• Max Defines the upper limit (100%) of the range represented by the progress bar
• Scrolling Defines the appearance of the progress bar, possible values are either ‘0 ccScrollingStandard’ (bar is a series of discrete blocks) or ‘1 ccScrollingSmooth’ (bar is continuous)

In addition the control has a ‘value’ property whose content actually determines how much of the progress bar is displayed. We intend showing this class working on a ‘percentage complete’ basis so, for now, we can leave the Min and Max properties at their default values. However, to avoid errors, we have added a custom assign method to the Value property to ensure that any specified value falls into the defined range, as illustrated here:
LPARAMETERS tnNewVal
IF VARTYPE( tnNewVal ) # "N" OR EMPTY( tnNewVal ) OR tnNewVal < This.Min
  *** Set to Min Value if invalid, nothing or less than Min
  lnPCDone = This.Min
ELSE
  *** Force to Max Value if greater than Max
  lnPCDone = IIF( BETWEEN( tnNewVal, This.Min, This.Max ), tnNewVal, This.Max )
ENDIF
*** Update the display
This.Value = lnPCDone
The only other property we need to set is the ‘Scrolling’ property. By default the progress bar shows a series of discrete blocks as the value is incremented toward the maximum (See Figure 9.4)
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform