Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > General > problem with picturebox adding pictures from images


Reply
 
Thread Tools Display Modes
  #1  
Old 05-08-2002, 08:33 PM
crazycheetah's Avatar
crazycheetah crazycheetah is offline
Junior Contributor
 
Join Date: Apr 2002
Location: Sunny Southern California
Posts: 347
Default 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.
Reply With Quote
  #2  
Old 05-08-2002, 08:37 PM
The IceMan
Guest
 
Posts: n/a
Default

In which line are u getting this error ??
Reply With Quote
  #3  
Old 05-08-2002, 08:39 PM
crazycheetah's Avatar
crazycheetah crazycheetah is offline
Junior Contributor
 
Join Date: Apr 2002
Location: Sunny Southern California
Posts: 347
Default

this is the line that is highlighted:

Code:
    Picture1.PaintPicture Layer1.Image1.Picture, x1, y1, w1, h1
Reply With Quote
  #4  
Old 05-08-2002, 08:43 PM
The IceMan
Guest
 
Posts: n/a
Default

The variables need to be declared as Public ones...
to all forms get values from them...
Reply With Quote
  #5  
Old 05-08-2002, 08:44 PM
The IceMan
Guest
 
Posts: n/a
Default

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
Reply With Quote
  #6  
Old 05-08-2002, 08:49 PM
crazycheetah's Avatar
crazycheetah crazycheetah is offline
Junior Contributor
 
Join Date: Apr 2002
Location: Sunny Southern California
Posts: 347
Default

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
Reply With Quote
  #7  
Old 05-08-2002, 08:51 PM
The IceMan
Guest
 
Posts: n/a
Default

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 ??
Reply With Quote
  #8  
Old 05-08-2002, 08:52 PM
crazycheetah's Avatar
crazycheetah crazycheetah is offline
Junior Contributor
 
Join Date: Apr 2002
Location: Sunny Southern California
Posts: 347
Default

ok, i did exactly that, and well now it is still giving me the same error???
Reply With Quote
  #9  
Old 05-08-2002, 08:57 PM
The IceMan
Guest
 
Posts: n/a
Default

before the Picture1.PaintPicture thing...

write this code:
msgbox str(x1) & vbcrlf & str(x2) & vbcrlf & str(x3)


what did u got in Message box ???
Reply With Quote
  #10  
Old 05-08-2002, 08:59 PM
crazycheetah's Avatar
crazycheetah crazycheetah is offline
Junior Contributor
 
Join Date: Apr 2002
Location: Sunny Southern California
Posts: 347
Default

3 0's which is what it should be so i'm not suprised that that is what it is
Reply With Quote
  #11  
Old 05-08-2002, 09:01 PM
The IceMan
Guest
 
Posts: n/a
Default

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
Reply With Quote
  #12  
Old 05-08-2002, 09:03 PM
The IceMan
Guest
 
Posts: n/a
Default

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 !!!
Reply With Quote
  #13  
Old 05-08-2002, 09:04 PM
crazycheetah's Avatar
crazycheetah crazycheetah is offline
Junior Contributor
 
Join Date: Apr 2002
Location: Sunny Southern California
Posts: 347
Default

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.
Reply With Quote
  #14  
Old 05-08-2002, 09:08 PM
The IceMan
Guest
 
Posts: n/a
Default

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...
Reply With Quote
  #15  
Old 05-08-2002, 09:10 PM
crazycheetah's Avatar
crazycheetah crazycheetah is offline
Junior Contributor
 
Join Date: Apr 2002
Location: Sunny Southern California
Posts: 347
Default

ok, i am officially confused, but i think i accidentally clicked new thread, so um yeah what i have is there.
Reply With Quote
  #16  
Old 05-08-2002, 09:12 PM
The IceMan
Guest
 
Posts: n/a
Default

can you ZIP this and attach ?

so I can take a look at it ??
Reply With Quote
  #17  
Old 05-08-2002, 09:14 PM
crazycheetah's Avatar
crazycheetah crazycheetah is offline
Junior Contributor
 
Join Date: Apr 2002
Location: Sunny Southern California
Posts: 347
Default

ok, here it is, there is also another form i don't use right now there, however.
Attached Files
File Type: zip vbmessup.zip (6.3 KB, 3 views)
Reply With Quote
  #18  
Old 05-08-2002, 09:25 PM
The IceMan
Guest
 
Posts: n/a
Default

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 ??
Reply With Quote
  #19  
Old 05-08-2002, 09:36 PM
The IceMan
Guest
 
Posts: n/a
Thumbs up

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...
Reply With Quote
  #20  
Old 05-08-2002, 09:41 PM
crazycheetah's Avatar
crazycheetah crazycheetah is offline
Junior Contributor
 
Join Date: Apr 2002
Location: Sunny Southern California
Posts: 347
Default

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!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->