Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Shading a checkbox
Message
From
10/07/2011 07:04:18
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
 
 
To
07/07/2011 15:37:27
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows 7
Miscellaneous
Thread ID:
01517604
Message ID:
01517836
Views:
80
>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.

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform