title: Set background color of a specific control
body: <p>I have searched the net looking for a way to set background color a dialog control.</p>
  
  <p>I have managed to do this with this code:</p>
  
  <pre><code>case WM_CTLCOLORSTATIC:
  {
      HDC hdcStatic = (HDC) wParam;
      SetTextColor(hdcStatic, RGB(255,255,255));
      SetBkColor(hdcStatic, RGB(0,0,0));
  
      if (hbrBkgnd == NULL)
      {
          hbrBkgnd = CreateSolidBrush(RGB(0,0,0));
      }
      return (INT_PTR)hbrBkgnd;
  }
  </code></pre>
  
  <p>However, what I am actually looking for is to color only a specific static control, not all the static controls I have in my dialog. Is there anyway to do this? Perhaps set the hdc to something using GetDlgItem(hdlg,"IDC_MYCONTROL") ?</p>
  
  <p>-- UPDATE</p>
  
  <p>After the suggestions I ended up with this :</p>
  
  <pre><code>case WM_CTLCOLORSTATIC:
  {
      HDC hdcStatic = (HDC) lParam;
      HWND hWnd =  (HWND)lParam;
      HWND dlg =GetDlgItem(hDlg, IDC_STATIC2);
      if (hWnd == dlg)
      {
          SetTextColor(hdcStatic, RGB(255,255,255));
          SetBkColor(hdcStatic, RGB(0,0,0));
      }
      if (hbrBkgnd == NULL)
      {
          hbrBkgnd = CreateSolidBrush(RGB(0,0,0));
      }
      return (INT_PTR)hbrBkgnd;
  }
  </code></pre>
  
  <p>And it seems that even if SetBkColor is run nothing changes on the dialog, leading on the wierd problem described below.</p>