Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Shading a checkbox
Message
De
10/07/2011 11:15:34
 
 
À
10/07/2011 07:04:18
Dragan Nedeljkovich (En ligne)
Now officially retired
Zrenjanin, Serbia
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows 7
Divers
Thread ID:
01517604
Message ID:
01517840
Vues:
84
>>As others pointed out to you, the coloring with a checkbox are natively limited. However OnyToo has published a class to colour a checkbox.
>
>Too bad the code has to live on the form and to know exactly where the checkbox is. This becomes very complicated when you have checkboxes at unknown depths of containership - like the form.container.pageframe.page.container.pageframe.page.container.checkbox that I have, plus at least one of the intermediate levels can be resized by the user, and of course the whole form can be resized and there's no guarantee that this frame around the checkbox will move with it.
>
>But I think the idea is right - the checkbox itself can draw a shape around itself and set its zorder, and then change the drawwidth and bordercolor of the shape (in .refresh and/or .interactivechange).
>
>So I came up with this:
>
>
>DEFINE CLASS mychk AS checkbox
>
>	hasfocus = .F.
>
>	PROCEDURE hasfocus_assign(tHasFocus)
>		lcShapeName="shp"+SUBSTR(THIS.NAME,3)
>		IF NOT PEMSTATUS(THIS.PARENT, lcShapeName,5)
>			THIS.PARENT.ADDOBJECT(lcShapeName, "shape")
>		ENDIF
>		loShape=GETPEM(THIS.PARENT, lcShapeName)
>		WITH loShape AS SHAPE
>			.BORDERCOLOR=0
>			.BORDERSTYLE= 3
>			.BORDERWIDTH=2
>			.BACKSTYLE= 0
>			.TOP=THIS.TOP-1
>			.HEIGHT=THIS.HEIGHT+2
>			.LEFT=THIS.LEFT-1
>			.WIDTH=THIS.WIDTH+2
>			.VISIBLE=tHasFocus
>		ENDWITH
>		THIS.hasfocus = tHasFocus
>	ENDPROC
>
>
>	PROCEDURE LostFocus
>		this.hasfocus=.f.
>	ENDPROC
>
>
>	PROCEDURE GotFocus
>		this.hasfocus=.t.
>	ENDPROC
>
>ENDDEFINE
>You may want to play with the properties of the shape; this is just a proof of concept. Tested, works, looks good enough.

Dragan,

Your idea is also very good, I had solved this by parameterizing the checkbox with all his coordinates. On second thought I think your idea is better thank you for sharing.

Regards,

Koen
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform