|
-
Nov 29th, 2000, 06:40 PM
#1
Thread Starter
Junior Member
I have a program that makes creates a shape from a set of coordinates in a textbox, but i want it to put the shape as a part of a picture box instead of the form. Is this possible?
Here is the code i have so far:
Code:
Public WithEvents myshape As Shape
Private Sub Create_Shape()
MyCoords = Split(Text11.Text, ",")
Set myshape = Controls.Add("VB.Shape", "abc")
myshape.left = MyCoords(0)
myshape.top = MyCoords(1)
myshape.width = MyCoords(2)
myshape.height = MyCoords(3)
myshape.Shape = 0
myshape.BorderColor = &HFF00FF
myshape.BorderWidth = 3
myshape.Visible = True
End Sub
[Edited by sp007 on 11-29-2000 at 09:54 PM]
-
Nov 29th, 2000, 09:27 PM
#2
Fanatic Member
You could always draw them directly using the API, but I'm not sure if that is what you want. If it is let me know and I'll send some code.
{Insert random techno-babble here}
{Insert quote from some long gone mofo here}
-
Nov 29th, 2000, 09:47 PM
#3
Thread Starter
Junior Member
I suppose that could work. Would you still be able to set the properties, such as borderwidth as bordercolor through api?
-
Nov 29th, 2000, 10:04 PM
#4
Fanatic Member
When drawing to a device such as a PictureBox the borderwidth and bordercolor are determined by the current properties of the surface you are drawing too, in this case the PictureBox, here is a quick example of how to draw a Rectangle.
Code:
Private Declare Function Rectangle Lib "gdi32" (ByVal hdc As Long, ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
Private Sub Picture1_Paint() ' all drawing should be done in paint event
Dim lRet As Long ' return value from drawing function
Picture1.DrawWidth = 2 ' same as borderwidth
Picture1.ForeColor = RGB(255, 0, 0) ' same as bordercolor
'draw rectangle
lRet = Rectangle(Picture1.hdc, 5, 5, 50, 100)
End Sub
Also the api uses Pixels as coordinates rather than Twips so if you wanted to convert a Twip coordinate to a Pixel coordinate use this formula.
Code:
x = x / Screen.TwipsPerPixelX
{Insert random techno-babble here}
{Insert quote from some long gone mofo here}
-
Nov 29th, 2000, 10:09 PM
#5
Thread Starter
Junior Member
Excellent. Thanks a ton. It works Great
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
|
Click Here to Expand Forum to Full Width
|