Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Odometer - Percentage Complete 1

Status
Not open for further replies.

RandyDeWitt

IS-IT--Management
Dec 16, 2002
14
US
Hello,

I am shamelessy trying to expand upon Marcia Akins code sample for an odometer in her 1001 Things you wanted to Know about Visual Foxpro.

I created a container class that holds the update method from her tbrprog class then place that object on my form. I execute it using,

IF MOD(lnCnt,10) = 0
thisform.objodometer.Update( INT((lnCnt/lnTotal)*100), 'Processing # ' + PADL(lnCnt,3))
ENDIF
lnCnt = lnCnt + 1

My problem is, when the shape covers the % Complete label, her label turns white and remains visible, while mine stays blue and gets covered by the ever widening shape.

How do I make my label go from blue to white when it is covered by the shape?

Here is the code for my new class. Thanks in advance for any assistance and thanks to Marcia for providing the framework.

**************************************************
*-- Class: xcntodo (c:\projects\common\class\genclass.vcx)
*-- ParentClass: xcntstd (c:\projects\common\class\genclass.vcx)
*-- BaseClass: container
*-- Time Stamp: 03/23/06 11:32:06 AM
*
DEFINE CLASS xcntodo AS xcntstd


Width = 304
Height = 49
BorderWidth = 0
Name = "xcntodo"


ADD OBJECT lbltitle AS xlblstd WITH ;
AutoSize = .T., ;
Caption = "Not started.", ;
Height = 17, ;
Left = 0, ;
Top = 0, ;
Width = 65, ;
Name = "lbltitle"


ADD OBJECT txtoutline AS xtxtstd WITH ;
BackStyle = 1, ;
BorderStyle = 1, ;
Enabled = .F., ;
Height = 22, ;
Left = 0, ;
Top = 24, ;
Width = 302, ;
Style = 0, ;
Name = "txtoutline"


ADD OBJECT shpodometer AS xshpstd WITH ;
Top = 24, ;
Left = 0, ;
Height = 19, ;
Width = 0, ;
BackStyle = 1, ;
BorderStyle = 1, ;
BorderWidth = 0, ;
DrawMode = 10, ;
SpecialEffect = 0, ;
BackColor = RGB(0,0,255), ;
BorderColor = RGB(0,0,255), ;
Name = "shpodometer"


ADD OBJECT lblpercent AS label WITH ;
AutoSize = .T., ;
BackStyle = 0, ;
Caption = "0%", ;
Height = 17, ;
Left = 139, ;
Top = 28, ;
Width = 20, ;
ColorSource = 4, ;
ColorScheme = 1, ;
ForeColor = RGB(0,0,255), ;
Name = "lblPercent"


*-- Displays progress bar
PROCEDURE update
LPARAMETERS tnNewVal, tcText
thisform.LockScreen = .T.
WITH this
*** Update Progress Bar
tnNewVal = IIF(tnNewVal < 0, 0, IIF(tnNewVal > 100, 100, tnNewVal))
.lblPercent.Caption = LTRIM(str(tnNewVal) + '%')
.shpodometer.Width = (3 * tnNewVal)
*** Check Title
IF TYPE( "tcText" ) = "C" AND ! EMPTY( tcText )
.lblTitle.Caption = tcText
ENDIF
ENDWITH
thisform.LockScreen = .F.
ENDPROC


ENDDEFINE
*
*-- EndDefine: xcntodo
**************************************************
 
I don't have Marcia's code handy to compare what you've changed. But it looks like you've got the backstyle of the shape set to opaque. Make it transparent.

The color shifting is handled by shape.DrawMode -- you'll have to fiddle with that setting to get the bitmasking to work the way you want.
 
Thanks danfreeman,

I set the draw mode to be 16, white, and am able to see the percentage label. I would like to leave the shape colored blue, but if not possible, I can live with the white. Thanks for pointing me in the general direction.
 
RandyDeWitt,

Set the DrawMode to 14 and make sure that the shape is on top of the label (zorder). Here's a runnable example:

Code:
PUBLIC oform1
oform1=NEWOBJECT("form1")
oform1.Show
RETURN

DEFINE CLASS form1 AS form

	DoCreate = .T.
	Caption = "Form1"
	Name = "Form1"

	ADD OBJECT label1 AS label WITH ;
		AutoSize = .T., ;
		FontName = "Tahoma", ;
		FontSize = 14, ;
		BackStyle = 0, ;
		Caption = "Visual FoxPro Rocks", ;
		Height = 25, ;
		Left = 96, ;
		Top = 84, ;
		Width = 166, ;
		Name = "Label1"
		
	ADD OBJECT shape1 AS shape WITH ;
		Top = 72, ;
		Left = 48, ;
		Height = 48, ;
		Width = 127, ;
		DrawMode = 14, ;
		BackColor = RGB(0,0,255), ;
		Name = "Shape1"
ENDDEFINE

boyd.gif

SweetPotato Software Website
My Blog
 
Thanks Craig!

I demo'd DrawMode in Virginia Beach when VFP3 was in beta and haven't touched it since. Couldn't quite remember which setting was needed here.
 
DrawMode was one of the absolutely hardest pieces I wrote in HackFox. As the acknowledgements note, Tom Meeks helped me get it.

Tamar
 
Dan, Craig, Tamar;

Thanks so much for the assistance. It never dawned on me that the order in which objects are placed on the container would affect the outcome. I thought I understood the example that Marcia wrote, but you all have sent me straight!

Thanks again and Craig, I awarded a star for your accurate and timely response.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top