Door object of type, cannot convert?

idavidov

New Member
Licensed User
Hi people - I hope someone can make things clear to me. It's about Door library and referencing the object.

When I create image from some resource and make an object - things work well. Here is the example.
B4X:
bitmapSrc.New3(IL1.Item(0))
dImage.Image = bitmapSrc.Value
obj.New1(False)
obj.FromControl("dImage")

But when I create bitmap image on the forelayer on which I draw - I cannot make an object and get this type of error: Object of type 'System.Drawing.Bitmap' cannot be converted to type 'System.Windows.Forms.Control', Continue? And here is the example.
B4X:
FormMain.ForeLayer = True
bitmapDraw.New2(240,320)
' drawing on image code (i omitted it here)
FormMain.FDrawImage ( bitmapDraw.Value, 0, 0)
obj.New1(False)
obj.FromControl("bitmapDraw")

I have tried also with
B4X:
obj.FromControl(bitmapDraw.Value)

I guess the solution would be to make an image control on the form and pass bitmap.value to it - but I would like to have bitmap on the forelayer on which I could draw. Well - I would also like that image to receive events - which is doable with image control in first example. Any ideas?

:sign0085:
 
Last edited:

agraham

Expert
Licensed User
Longtime User
To get the Bitmap into a Door object

Obj1.Value = bitmapDraw.Value

I'm afraid that I don't understand why you want to do this. You mention events but Bitmaps don't have events :confused:

When playing with the Door library this line is invaluable to tell you what type of object you have obtained

MsgBox(Obj1.RunMethod("ToString"))
 

klaus

Expert
Licensed User
Longtime User
If I understood you well, you want to draw onto an Image.
I am shure you would be better using the ImageLibEx library.
You can define a BitmapEx object, even larger than the form, draw onto it copy part of it onto the backgroung image of the form. And you can use the standard events of the form, and also use the forelayer of the form.
Attached is a simple Drawing program.
You can find a more complete one here. http://www.b4x.com/forum/share-your-creations/3945-draw-program-5.html#post22832

Best regards.
 

idavidov

New Member
Licensed User
Agraham thank you for pointing me to the right direction - earlier I was using Image control and "filling" it with bitmat that I have drawn. Now I know what was not clear to me - that bitmap cannot receive events. I started basic4ppc few days ago and this was really noobish from me - might say that I deserve famous words like RTFM :)

Klaus - I would also like to thank you for the example. Yes - I'm drawing an image (and on image) and dynamically replacing it on different events.

I'm absolutely clear now of what to do and when. Thank you both for help!!

:sign0060:
 
Top