0

I changed the button's background color but the button looks like a flat button, the focus rectangle around it is gone, so is the mouse effect when you pass mouse over it.

Below, the mouse over effect I'm talking about.

the regular button:

enter image description here

when mouse pass over it:

enter image description here

Currently the button I changed the background color look like this:

enter image description here

Why does it look like a flat button and how can I change that?

I thought this was going to look like this without focus:

enter image description here

with focus:

enter image description here

I'd like to change that border color too but still have the focus rectangle around it.

Here's my WM_NOTIFY:

case WM_NOTIFY:
{
    LPNMHDR pnm = (LPNMHDR) lParam;
    if(pnm->hwndFrom == hButton1_tab1 && pnm->code == NM_CUSTOMDRAW)
    {
      LRESULT res = CustomDrawButton(pnm->hwndFrom, (LPNMCUSTOMDRAW) lParam);
      LPNMCUSTOMDRAW nmc = (LPNMCUSTOMDRAW) lParam;
      if(nmc->dwDrawStage == CDDS_PREPAINT)
      {
          HDC hdc = nmc->hdc;
          RECT rc = nmc->rc;
          FillRect(hdc, &rc, hBrush);
          return CDRF_NOTIFYITEMDRAW;
      }
    }
}
break;

hBrush is defined as:

 hBrush = CreateSolidBrush(RGB(0, 128, 0));
Jack
  • 16,276
  • 55
  • 159
  • 284
  • If you custom draw a button you draw everything, so if you want it to have a 3D border or translucency or whatever, it's up to you to draw it. – Jonathan Potter Jan 16 '21 at 06:23
  • You can refer to [How can I change the background color of a button WinAPI C++](https://stackoverflow.com/questions/18745447/how-can-i-change-the-background-color-of-a-button-winapi-c) and [WINAPI: Colored Border for Static Dialog Item](https://stackoverflow.com/questions/28738658/winapi-colored-border-for-static-dialog-item) to realize to modify the style of the button and set the border color. – Zeus Jan 18 '21 at 03:26

0 Answers0