You are not logged in.

Dear visitor, welcome to Jabaco - Community. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

Perry

Beginner

  • "Perry" is male
  • "Perry" started this thread

Posts: 40

Date of registration: Jan 15th 2011

Location: Sarasota, FL

Occupation: Cabinet Design

Hobbies: Programming

  • Send private message

1

Wednesday, January 19th 2011, 12:44am

Here I'm Puzzled - Picturebox

I wrote this code to familiarize myself with the Controls.

I can't understand why this won't work.

I placed a Picturebox on a form, & also a commondialog control.

I placed this code in th picturbox click event

Public Sub Picture1_Click()
Dim P As PictureBox,C As CommonDialog,FN As String

Set P = Picture1
Set C = CommonDialog1
With C
.Filter = "(*.bmp)|*.bmp"
.ShowOpen
End With
FN = C.FileName
P.Picture = LoadPicture (FN)
P.PaintPicture LoadPicture(FN) ,0,0

End Sub

Note the 2 lines before the End Sub. They would both do about the same thing in VB

of the 2 lines

P.Picture = LoadPicture (FN)
Picture2.PaintPicture LoadPicture(FN) ,0,0

The first line above complains with an error on the LoadPicture(FN) function

but if I comment out that line, the second line works without complaint.

Also I clearly don't know yet how Jabaco implements the .Filter in the code above, because it doesn't work like I intended it to either.

could someone give me a pointer or 2 on this?

This post has been edited 1 times, last edit by "Perry" (Jan 19th 2011, 8:54am)


scGuy

Beginner

Posts: 40

Date of registration: Jan 12th 2011

  • Send private message

2

Wednesday, January 19th 2011, 7:57pm

Hmmm, the compiler may be highlighting the wrong item as the problem point. As for the last two lines doing the same thing in VB, I agree, though you may need to use the "set" command such as: set picture1.picture=LoadPicture("something.jpg")



That being said, including the set command in Jabaco did not help. The PaintPicture method expects an "image" type as an argument. The LoadPicture function returns an "image" type, so all is well. My guess is that the "Picture" property of the Picturebox control is *not* of type "image", and therefore a compile error is occurring. But that's a guess. ...?



Might be a bug then--I think the .Picture property should take an Image type as returned by LoadPicture...

theuserbl

Intermediate

Posts: 436

Date of registration: Dec 20th 2008

  • Send private message

3

Thursday, January 20th 2011, 3:57am

I have only little knowledge about VB6. I come from QBasic and using currently mostly Java. And Jabaco from time to time as fun.

To load a picture in Jabaco, you have multiple possibilities:

Possiblility 1)
Choosing in the IDE designer under "Properties" and "Picture" a picture.

Possiblility 2)

Jabaco Source

1
2
3
4
Public Sub Picture1_Click()
     Picture1.Picture = New Resources("mypic.bmp")
     Picture1.Refresh
End Sub

In this case you have to run it one time and then going in the menu over "Project" -> "Open Working Directory" and coping in there your file "mypic.bmp".
Then restart the program. You will see the picture if you click in that field.

Possibility 3)
Havent't enoght time to check it out now. But ths should be working, but it don't. Don't know why:

Jabaco Source

1
2
3
4
Public Sub Picture1_Click()
     Picture1.Picture = Me.Parent.getToolkit.getImage("mypic.bmp")
     Picture1.Refresh
End Sub

Perry

Beginner

  • "Perry" is male
  • "Perry" started this thread

Posts: 40

Date of registration: Jan 15th 2011

Location: Sarasota, FL

Occupation: Cabinet Design

Hobbies: Programming

  • Send private message

4

Thursday, January 20th 2011, 5:54am

Yet the GUI gives me 2 possibilities.

1/2 LoadPicture(Resource as String) as Image

or

2/2 LoadPicture (Resource as IResource) as Image

Clearly the variable FN in my code above is a String, which the GUI says is acceptable.
It is also a valid file address, as it was just retrieved from the commondialog control.

I also tried the New Resources trick ... It complained as well until I placed a Set command before the Picture1.Picture command. That quieted the compiler .... but though it didn't complain, it didn't load the picture either....
:(

scGuy:
I think perhaps you fingered the problem .. the .picture property will not accept an Image type .. but demands a resource.

If this is wrong I am asking someone to correct this notion.
I would be interested if someone can come up with code that will do the same thing I have just attempted that will work.
One thing that I will be trying to do eventually is stretch the picture to fit the entire picture control area.
For that I will need the PaintPicture method which does appear to work. It will allow stretching providing that I can plug in the proper variables. However I will need the actual size of the original picture so that I can stretch it to it's final size. This I usually do in VB6 by loading the picture into another picture control, and since that will size itself, I then copy it over into the working picture control with the paintpicture method. Maybe there is another method of determining the actual size of the picture file.

In this excersize it is critical that the file can be selected dynamically from the commondialog.

This post has been edited 1 times, last edit by "Perry" (Jan 20th 2011, 1:38pm)


Rate this thread
WoltLab Burning Board