Thread: Creating my own button

  1. #1
    Funniest man in this seat minesweeper's Avatar
    Join Date
    Mar 2002
    Posts
    798

    Creating my own button

    I have created 4 ownerdraw buttons as child windows and I am trying to display a bitmap on the buttons.

    I believe the correct way of doing this is to use the SendMessage function with the message BM_SETIMAGE. On MSDN it is given as this:

    Code:
    To send this message, call the SendMessage function as follows. 
    
    lResult = SendMessage(      (HWND) hWndControl,           (UINT) BM_SETIMAGE,      (WPARAM) wParam,          (LPARAM) lParam      );  
    
    Parameters:
    
    wParam
    Specifies the type of image to associate with the button. This parameter can be one of the following values: 
    IMAGE_BITMAP
    IMAGE_ICON
    
    lParam
    Handle to the image to associate with the button.
    I have entered IMAGE_BITMAP in as the third argument and as the fourth argument I have used the handle to my bitmap. The problem is that it won't compile stating that the fourth argument should be a long. I tried type casting this argument and it compiled but did not display the bitmap. I believe my method of creating the handle to the bitmap is correct as I have used it elsewhere successfully. Am I doing anything wrong with regards to the use of the SendMessage function?

  2. #2
    Magically delicious LuckY's Avatar
    Join Date
    Oct 2001
    Posts
    856
    Did you cast it to (LPARAM)?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Profiler Valgrind
    By afflictedd2 in forum C++ Programming
    Replies: 4
    Last Post: 07-18-2008, 09:38 AM
  2. Creating a function pointer from a button click event?
    By dxfoo in forum Windows Programming
    Replies: 20
    Last Post: 01-29-2008, 03:35 AM
  3. creating a button
    By scwizzo in forum Windows Programming
    Replies: 19
    Last Post: 06-07-2007, 07:52 PM
  4. creating a button without a focus rect
    By X PaYnE X in forum Windows Programming
    Replies: 0
    Last Post: 05-11-2005, 10:16 PM
  5. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 09:44 AM