Thread: Buttons And Bitmaps

  1. #1
    Registered User minime6696's Avatar
    Join Date
    Aug 2001
    Posts
    267

    Exclamation Buttons And Bitmaps

    I am trying to put a bitmap onto a button, its not working here is my code with the declairations used:

    class WinObj
    {public:
    int ID;
    HWND hwndButton;
    };

    WinObj CreateWindowsObject( int ID , const char *Caption , int xcor , int ycor , int xszi , int yszi , const char *Type , DWORD Flags )
    {
    WinObj Ret;

    Ret.hwndButton = CreateWindow(Type,
    Caption,WS_CHILD | WS_VISIBLE | Flags,
    xcor,ycor ,xszi,yszi,hwnd, (HMENU)ID, (HINSTANCE)GetWindowLong(hwnd, GWL_HINSTANCE), NULL);

    Ret.ID = ID;

    return Ret;
    }

    // Code:
    WinObj W;
    CreateWindowsObject(0,"",0,0,100,100,"button",BS_B ITMAP);

    SendMessage(
    (HWND) W.hwndButton, // handle to destination window
    BM_SETIMAGE, // message to send
    (WPARAM) IMAGE_BITMAP, // image type
    (LPARAM) LoadBitmap(hInstance,"IDB_BITMAP1") // handle to the image (HANDLE)
    );


    Please help, ive tried MSDN and stuff it just doesnt seem to work!

    SPH

  2. #2
    Registered User Chemanuel's Avatar
    Join Date
    Aug 2001
    Posts
    13

    Just a guess

    I don't see anything wrong with the code. However, I don't see that the bitmap is declared globally and perhaps there is the problem.

    Just LoadBitmap into a global variable and see if it works.

    Don't forget to delete the bitmap when the application finishes.
    Chemanuel

    Lo bueno si breve dos veces bueno (Baltasar Gracián 1601-1658)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Custom button using bitmaps
    By Eirik in forum Windows Programming
    Replies: 2
    Last Post: 11-04-2008, 12:20 AM
  2. Putting tool buttons onto windows
    By eth0 in forum Windows Programming
    Replies: 7
    Last Post: 04-10-2006, 04:15 PM
  3. Loading Bitmaps into BS_OWNERDRAW buttons
    By rEtard in forum Windows Programming
    Replies: 4
    Last Post: 05-04-2005, 08:20 AM
  4. Adding user drawn bitmaps to an existing toolbar
    By korbitz in forum Windows Programming
    Replies: 4
    Last Post: 04-06-2004, 04:16 PM
  5. Displaying bitmaps on a dialog
    By minesweeper in forum Windows Programming
    Replies: 2
    Last Post: 05-15-2002, 03:11 PM