Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Baseclasses not te be subclassed
Message
General information
Forum:
Visual FoxPro
Category:
Object Oriented Programming
Miscellaneous
Thread ID:
00149269
Message ID:
00149494
Views:
16
>>Columns, headers and pages cannot (visualy) be subclassed.
>>Why is this and how should one deal with this?
>>
>>Example: when a user clicks a page in a pageframe i want its caption to turn bold so the user can see he/she has seen the page.
>>I now have 'This.FontBold=.T.' in the Click() of all the applications pages (about 70 pages total). Now the user decided he/she doesn't want the page's caption to turn bold but red. Now i have to change the code at 70 places! This cannot be the goal of OOP.
>>
>>For properties i can use SetAll() but there's no such function for methods.
>>
>>I wonder how you guys deal with this, please let me know.
>>
>>
>>Thanks,
>>
>>Marco.
>>
>>BTW: Optionbuttons can be subclassed, so can optiongroups. Subclassed optionbuttons cannot be used in a subclassed optiongroup!?!?!?!?
>
>You can subclass pages, but it may be more of a problem than changing the code in 70 places. Here's what I did because I needed my pages to be able to hold a record number:
>
>

>DEFINE CLASS TripPage AS PAGE
> TripID = 0
> PROCEDURE ACTIVATE
> SELECT trips
> SEEK(THIS.TripID)
> THISFORM.REFRESH()
>ENDPROC
>ENDDEFINE
>
>Here's where I add the pages to the pageframe:
>
>i = 2
>SELECT trips
>WITH thisform.tsPageFrame1
> .pagecount = 1
> SCAN FOR trips.igroup = thisform.group
> lcPageName = SYS(2015)
> .AddObject(lcPageName,'TripPage')
> .pages[i].TripID = trips.tripkey
> .pages[i].caption = trips.cname
> i = i + 1
> SELECT trips
> ENDSCAN
> lcOldPageName = .pages[1].name
> .removeobject(lcOldPageName)
>...
>
>-Michelle
>
>
><\PRE>

I always try to use the approach when I create the class (usually invisible Label) with all necessary properties and methods and just drop it in all pages/containers which need this functionality. Specific properties can be easily customized for each instance if necessary. In case of using for Pages I usually place the code in UIEnable event method so it fires automatically on changing pages. I realize that the Line class is more lightweight, but Label is used because it is easy for developer to find it on pages (it usually has the distinct ForeColor and it is invisible at the runtime). And the caption says what this label does. Like: "TabChanger", "IdFinder" ...
Nick Neklioudov
Universal Thread Consultant
3 times Microsoft MVP - Visual FoxPro

"I have not failed. I've just found 10,000 ways that don't work." - Thomas Edison
Previous
Reply
Map
View

Click here to load this message in the networking platform