|
-
Mar 12th, 2003, 11:25 AM
#1
Thread Starter
Fanatic Member
creating a shape at runtime **RESOLVED**
Does anyone know how to create a shape at runtime
user enters x1,y1,x2,y2 and shape in text boxes and the shape appears on the form.
Last edited by davidrobin; Mar 13th, 2003 at 07:44 AM.
-
Mar 12th, 2003, 01:47 PM
#2
Make an array of shapes, then you can load them at runtime...
-
Mar 13th, 2003, 07:31 AM
#3
Thread Starter
Fanatic Member
This code originally appeared in a post by toughcoder. I have just modified it a little.
OK, I have done this but I get a 'Object variable or with block variable not set'
Code:
Option Explicit
Dim blnDrawing As Boolean
Dim x1 As Single, y1 As Single
Dim Shape2(1) As Shape
Private Sub Form_Load()
' Shape2.FillStyle = vbFSTransparent
' Shape2.FillColor = 0
' Shape2.BorderStyle = 1
' Shape2.BorderWidth = 1
End Sub
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
x1 = X
y1 = Y
Shape2(0).Left = x1
Shape2(0).Top = y1
blnDrawing = True
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If blnDrawing = True Then
Shape2(0).Width = X - x1
Shape2(0).Height = Y - y1
End If
End Sub
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
blnDrawing = False
Shape2(0).FillStyle = vbFSSolid
Shape2(0).FillColor = vbRed
Shape2(0).BorderColor = vbRed
End Sub
-
Mar 13th, 2003, 07:37 AM
#4
Sorry, I can't test this now(no IDE in my office), but
Put a shape on the form at designtime(.index=0)
at runtime use
I hope that'S correct!
You're welcome to rate this post!
If your problem is solved, please use the Mark thread as resolved button
Wait, I'm too old to hurry!
-
Mar 13th, 2003, 07:43 AM
#5
Thread Starter
Fanatic Member
-
Mar 13th, 2003, 08:56 AM
#6
....LOL...nice bug with the visiblity....I remember the first time I did that...
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
|