Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Add objects at runtime not working (AGAIN)
Message
De
20/11/2008 09:40:38
Dragan Nedeljkovich (En ligne)
Now officially retired
Zrenjanin, Serbia
 
 
À
20/11/2008 07:30:57
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Versions des environnements
Visual FoxPro:
VFP 9
OS:
Vista
Divers
Thread ID:
01363081
Message ID:
01363148
Vues:
14
This message has been marked as a message which has helped to the initial question of the thread.
>I haven't used adding objects at runtime at a really long time but now twice I tried and failed;
>the following is supposed to add a time scale to a form like this
>
>7 8 9 10
>|______|______|______| etc
>and then scale when resized
>the objects get created and are labelled visible in the debugger but they DON'T show on the form once initialized
>
>what could I be doing wrong???

I found that I've done that, once... 11 years ago... see below, there's a trick to it. It may count a dirty trick nowadays, but if it worked then, it should work today.

>This method is called from the init of the form.
>
>LOCAL lnWidth,lnNumTicks,lnStratTick,lnTickLen,I
>lnWidth		= thisform.grd1.Width
>lnNumTicks	= 17
>lnStratTick	= 7
>lnTickLen	= lnWidth/lnNumTicks
>DIMENSION thisform.aScale[lnNumTicks+1]
>DIMENSION thisform.aTicksLabel[lnNumTicks+1]
>FOR I = 1 TO lnNumTicks+1

*-- here, this is what won't work, i.e. won't give the results you want:

>*	thisform.aScale[m.I]	= CREATEOBJECT("Line")

*-- instead, 

       thisform.AddObject('thisform.aScale[m.I]', 'line')

>	thisform.aScale[m.I].top	= 262
>	thisform.aScale[m.I].height = 12
>	thisform.aScale[m.I].width	= 1
>	thisform.aScale[m.I].left	= 3+(m.I-1)*lnTickLen
>	thisform.aScale[m.I].visible= .t.

* likewise
>	thisform.addobject("thisform.aTicksLabel[m.I]", "Label")
>	thisform.aTicksLabel[m.I].caption	= TRANSFORM(6+m.i)
>	thisform.aTicksLabel[m.I].height	= 15
>	thisform.aTicksLabel[m.I].fontname	= 'Arial'
>	thisform.aTicksLabel[m.I].fontsize	= 8
>	thisform.aTicksLabel[m.I].fontitalic= .t.
>	DO CASE
>	CASE m.I = lnStratTick
>		thisform.aTicksLabel[m.I].caption	= TRANSFORM(6+m.i)+" am"
>	
>	CASE m.I = 12-(lnStratTick+2)
>		thisform.aTicksLabel[m.I].caption	= TRANSFORM(6+m.i)+" Noon"
>
>	CASE m.I = 12-(lnStratTick+2)+ 1
>		thisform.aTicksLabel[m.I].caption	= TRANSFORM(6+m.i)+" pm"
>
>	CASE m.I = lnNumTicks + 1
>		thisform.aTicksLabel[m.I].caption	= TRANSFORM(6+m.i)+" pm"
>
>	OTHERWISE
>		
>	ENDCASE
>	thisform.aTicksLabel[m.I].left	= 3+(m.I-1)*lnTickLen
>        thisform.aTicksLabel[m.I].visible	= .t.
>	
>ENDFOR 
>thisform.AddObject (oScaleLine,"LIne")
>WITH thisform.oScaleLine
>	.top	= 276
>	.height	= 1
>	.width	= lnWidth
>	.left	= 3
>	.visible= .t.
>ENDWITH 
>
>
>Thanks again
>
>
>Peter

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform