Re: Common Interface for objects that expose VB-drawing-API
- From: "Mike D Sutton" <EDais@xxxxxxxx>
- Date: Wed, 24 May 2006 09:47:52 +0100
VB.Form, VB.PictureBox and VB.Printer have a TextWidth and TextHeight-method, they also share these VB-Drawing methods
like PaintPicture, PSet, Line, Circle, Print, Cls
and props like CurrentX, CurrentY, DrawMode, DrawWidth, FillColor
and some more.
Is there a name for a common COM-interface that these VB-objects implement, so that if i can specify this
interface-type for an
argument of a method, rather then the generic 'Object'-type?
I am replacing controls that have multiple cols displaying
text-entries like listviews, grids, option-groups etc by text
printed onto either pictureboxes, forms or the printer-object
and i need to get max text-width and -height of the list-control.
So it was nice, although not necessary, if i could pass the control
that executes TextWidth and TextHeight by a strong type.
My current signature is:
Public Sub GetMaxTextEntend _
( _
oCtrl As Object, _
oNewContainer As Object, _
ByRef sngMaxTextWidth As Single, _
ByRef sngMaxTextHeight As Single _
)
where
oNewContainer As Object,
should by replaced by
oNewContainer As IVBContainerForDrawing,
Now does this interface exist and does it have a name?
Simple answer is no, there is no (public) interface defined that exposes these methods.
You could however write a reasonably simple little class which exposes these methods, and internally stores an Object.
In the Property Set for the internal object, validate the object you're being passed to make sure it implements the
required methods (either by calling them and trapping errors, or just use TypeOf.)
Not quite as elegant, but it is type safe and will offer intellisense at design time.
Hope this helps,
Mike
- Microsoft Visual Basic MVP -
E-Mail: EDais@xxxxxxxx
WWW: Http://EDais.mvps.org/
.
- Follow-Ups:
- Re: Common Interface for objects that expose VB-drawing-API
- From: Alexander Mueller
- Re: Common Interface for objects that expose VB-drawing-API
- References:
- Common Interface for objects that expose VB-drawing-API
- From: Alexander Mueller
- Common Interface for objects that expose VB-drawing-API
- Prev by Date: Re: Update a graphic and save it
- Next by Date: Re: Common Interface for objects that expose VB-drawing-API
- Previous by thread: Common Interface for objects that expose VB-drawing-API
- Next by thread: Re: Common Interface for objects that expose VB-drawing-API
- Index(es):
Loading