Thread: Button Displaying Image

  1. #1
    Registered User mrafcho001's Avatar
    Join Date
    Jan 2005
    Posts
    483

    Button Displaying Image

    I have a button that displays an image, but there is still like a border around the image. How can i remove it?

    There is a yellow border around the image on the button. Also how can i make the button flat, so that it is not raised?

    I am creating the button like this:
    Code:
    InB = CreateWindowEx(WS_EX_WINDOWEDGE, "BUTTON", "File In", WS_CHILD | WS_VISIBLE | BS_BITMAP,
    			30, 78, 70, 24, hwnd, (HMENU)MAIN_FIN, GetModuleHandle(NULL), NULL);
    Here is what i mean:
    My Website
    010000110010101100101011
    Add Color To Your Code!

  2. #2
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    Start by removing the WS_EX_WINDOWEDGE extended style which
    Quote Originally Posted by msdn
    Specifies that a window has a border with a raised edge.

    See CreateWindowEx.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  3. #3
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    He's back!


    You could also try adding the BS_FLAT style.

  4. #4
    Registered User mrafcho001's Avatar
    Join Date
    Jan 2005
    Posts
    483
    Quote Originally Posted by Ken Fitlike
    Start by removing the WS_EX_WINDOWEDGE extended style which

    What do i put in place of it?

    EDIT:

    Also I have a checkbox button, how do i change the background color of that, because my current bg color of the window is gray, but the checkbox has some kind of yellowish.
    Last edited by mrafcho001; 12-03-2005 at 02:09 PM.
    My Website
    010000110010101100101011
    Add Color To Your Code!

  5. #5
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    Null or 0 (zero).

    >>checkbox...change background color of that<<

    Search the boards as this one's been asked and answered many times in the past.

    edit: Actually the situation is a little more complicated because a checkbox is a button control - read this msdn page, which, while old, is still relevant to later operating systems such as winxp. In short, just handle the WM_CTLCOLORSTATIC message send to the checkbox's parent and return a brush which will be used to paint the control background. Make sure you free up any gdi resources you used to create the brush, assuming it's a non-system, non-shared object. For example, something like:
    Code:
    case WM_CTLCOLORSTATIC:
      {
      int nID=GetDlgCtrlID((HWND)lParam);
    
      if (nID==YOUR_CHECKBOX_ID)
        {
        return (LRESULT)GetStockObject(BLACK_BRUSH); /*or your own brush*/
        }
      return DefWindowProc(hwnd,uMsg,wParam,lParam);
      }
    >>He's back!<<

    And just when the standards of the boards were improving, too.
    Last edited by Ken Fitlike; 12-03-2005 at 02:29 PM.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem reading tiff image files?
    By compz in forum C++ Programming
    Replies: 9
    Last Post: 10-30-2009, 04:17 AM
  2. C Programming 2d Array Question
    By jeev2005 in forum C Programming
    Replies: 3
    Last Post: 04-26-2006, 03:18 PM
  3. Using a image like a button
    By cgod in forum Windows Programming
    Replies: 1
    Last Post: 02-13-2005, 04:19 PM
  4. displaying a bitmap on a button
    By korbitz in forum Windows Programming
    Replies: 13
    Last Post: 04-01-2004, 05:35 PM
  5. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 09:44 AM