title: win32 - How to draw a rectangle around a text string?
body: <p>I am new to Win32 and trying to get a GDI based code in C++ ( for technical reasons don't want to use GDI+)</p>
  
  <p>Edit: Simplied the question:</p>
  
  <p>I need to draw a rectangle around the text that is drawn in the middle of the window.
  - How can I populate the rectangle co-ordinates?
  - Can any one help with the line - Rectangle(x1,y1,x2,y2)?  - How to calculate these (x1,y1) &amp; (x2,y2) values?</p>
  
  <p>Thank you.. </p>
  
  <pre><code>        hdc = BeginPaint(hWnd, &amp;ps);
      GetClientRect(hWnd, &amp;rcClient);
      SelectObject(hdc, GetStockObject(DEFAULT_GUI_FONT));
      SetTextColor(hdc, RGB(255, 0, 0));
  
      DrawText(hdc, wstring(s.begin(),s.end()).c_str(), -1, &amp;rectResult, DT_SINGLELINE | DT_CALCRECT);
  
      DrawText(hdc, wstring(s.begin(),s.end()).c_str(), -1, &amp;rcClient, DT_SINGLELINE | DT_CENTER | DT_VCENTER);
  
      // Here I need help - How to I place the rectangle around the Text - which is drawn in the middle of the window?
      // It looks like need to use - rectResult.bottom/top/left/right - but don't know how.. 
      Rectangle(hdc, 0,0,100,100);   
  </code></pre>