Hello to all!

In the attachment screen program. + Attach code written in Visual Studio. C ++. via WinAPI.

How to remove this white frame around the button, or make it the background color? The button is created automatically through the resources by transferring it to the main program window.

case WM_INITDIALOG: { // Фон HBRUSH hBrush; HDC hdc; PAINTSTRUCT ps; RECT rc; COLORREF g_Green = RGB(0, 249, 249); hdc = BeginPaint(hwnd, &ps); GetClientRect(hwnd, &rc); hBrush = CreateSolidBrush(g_Green); // COLORREF g_Green = RGB(0,255,0); FillRect(hdc, &rc, hBrush); EndPaint(hwnd, &ps); DeleteObject(hBrush); // Кнопка HWND CMDListControl = GetDlgItem(hwnd, IDOK); HBITMAP hBitmap; hBitmap = LoadBitmap(hInst, MAKEINTRESOURCE(IDB_BITMAP1)); SendMessage(CMDListControl, BM_SETIMAGE, IMAGE_BITMAP, (LPARAM)hBitmap); break; } 

Program

  • Remove WS_BORDER and other similar styles from the button styles. (styles in the resource file) - nick_n_a
  • <code> IDD_DIALOG1 DIALOGEX 0, 0, 246, 153 STYLE DS_SETFONT | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_SYSMENU FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN PUSHBUTTON "OK", IDOK, 45,56,166,21, BS_BITMAP END <code> Like nothing like this - KrYpToDeN

1 answer 1

Perhaps you will be helped by setting the style for the BS_FLAT button:

 SendMessage(CMDListControl, BM_SETSTYLE, BS_FLAT, MAKELPARAM(TRUE, 0)); 
  • The BS_FLAT style can also be added directly to resources. - nick_n_a
  • Had tried. But in this case, an additional black stroke is also drawn (what other suggestions are there? - KrYpToDeN
  • maybe you should try to tell her that her style is her style minus WS_BORDER as recommended above =) - Markelov Edward
  • SendMessage (CMDListControl, BM_SETSTYLE, -WS_BORDER, MAKELPARAM (TRUE, 0)); Something like that? does not work ( - KrYpToDeN
  • You are using a push-button, and it seems that none of the above will help you. You need to do msdn OwnerDraw section BS_OWNERDRAW - nick_n_a