Is this code correct?

This is a discussion on Is this code correct? within the Windows Programming forums, part of the Platform Specific Boards category; Hi, I'm wanting to get a handle to a bitmap (not in a resource!) and I'm using: HBITMAP ButtonPic; ButtonPic=(HBITMAP)LoadImage(NULL,"C:\ETInt\V02\ ...

  1. #1
    Registered User
    Join Date
    May 2003
    Posts
    44

    Is this code correct?

    Hi,

    I'm wanting to get a handle to a bitmap (not in a resource!) and I'm using:


    HBITMAP ButtonPic;

    ButtonPic=(HBITMAP)LoadImage(NULL,"C:\\ETInt\\V02\ \pic.bmp",IMAGE_BITMAP,0,0,LR_LOADFROMFILE|LR_CREA TEDIBSECTION);


    Is this correct? Thanks!
    Uni

  2. #2
    Kiss the monkey. CodeMonkey's Avatar
    Join Date
    Sep 2001
    Posts
    902
    Looks good to me. I think there might be an LR_FILENAME thing in there somewhere, too. But I think that should work. Does it?
    "If you tell the truth, you don't have to remember anything"
    -Mark Twain

  3. #3
    Registered User
    Join Date
    May 2003
    Posts
    44
    Well...that's the trouble . This is to put in with a custom button, which can have a resource of the bitmap or a handle to a file. Since I don't have a resource I'm doing it like this. But its not adding the bitmap to the button...

  4. #4
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,831
    Check the return value from LoadImage(). If the call works, it returns a handle, if not NULL. If it is returning a handle, then the problem is somewhere else, if it is returning NULL, call GetLastError() to find out why.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. my Dictionary removal code correct?
    By George2 in forum C# Programming
    Replies: 1
    Last Post: 05-17-2008, 08:45 AM
  2. True ASM vs. Fake ASM ????
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 7
    Last Post: 04-02-2003, 03:28 AM
  3. Seems like correct code, but results are not right...
    By OmniMirror in forum C Programming
    Replies: 4
    Last Post: 02-13-2003, 12:33 PM
  4. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 05:06 PM
  5. Replies: 4
    Last Post: 01-15-2002, 11:04 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21