What am I doing wrong, I always get a zero value for hBmp.
hBmp = LoadImage(Picture2.hdc, 0, IMAGE_BITMAP, 0, 0, LR_DEFAULTSIZE)
I am trying to copy the image in picture to the hBmp.
Thanks in advance,
Printable View
What am I doing wrong, I always get a zero value for hBmp.
hBmp = LoadImage(Picture2.hdc, 0, IMAGE_BITMAP, 0, 0, LR_DEFAULTSIZE)
I am trying to copy the image in picture to the hBmp.
Thanks in advance,
You cannot copy a bitmap like this. The LoadImage function is used for loading bitmap images from files. Use the BitBlt to copy (blit) a bitmap from one DC to another.
However, if you want to obtain a handle to a bitmap use the .Picture.Handle property of a form, picturebox...
These will all return the handle to the picture, so just choose which one you like the best:
Code:Print Picture1
Print Picture1.Picture
Print Picture1.Picture.Handle
Personally I prefer .Picture.Handle because in VB.NET there will be no default properties :)
I usually use Picture1.Picture, because there are some times where you can't use .Handle, e.g:
Code:Picture1.Picture = Picture2.Picture
This copies the whole struct right?
Does VB always check if there might be a default value to use if you specify '.picture'?
No that doesn't. Set is implicitely used when you assign an object reference, so the correct syntax is
Set Picture1.Picture = Picture2.Picture
I guess they're variants, otherways it should give you an error.
The COM Objects are not like structs, that is UDT's in VB, when the assignment is done, a pointer is just copied so both picture1 and picture2's picture properties points to the same stdpicture. You can't copy COM objects with a decent general way in VB, if you design your own classes you can put in clone functions though. The compiler should search for default properties whenever there's a type mismatch (between COM and other datatypes) if you don't specify explicitely by using SET or LET statements.