title: a better way to draw grid as background
body: <p>I want to draw grid as in the below picture.<img src="https://i.stack.imgur.com/77uau.png" alt="enter image description here"></p>
  
  <p>I know a trick to draw this by draw 6 vertical and horizontal lines instead of 6 x 6 small rectangle.</p>
  
  <p>But if I want to have smaller zoom (zoom for viewing picture), the lines are many. For example, say my view window is of size 800 x 600 and viewing a picture of size 400 x 300 (so zoom in is 2). There will be 400 x 300 rectangle of size 2 x 2 (each rectangle represents a pixel).</p>
  
  <p>If I draw each cell (in a loop, say 400 x 300 times), it is very slow (when I move the window...).
  Using the trick solves the problem.</p>
  
  <p>By I am still curious if there is a better way to do this task in winapi, GDI(+). For example, a function like <code>DrawGrid(HDC hdc, int x, int y, int numOfCellsH, int numOfCellsV)</code>?</p>
  
  <p>A further question is: If I don't resize, move the window or I don't change the zoom in, the grid won't be changed. So even if I update the picture continuously (capture screen), it is uncessary to redraw the grid. But I use <code>StretchBlt</code> and <code>BitBlt</code> to capture the screen (to memory DC then hdc of the window), if I didn't redraw the grid in memory DC, then the grid will disappear. Is there a way to make the grid stick there and update the bitmap of the screen capture?</p>
  
  <p>ps: This is not a real issue. Since I want to draw the grid when zoom is not less than 10 (so each cell is of size 10 x 10 or larger). In this case, there will be at most 100 + 100 = 200 lines to draw and it is fast. I am just  curious  if there is a faster way. </p>