title: Which class, part and state is used to draw selection?
body: <p>I'm trying to draw selection/focus frame in my custom windows forms control using visual styles on Windows 7 with Aero enabled. I tried this one:</p>
  
  <pre><code>VisualStyleRenderer selectionRenderer = new VisualStyleRenderer(VisualStyleElement.ListView.Item.Selected);
  selectionRenderer.DrawBackground(g, visual.ItemArea);
  </code></pre>
  
  <p>And this one:</p>
  
  <pre><code>VisualStyleRenderer selectionRenderer = new VisualStyleRenderer(VisualStyleElement.TreeView.Item.Selected);
  selectionRenderer.DrawBackground(g, visual.ItemArea);
  </code></pre>
  
  <p>However, both fail with information, that neither TreeView.Item.Selected, nor ListView.Item.Selected is supported in current style. But hey, Windows draws the selection in the UI's treeviews:</p>
  
  <p><img src="https://i.stack.imgur.com/KraHo.png" alt="Selection in treeview"></p>
  
  <p>And listviews:</p>
  
  <p><img src="https://i.stack.imgur.com/fylcm.png" alt="Selection in listview"></p>
  
  <p>So which class and part should I use to draw the system selection rectangle?</p>
  
  <hr />
  
  <p><b>Edit:</b> I've tried to write the code in pure WinAPI. Here's a code fragment:</p>
  
  <pre><code>case WM_PAINT:
      {
          PAINTSTRUCT ps;
          HDC hdc = BeginPaint(hwnd, &amp;ps); 
  
          HTHEME theme = OpenThemeData(hwnd, L"TREEVIEW");
          RECT rect;
          rect.left = 10;
          rect.top = 10;
          rect.right = 80;
          rect.bottom = 80;
          DrawThemeBackground(theme, hdc, TVP_TREEITEM, TREIS_SELECTED, &amp;rect, &amp;rect);
          CloseThemeData(theme);
  
          EndPaint(hwnd, &amp;ps); 
          return 0L; 
      }
  </code></pre>
  
  <p>The result looks as following:</p>
  
  <p><img src="https://i.stack.imgur.com/8HYxe.png" alt="Selection drawn in WinAPI"></p>