Page 1 of 1

ImageGadget error with form designer

Posted: Tue Mar 25, 2014 12:38 am
by atiaust
I am trying to use an ImageGadget created on a form in the form designer.

This is the generated ImageGadget.

Code: Select all

Image_0 = ImageGadget(#PB_Any, 460, 140, 50, 100, 0, #PB_Image_Border)
I added this to one of the procedures in the procedures file

Code: Select all

            CreateImage(Image_0,20,100)
            ; Debug("Image ID = "+ImageID(Image_0))
            StartDrawing(ImageOutput(Image_0))
            Box(0,0,20,100,$FF4D20)
            StopDrawing()
            ImageGadget(Image_0, 460, 140, 20, 100, ImageID(Image_0))
When I run the program I get an error :
[ERROR] #Gadget object number is very high (over 10000), are You sure of that ?
The debug shows a number of 755126886

Then - [ERROR] Invalid memory access. (read error at address 12)
This occurs at:

Code: Select all

Event = WaitWindowEvent()
Does anyone have any ideas as to where I may be going wrong or what is causing this?

If I generate the ImageGadget manually in the procedures file it appears to work OK.

Thanks

Re: ImageGadget error with form designer

Posted: Tue Mar 25, 2014 12:57 am
by majikeyric
Image and ImageGadget are different objects. you mix both.

Code: Select all

            gadget_0 = ImageGadget(#PB_Any, 460, 140, 50, 100, 0, #PB_Image_Border)
            CreateImage(Image,20,100)
            StartDrawing(ImageOutput(Image))
            Box(0,0,20,100,$FF4D20)
            StopDrawing()
 	    SetGadgetState(gadget_0, ImageID(image))

Re: ImageGadget error with form designer

Posted: Tue Mar 25, 2014 11:09 am
by atiaust
Thanks majikeyric;

I tried your suggestion and still get the same error/s.

I unclicked the #PB_Any property for the ImageGadget in the Form Designer and used Image_0.
The following code now works correctly.

Code: Select all

            CreateImage(#0,50,100)
            StartDrawing(ImageOutput(#0))
            Box(0,0,20,70,$FF4D20)
            StopDrawing()
            ImageGadget(#Image_0, 460, 140, 20, 100, ImageID(#0))
It appears there is an error that occurs when the #PB_Any is used in the Form Designer.

Anyone wish to comment?

Re: ImageGadget error with form designer

Posted: Tue Mar 25, 2014 5:37 pm
by Polo
It's because you're using the same variable (Image_0) for the image and the image gadget!

Re: ImageGadget error with form designer

Posted: Wed Mar 26, 2014 4:37 am
by atiaust
Thanks Polo for your reply.

I have found that if I allow the form designer to define the ImageGadget with #PB_Any I get an error

[ERROR] #Gadget object number is very high (over 10000), are You sure of that ?

but if I don't use #PB_any and use the code below it works fine.

Code: Select all

            CreateImage(#Temp,20,120)
            StartDrawing(ImageOutput(#Temp))
            Box(0,0,20,120,RGB(255,255,128))
            Box(0,0,20,70,$FF4D20)
            StopDrawing()
            ImageGadget(#Image_0, 200, 140, 20, 120, ImageID(#Temp),#PB_Image_Border)
So at this stage I don't understand enough about the Form Designer but I have the ImageGadget working for my needs.

Thanks again.