Remove dialog button border

This is a discussion on Remove dialog button border within the Windows Programming forums, part of the Platform Specific Boards category; I'm having a problem with the dialog button control. I have loaded a bitmap over the button (successfully), however, the ...

  1. #1
    Registered User
    Join Date
    Jun 2005
    Location
    Philadelphia
    Posts
    16

    Question Remove dialog button border

    I'm having a problem with the dialog button control. I have loaded a bitmap over the button (successfully), however, the border around the button remains. I've made sure that there's nothing specifying borders checked under properties, and I've even double checked by opening my program with a resource editor and checking that WS_BORDER isn't a style for the button. Is there any way to just have a flat bitmap button?

  2. #2
    Registered User Queatrix's Avatar
    Join Date
    Apr 2005
    Posts
    1,342
    It looks like you'r printing the bitmap in the parent window's callback and HDC. You need to do it in the button's own callback and HDC. Give the button the style BS_FLAT too.

  3. #3
    Registered User
    Join Date
    Jun 2005
    Location
    Philadelphia
    Posts
    16
    Quote Originally Posted by Cool-August
    It looks like you'r printing the bitmap in the parent window's callback and HDC. You need to do it in the button's own callback and HDC. Give the button the style BS_FLAT too.
    I'm sending a message directly to the button on the dialog with
    Code:
    SendDlgItemMessage(hDlg, IDC_OKAYBUTTON, BM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM)LoadBitmap(GetModuleHandle(NULL), MAKEINTRESOURCE(IDB_OKAY)));
    . The button is actually a button control, not a button done with CreateWindow. If I used GetDC and all that to draw within the button wouldn't it still be limited to the frame? Currently everything "works" so to speak, it's just that if I have an 80x20 pixel bitmap and an approx. 60x10 button then only 60x10 of the bitmap will be displayed.

  4. #4
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    Unless the button has the BS_OWNERDRAW style or has been subclassed then the system will paint the button, despite your attempts to circumvent this. Since you already seem to be attempting to draw it, I'd suggest going all the way with an owner-drawn button by giving the control the BS_OWNERDRAW style and handling the parent's WM_DRAWITEM message.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  5. #5
    Registered User
    Join Date
    Jun 2005
    Location
    Philadelphia
    Posts
    16
    Quote Originally Posted by Ken Fitlike
    Unless the button has the BS_OWNERDRAW style or has been subclassed then the system will paint the button, despite your attempts to circumvent this. Since you already seem to be attempting to draw it, I'd suggest going all the way with an owner-drawn button by giving the control the BS_OWNERDRAW style and handling the parent's WM_DRAWITEM message.
    Perfect, this works exactly as planned. Thanks.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. BN_CLICKED, change button style
    By bennyandthejets in forum Windows Programming
    Replies: 13
    Last Post: 07-05-2010, 11:42 PM
  2. Replies: 9
    Last Post: 02-13-2008, 01:59 PM
  3. Button coordinates in dialog. Strange ?
    By fizisyen in forum Windows Programming
    Replies: 1
    Last Post: 08-23-2004, 09:29 PM
  4. Click button on dialog box to open window.
    By ooosawaddee3 in forum Windows Programming
    Replies: 1
    Last Post: 11-29-2002, 07:53 AM
  5. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 09:44 AM

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