 |
|

05-08-2002, 08:33 PM
|
 |
Junior Contributor
|
|
Join Date: Apr 2002
Location: Sunny Southern California
Posts: 347
|
|
problem with picturebox adding pictures from images
|
ok, i need to add a picture from a image to a picture box. here is the code i used:
In form with images:
Code:
Dim x1 As Integer
Dim y1 As Integer
Dim w1 As Integer
Dim h1 As Integer
Dim x2 As Integer
Dim y2 As Integer
Dim w2 As Integer
Dim h2 As Integer
Dim x3 As Integer
Dim y3 As Integer
Dim w3 As Integer
Dim h3 As Integer
Private Sub Timer1_Timer()
x1 = (Image1.Top * 4)
y1 = (Image1.Left * 4)
w1 = (Image1.Width * 4)
h1 = (Image1.Height * 4)
x2 = (Image2.Top * 4)
y2 = (Image2.Left * 4)
w2 = (Image2.Width * 4)
h2 = (Image2.Height * 4)
x3 = (Image3.Top * 4)
y3 = (Image3.Left * 4)
w3 = (Image3.Width * 4)
h3 = (Image3.Height * 4)
End Sub
In form with picture box:
Code:
Private Sub Form_Load()
Picture1.PaintPicture Layer1.Image1.Picture, x1, y1, w1, h1
Picture1.PaintPicture Layer1.Image2.Picture, x2, y2, w2, h2
Picture1.PaintPicture Layer1.Image3.Picture, x3, y3, w3, h3
End Sub
Layer1 is the form in which the images are on. Here is the error I get:
Invalid Property Value
Thanks if you help me at all.
EDIT: Just to let you know I am using these variables, incase these images move at all. I am obviously enlarging them to go into the picturebox, but they only enlarge in the picture box, and remain the same in the images. I hope this is all clear.
|
Last edited by crazycheetah; 05-08-2002 at 09:07 PM.
|

05-08-2002, 08:37 PM
|
|
|
|
In which line are u getting this error ??
|
|

05-08-2002, 08:39 PM
|
 |
Junior Contributor
|
|
Join Date: Apr 2002
Location: Sunny Southern California
Posts: 347
|
|
this is the line that is highlighted:
Code:
Picture1.PaintPicture Layer1.Image1.Picture, x1, y1, w1, h1
|
|

05-08-2002, 08:43 PM
|
|
|
|
The variables need to be declared as Public ones...
to all forms get values from them...
|
|

05-08-2002, 08:44 PM
|
|
|
|
add a module to your project and declare tha variables there...
same as follow:
Public x1, y1, w1, h1 as integer
Public x2, y2, w2, h2 as integer
Public x3, y3, w3, h3 as integer
|
|

05-08-2002, 08:49 PM
|
 |
Junior Contributor
|
|
Join Date: Apr 2002
Location: Sunny Southern California
Posts: 347
|
|
ok, i made the code as follows now:
In Module:
Code:
Sub Main()
Public x1 As Integer
Public y1 As Integer
Public w1 As Integer
Public h1 As Integer
Public x2 As Integer
Public y2 As Integer
Public w2 As Integer
Public h2 As Integer
Public x3 As Integer
Public y3 As Integer
Public w3 As Integer
Public h3 As Integer
Load Layer1
Load Form2
Form2.Show
End Sub
Then in the form called Layer1:
Code:
Private Sub Timer1_Timer()
x1 = (Image1.Top * 4)
y1 = (Image1.Left * 4)
w1 = (Image1.Width * 4)
h1 = (Image1.Height * 4)
x2 = (Image2.Top * 4)
y2 = (Image2.Left * 4)
w2 = (Image2.Width * 4)
h2 = (Image2.Height * 4)
x3 = (Image3.Top * 4)
y3 = (Image3.Left * 4)
w3 = (Image3.Width * 4)
h3 = (Image3.Height * 4)
End Sub
then in the form with the picture box:
Code:
Private Sub Form_Load()
Picture1.PaintPicture Layer1.Image1.Picture, x1, y1, w1, h1
Picture1.PaintPicture Layer1.Image2.Picture, x2, y2, w2, h2
Picture1.PaintPicture Layer1.Image3.Picture, x3, y3, w3, h3
End Sub
however i get the Invalid Property Value error
Im getting extremely confused from this
|
|

05-08-2002, 08:51 PM
|
|
|
Don't Declare the variables into te Sub Main !!!
Declare it out...
Code:
Public x1 As Integer
Public y1 As Integer
Public w1 As Integer
Public h1 As Integer
Public x2 As Integer
Public y2 As Integer
Public w2 As Integer
Public h2 As Integer
Public x3 As Integer
Public y3 As Integer
Public w3 As Integer
Public h3 As Integer
Sub Main()
Load Layer1
Load Form2
Form2.Show
End Sub
Understood ??
|
|

05-08-2002, 08:52 PM
|
 |
Junior Contributor
|
|
Join Date: Apr 2002
Location: Sunny Southern California
Posts: 347
|
|
|
ok, i did exactly that, and well now it is still giving me the same error???
|
|

05-08-2002, 08:57 PM
|
|
|
|
before the Picture1.PaintPicture thing...
write this code:
msgbox str(x1) & vbcrlf & str(x2) & vbcrlf & str(x3)
what did u got in Message box ???
|
|

05-08-2002, 08:59 PM
|
 |
Junior Contributor
|
|
Join Date: Apr 2002
Location: Sunny Southern California
Posts: 347
|
|
|
3 0's which is what it should be so i'm not suprised that that is what it is
|
|

05-08-2002, 09:01 PM
|
|
|
oh...
the x1, x2, x3 are all 0's ???
do the follow:
Code:
Private Sub Timer1_Timer()
x1 = (Image1.Top * 4) + 1
y1 = (Image1.Left * 4) + 1
w1 = (Image1.Width * 4)
h1 = (Image1.Height * 4)
x2 = (Image2.Top * 4) + 1
y2 = (Image2.Left * 4) + 1
w2 = (Image2.Width * 4)
h2 = (Image2.Height * 4)
x3 = (Image3.Top * 4) + 1
y3 = (Image3.Left * 4) + 1
w3 = (Image3.Width * 4)
h3 = (Image3.Height * 4)
End Sub
|
|

05-08-2002, 09:03 PM
|
|
|
Oh man !!
I'm so stupid !!!
In the Form1...
Put the Picture1.PaintPicture things in Form_Activate event !!!
and i'm sure it'll work !!! 
|
|

05-08-2002, 09:04 PM
|
 |
Junior Contributor
|
|
Join Date: Apr 2002
Location: Sunny Southern California
Posts: 347
|
|
|
they remain as 0's and i just realized they are not all supposed to be 0. the y axis is but not the x axis.
and um, stupid me i forgot to say that they are in the Form_Load event.
|
|

05-08-2002, 09:08 PM
|
|
|
and the X and Y axis things...
I think you should change this one thing to...
the Y axis is the TOP property
and X is the LEFT one... 
|
|

05-08-2002, 09:10 PM
|
 |
Junior Contributor
|
|
Join Date: Apr 2002
Location: Sunny Southern California
Posts: 347
|
|
|
ok, i am officially confused, but i think i accidentally clicked new thread, so um yeah what i have is there.
|
|

05-08-2002, 09:12 PM
|
|
|
|
can you ZIP this and attach ?
so I can take a look at it ??
|
|

05-08-2002, 09:14 PM
|
 |
Junior Contributor
|
|
Join Date: Apr 2002
Location: Sunny Southern California
Posts: 347
|
|
|
ok, here it is, there is also another form i don't use right now there, however.
|
|

05-08-2002, 09:25 PM
|
|
|
|
I've looked at it ...
and it's working fine now...
But, anyways... I cannot attach anything (don't know why)
so, do u have any other way for me to sending this ??
|
|

05-08-2002, 09:36 PM
|
|
|
I'll post forms, One by One...
Overwrite all the codes os then with these...
Form2
Code:
Private Sub Form_KeyPress(KeyAscii As Integer)
If KeyAscii = vbKeyEscape Then
Unload Me
End If
End Sub
Private Sub Form_Activate() 'PAINT ONLY WHEN FORM HAS BEEN FULLY LOADED AND SHOWN
Picture1.PaintPicture Layer1.Image1.Picture, x1, y1, w1, h1
Picture1.PaintPicture Layer1.Image2.Picture, x2, y2, w2, h2
Picture1.PaintPicture Layer1.Image3.Picture, x3, y3, w3, h3
End Sub
Private Sub Form_Unload(Cancel As Integer)
End
End Sub
Private Sub Picture1_Click()
End Sub
Private Sub Timer1_Timer()
Picture1.Cls
Picture1.PaintPicture Layer1.Image1.Picture, x1, y1, w1, h1
Picture1.PaintPicture Layer1.Image2.Picture, x2, y2, w2, h2
Picture1.PaintPicture Layer1.Image3.Picture, x3, y3, w3, h3
End Sub
Layer1
Code:
Private Sub Form_Activate() 'HERE...I'LL ONLY SHOW THE FORM2 WHEN THE POSTIONS HAVE ALREADY BEEN SET...
Timer1_Timer
DoEvents
Form2.Show
End Sub
Private Sub Timer1_Timer()
x1 = (Image1.Left * 4) + 1
y1 = (Image1.Top * 4) + 1
w1 = (Image1.Width * 4)
h1 = (Image1.Height * 4)
x2 = (Image2.Left * 4) + 1
y2 = (Image2.Top * 4) + 1
w2 = (Image2.Width * 4)
h2 = (Image2.Height * 4)
x3 = (Image3.Left * 4) + 1
y3 = (Image3.Top * 4) + 1
w3 = (Image3.Width * 4)
h3 = (Image3.Height * 4)
End Sub
Module
Code:
Public x1 As Integer
Public y1 As Integer
Public w1 As Integer
Public h1 As Integer
Public x2 As Integer
Public y2 As Integer
Public w2 As Integer
Public h2 As Integer
Public x3 As Integer
Public y3 As Integer
Public w3 As Integer
Public h3 As Integer
Sub Main() 'SHOW LAYER1 ONLY... SEE THERE WHY...
Layer1.Show
Layer1.Hide
End Sub
Also...
go in Project Properties...
and Set Start Up Form as Sub Main... 
|
|

05-08-2002, 09:41 PM
|
 |
Junior Contributor
|
|
Join Date: Apr 2002
Location: Sunny Southern California
Posts: 347
|
|
|
well, i had a small problem, cause i was trying to get my e-mail to work, and then I had to change it, so I had to wait and get re-registered pretty much. But the code worked, thanks man!
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|
|