Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Subclassing OptionButton
Message
From
05/10/1998 10:19:43
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
05/10/1998 09:29:26
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Miscellaneous
Thread ID:
00143846
Message ID:
00143867
Views:
24
>Am trying to add an OptionGroup to my class library and want to incorporate my own properties & methods with the associated OptionButtons.
>
>However the OptionButton is not one of those available for subclassing in the Class Browser.
>
>The ButtonCount of the OptionGroup will vary each time I add my new class to a form. Will I have to create the OptionGroup class with the maximum number of Buttons forseen and then change the ButtonCount property to a lower number ? Or is there a better way ?
>
>- Werner
Werner,
You could subclass the "buttons" nonvisually.
oForm = createobject("Form")
with oForm
	.addobject("MyoptGrp","Optiongroup")
	with .MyoptGrp
		.buttoncount = 5
		for ix = 1 to 5
			.removeobject("Option"+ltrim(str(ix)))
			.addobject("Option"+ltrim(str(ix)),"myoption",;
				"Hello"+ltrim(str(ix)), ix)
		endfor
		.setall("Visible",.t.)
		.autosize = .t.
		.visible = .t.
	endwith
	.addobject("myquitter","myquit")
	.myquitter.visible = .t.
endwith
oForm.show
read events

define class myoption as optionbutton
	fontname = "Arial"
	fontbold = .t.
	fontitalic = .t.
	autosize = .t.
	procedure init
	lparameters tcCaption, tnPos
		this.caption = tcCaption
		this.left = 1
		this.Top  = tnPos * (this.height + 2)
	endproc

	procedure click
		=rand(-1)
		this.forecolor = rgb(int(rand()*255), ;
	                         int(rand()*255), ;
	                         int(rand()*255))
	endproc
enddefine

define class myquit as commandbutton
Autosize = .T.
Caption="Close"
procedure init
	this.left = this.parent.width - this.width - 2
	this.top  = this.parent.height - this.height - 2
endproc
procedure click
    release all
	clear events
endproc
enddefine
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform