title: Win32 (GDI) - Set Opacity of STATIC Control
body: <p><strong>I'm using C - (NO MFC or GDI+)</strong> :-)</p>
  
  <p>What I want is to set the opacity of my child window to let say 100 (my child window is a <code>STATIC</code> control). I was wondering if this is even possible and if so can someone please point me to the right direction on how to do it.</p>
  
  <p>Here is my setup:</p>
  
  <p>I create my Parent window as follow:</p>
  
  <pre><code>HWND     hWnd;
  WNDCLASS wndCls_s;
  
  
  wndCls_s.style         = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
  wndCls_s.lpfnWndProc   = MainWndProc;
  wndCls_s.cbClsExtra    = 0;
  wndCls_s.cbWndExtra    = 0;
  wndCls_s.hInstance     = hInstance;
  wndCls_s.hIcon         = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_BSN_64));
  wndCls_s.hCursor       = LoadCursor(NULL, IDC_ARROW);
  wndCls_s.hbrBackground = CreateSolidBrush(RGB(0, 0, 0));
  wndCls_s.lpszMenuName  = NULL;
  wndCls_s.lpszClassName = pszCName;
  
  if (RegisterClass(&amp;wndCls_s) == 0)
      return EXIT_FAILURE;
  
  
  /* Creating Window */
  hWnd = CreateWindow(
      pszCName, pszCName,
      WS_VISIBLE | WS_POPUP | WS_SYSMENU | WS_CLIPCHILDREN,
      0, 0, WND_WIDTH, WND_HEIGHT,
      NULL, NULL, hInstance, NULL);
  </code></pre>
  
  <p>In my <code>MainWndProc</code>:</p>
  
  <pre><code>case WM_CREATE: 
      {   
      HWND hWndChild = CreateWindow(
          L"STATIC", (LPCTSTR) NULL,
          WS_CHILD | WS_VISIBLE,
          10, 10, 110, 110,
          hWnd, (HMENU) (int) 10000, 
          g_hInst, NULL);
      }
      break;
  case WM_CTLCOLORSTATIC:
      {
      COLORREF dwColor; 
  
      dwColor = RGB(255, 0, 0);
      hDC = (HDC) wParam;
  
      //SetBkColor(hDC, dwColor);
      SetBkMode(hDC, TRANSPARENT);
  
      /*
      This is not going to work for child window
      SetWindowLong(
          hWnd, GWL_EXSTYLE,
          GetWindowLong((HWND)lParam, GWL_EXSTYLE) &amp; ~WS_EX_LAYERED);
  
          SetLayeredWindowAttributes(
              (HWND)lParam, 0, 100, LWA_ALPHA);
          RedrawWindow((HWND)lParam, NULL, NULL, RDW_ERASE | RDW_INVALIDATE);
      */
  
      if (g_hBrushRed == NULL)
          g_hBrushRed = CreateSolidBrush(dwColor);
      }
      return (INT_PTR)g_hBrushRed;
  </code></pre>