Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Amending Commandgroup Class
Message
From
29/07/1999 01:47:28
Dragan Nedeljkovich
Now officially retired
Zrenjanin, Serbia
 
 
To
26/07/1999 15:24:01
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Miscellaneous
Thread ID:
00246273
Message ID:
00247533
Views:
30
>Made amendments to the command button class. Now want to amend my original commandgroup by having it use my amended command button.
>
>Assumed it would be similar to what I did with the form. scx, but only shows 3 records. Although it has references to the existing buttons, there is no obvious place to adjust the class references to them.
>
>If I use the class browser I can see that they are still using the vfp base class but can't see any way to change that.
>
>If I try adding one of my new buttons - with a view to changing them piecemeal - I get told I can't add an object to another if it isn't a container object (which I thought the commandgroup was)
>
>If I try creating a new class 'based on' a commandgroup - it seems that the 'base' is still the vfp base and not my new class library and I can't see an obvious option in Tools/Options to change that.
>
>So How?

By dirty tricks (beware the sticky nickname...). In your commandgroup class event addobject, do something like

this.addobject("yourbuttonclass")
nodefault

I tried it with V5.0a, but it doesn't work. It may work with vfp6, if we put this in buttoncount_assign method. Well, not that easy, it would require some calculation of how many elements should be put there etc, or some should be removed.

Instead I used a different approach: kick the default and stuff your own in the .init (but it requires you to add default buttons at design time, destroys them and then replaces them with your buttons). It actually copies some of the properties of the old buttons, i.e. the design-time properties, but then this also means you can't have your buttons with local method code - they'll run their default class code, so it's just a single-shot operation. Many properties will also get lost, so playing around with them at design time is just a waste.

The ability to define the default button class for button groups at design time (so when you add buttons, the group would automaGically add your buttons) is my long-time (fox)wish. Not just button groups, it goes for pageframes/pages, grids/columns.
PROCEDURE Init
	with this
		.visible=.t.
		local i, maxwidth, _cap, _top, _width, oldname, newname
		maxwidth=0
		if .buttoncount=0
			.buttoncount=1
		endif
		for i=1 to .buttoncount
			oldname=.buttons[i].name
			with eval("."+oldname)
				_cap=.caption
				_top=.top
				_width=.width
			endwith
			.removeobject(oldname)
			newname="gButton"+allt(str(i))
			.addobject(newname, "MyCommandButtonClass")
			with eval("."+newname)
				.visible=.t.
				.caption=_cap
				.top=_top
				.width=_width
			endwith
			maxwidth=max(maxwidth, _width)
		endfor
		.height=.buttons(.buttoncount).top+.buttons(.buttoncount).height
		.width=maxwidth
	endwith
ENDPROC

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