Results 1 to 7 of 7

Thread: Using LoadImage

  1. #1

    Thread Starter
    PowerPoster 2.0 Negative0's Avatar
    Join Date
    Jun 2000
    Location
    Southeastern MI
    Posts
    4,367

    Using LoadImage

    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,

  2. #2
    Addicted Member
    Join Date
    Aug 2000
    Location
    Croatia
    Posts
    200
    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...

  3. #3
    Megatron
    Guest
    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

  4. #4
    Addicted Member
    Join Date
    Aug 2000
    Location
    Croatia
    Posts
    200
    Personally I prefer .Picture.Handle because in VB.NET there will be no default properties

  5. #5
    Megatron
    Guest
    I usually use Picture1.Picture, because there are some times where you can't use .Handle, e.g:
    Code:
    Picture1.Picture = Picture2.Picture

  6. #6
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088
    This copies the whole struct right?

    Does VB always check if there might be a default value to use if you specify '.picture'?

  7. #7
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    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.
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width