-
Inheritance
I know VB7 is still another year a way but I was wondering if inheritance
will let you eliminate (or hide) a property/method from your base class.
For example, let's say I want to create a graphical command button control
inherited from VB's standard CommandButton control. It works just like a
standard command button except it would use a predefined BMP for its Picture
property. Because this new control is always graphical, there's no need
for a Style property. Could I eliminate the Style property from my derived
control's interface? If MS hasn't indicated how VB7 handles this problem,
how do other languages handle this?
- Jim
-
Re: Inheritance
"Jim Pragit" <James.Pragit@BakerNet.com> wrote in message
news:38e22898$1@news.devx.com...
> For example, let's say I want to create a graphical command button control
> inherited from VB's standard CommandButton control. It works just like a
> standard command button except it would use a predefined BMP for its
Picture
> property. Because this new control is always graphical, there's no need
> for a Style property. Could I eliminate the Style property from my
derived
> control's interface? If MS hasn't indicated how VB7 handles this problem,
> how do other languages handle this?
In Delphi they create a base class called TCustomXXX that contains all of
the components functionality. They then declare a TXXX class that contains
no functionality but exposes all of the protected properties as published.
The TXXX component is what developers actually drop on forms. Thus is you
wanted to create a new control and hide a property, simply derive it from
the TCustomXXX class and only expose the properties you want to. This works
great in Delphi since it's component architecture is source code based (i.e.
you have the source code for every component that ships with Delphi).
Gerald
-
Re: Inheritance
> For example, let's say I want to create a graphical command button control
> inherited from VB's standard CommandButton control. It works just like a
> standard command button except it would use a predefined BMP for its
Picture
> property. Because this new control is always graphical, there's no need
> for a Style property. Could I eliminate the Style property from my
derived
> control's interface? If MS hasn't indicated how VB7 handles this problem,
> how do other languages handle this?
I think this is already possible in VB6.
Just draw a UserControl, drop a CommandButton on it, and expose whatever
interface you like.
Or didn't understand the question correctly?
Ronald
-
Re: Inheritance
Well, yes it's possible in VB6. What I was asking about is how we might do
it in VB7 using inheritance.
- Jim
"Ronald Dolman" <rdolman@email.nl> wrote:
>> For example, let's say I want to create a graphical command button control
>> inherited from VB's standard CommandButton control. It works just like
a
>> standard command button except it would use a predefined BMP for its
>Picture
>> property. Because this new control is always graphical, there's no need
>> for a Style property. Could I eliminate the Style property from my
>derived
>> control's interface? If MS hasn't indicated how VB7 handles this problem,
>> how do other languages handle this?
>
>I think this is already possible in VB6.
>Just draw a UserControl, drop a CommandButton on it, and expose whatever
>interface you like.
>Or didn't understand the question correctly?
>
>Ronald
>
>
-
Re: Inheritance
I see that you've had an answer for Delphi. Here's the way you'd do it in
Visual FoxPro. I'm limiting my answer to a control, as you asked - in a non-visual
class, it's basically the same thing though.
You'd subclass the commandbutton control, set the Style property to graphical,
and then protect that property. That's basically it. FWIW, from a practical
perspective, I don't see a reason to do this just to protect the one property,
but that is how you'd do it...
yag
"Jim Pragit" <James.Pragit@BakerNet.com> wrote:
>
>I know VB7 is still another year a way but I was wondering if inheritance
>will let you eliminate (or hide) a property/method from your base class.
>
>
>For example, let's say I want to create a graphical command button control
>inherited from VB's standard CommandButton control. It works just like
a
>standard command button except it would use a predefined BMP for its Picture
>property. Because this new control is always graphical, there's no need
>for a Style property. Could I eliminate the Style property from my derived
>control's interface? If MS hasn't indicated how VB7 handles this problem,
>how do other languages handle this?
>
>- Jim
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks