Home > Archive > Visual Basic > February 2005 > Writing new picturebox member
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Writing new picturebox member
|
|
| Marko Pinteric 2005-02-28, 8:55 am |
| Hello,
I want to define a new picturebox member. For example,
PictureBox.Circle member already exists, I would like to define
PictureBox.Square member. Is this possible to do and how?
Thank you for your answers,
Marko
| |
| Mike D Sutton 2005-02-28, 8:55 am |
| > I want to define a new picturebox member. For example,
> PictureBox.Circle member already exists, I would like to define
> PictureBox.Square member. Is this possible to do and how?
Nope, you can however write a UserControl that encapsulates a picture box and adds this additional functionality. IMO
though I'd just write a routine which takes a PictureBox as an input parameter, or write a library of additional drawing
commands which draw to a control's surface or DC handle such as the APIDraw library on my site.
Hope this helps,
Mike
- Microsoft Visual Basic MVP -
E-Mail: EDais@mvps.org
WWW: Http://EDais.mvps.org/
| |
| Rick Rothstein 2005-02-28, 8:55 am |
| > I want to define a new picturebox member. For example,
> PictureBox.Circle member already exists, I would like to define
> PictureBox.Square member. Is this possible to do and how?
Use the Line method with the optional B or BF argument. For example,
Picture1.Line (1000, 500)-(2000, 1500), vbRed, BF
Rick
| |
| Marko Pinteric 2005-02-28, 8:55 am |
|
"...I'd just write a routine which takes a PictureBox as an input
parameter..."
I think this is a nice solution. But - is it possible to do? For
example I want to write a Public Sub, which will be called from
different frames. How would you pass the argument? Can you five me a hint?
Did you have in mind something like that?
frmTransform:
Square("picGraph", xcoord, ycoord, size)
general.bas:
Public Sub Square(name as string, x as single, y as single, size as single)
name.Line (x-size/2, y-size/2)-(x-size/2, y+size/2) '?????????
...
Marko
Mike D Sutton wrote:
>
>
> Nope, you can however write a UserControl that encapsulates a picture box and adds this additional functionality. IMO
> though I'd just write a routine which takes a PictureBox as an input parameter, or write a library of additional drawing
> commands which draw to a control's surface or DC handle such as the APIDraw library on my site.
> Hope this helps,
>
> Mike
>
>
> - Microsoft Visual Basic MVP -
> E-Mail: EDais@mvps.org
> WWW: Http://EDais.mvps.org/
>
>
| |
| J French 2005-02-28, 8:55 am |
| On Mon, 28 Feb 2005 08:32:38 +0100, Marko Pinteric
<marko@pinteric.com> wrote:
>Hello,
>
>I want to define a new picturebox member. For example,
>PictureBox.Circle member already exists, I would like to define
>PictureBox.Square member. Is this possible to do and how?
You cannot add intrinsic methods to a Picturebox
- you would need to write some sort of Sub
However if you use a UserControl instead of a Picturebox, then you can
add whatever you like
- that may (or may not) be a solution
| |
| Mike D Sutton 2005-02-28, 8:55 am |
| > "...I'd just write a routine which takes a PictureBox as an input
> parameter..."
>
> I think this is a nice solution. But - is it possible to do? For
> example I want to write a Public Sub, which will be called from
> different frames. How would you pass the argument? Can you five me a hint?
>
> Did you have in mind something like that?
>
>
> frmTransform:
>
> Square("picGraph", xcoord, ycoord, size)
>
>
> general.bas:
>
> Public Sub Square(name as string, x as single, y as single, size as single)
> name.Line (x-size/2, y-size/2)-(x-size/2, y+size/2) '?????????
Since a picturebox is just an object of type PictureBox, you can pass it in directly to the function:
'***
Private Sub Square(ByVal inPic As PictureBox, _
ByVal inX As Single, ByVal inY As Single, ByVal inSize As Single)
inPic.Line (inX - inSize / 2, inY - inSize / 2)-(inX - inSize / 2, inY + inSize / 2)
End Sub
'***
Hope this helps,
Mike
- Microsoft Visual Basic MVP -
E-Mail: EDais@mvps.org
WWW: Http://EDais.mvps.org/
| |
| Marko Pinteric 2005-02-28, 8:55 am |
| Well, that was a quick answer! I will try it later!
Thanks!
Marko
Mike D Sutton wrote:
>
>
> Since a picturebox is just an object of type PictureBox, you can pass it in directly to the function:
>
> '***
> Private Sub Square(ByVal inPic As PictureBox, _
> ByVal inX As Single, ByVal inY As Single, ByVal inSize As Single)
> inPic.Line (inX - inSize / 2, inY - inSize / 2)-(inX - inSize / 2, inY + inSize / 2)
> End Sub
> '***
>
> Hope this helps,
>
> Mike
>
>
> - Microsoft Visual Basic MVP -
> E-Mail: EDais@mvps.org
> WWW: Http://EDais.mvps.org/
>
>
|
|
|
|
|