title: How do I set the text and background color of an single static control c++?
body: <p>I have managed to set the colors of static and edit
  controls when I set all of them to the same color, but I cant figure out how
  to set the color of just one without affecting the others. I've looked around on the internet but none of the things I find are about how to set color of just one
  static or edit control. Here is the code I am using at the moment to set the color of all static text fields:</p>
  <pre><code>#include &lt;windows.h&gt;
  
  LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);
  
  HWND staticTextField, staticTextFieldTwo;
  
  char szClassName[ ] = &quot;WindowsApp&quot;;
  
  int WINAPI WinMain(HINSTANCE hThisInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR lpszArgument,
                     int nFunsterStil)
  
  {
      HWND hwnd;
      MSG messages;
      WNDCLASSEX wincl;
  
      wincl.hInstance = hThisInstance;
      wincl.lpszClassName = szClassName;
      wincl.lpfnWndProc = WindowProcedure;
      wincl.style = CS_DBLCLKS; 
      wincl.cbSize = sizeof (WNDCLASSEX);
  
      wincl.hIcon = LoadIcon(NULL, IDI_APPLICATION);
      wincl.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
      wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
      wincl.lpszMenuName = NULL;
      wincl.cbClsExtra = 0;
      wincl.cbWndExtra = 0;
      wincl.hbrBackground = CreateSolidBrush(RGB(0, 255, 255));
  
      if (!RegisterClassEx (&amp;wincl))
          return 0;
  
      hwnd = CreateWindowEx (
         0,
         szClassName,
         &quot;Windows app&quot;,
         WS_OVERLAPPED | WS_SYSMENU | WS_MINIMIZEBOX | WS_MAXIMIZEBOX,
         CW_USEDEFAULT,
         CW_USEDEFAULT,
         544,
         375,
         HWND_DESKTOP,
         NULL,
         hThisInstance,
         NULL
      );
  
      ShowWindow (hwnd, nFunsterStil);
  
      while (GetMessage (&amp;messages, NULL, 0, 0))
      {
          TranslateMessage(&amp;messages);
          DispatchMessage(&amp;messages);
      }
  
      return messages.wParam;
  }
  
  
  LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam,
  LPARAM lParam)
  {
      HDC hdcStatic = (HDC)wParam;
  
  switch (message)
  {
      case WM_DESTROY:
          PostQuitMessage (0);
          break;
      case WM_CREATE:
  
           staticTextField = CreateWindow(&quot;STATIC&quot;, &quot;static 1&quot;, WS_VISIBLE 
           | WS_CHILD, 20, 20, 300, 25, hwnd, NULL, NULL, NULL);
  
  
           staticTextFieldTwo = CreateWindow(&quot;STATIC&quot;, &quot;static2&quot;, WS_VISIBLE | 
           WS_CHILD | WS_BORDER, 100, 200, 300, 20, hwnd, NULL, NULL, NULL);
  
           break;
      case WM_CTLCOLORSTATIC:
          SetTextColor(hdcStatic, RGB(255, 0, 0));
          SetBkColor(hdcStatic, RGB(0, 255, 255));
          return (INT_PTR)CreateSolidBrush(RGB(0, 255, 255));
          break;
      default:
          return DefWindowProc(hwnd, message, wParam, lParam);
  }
  
  return 0;
  }
  </code></pre>