Hey man, i dunno if this is the correct way but its easier, i aint on my comp with my programming stuff now so heres a small example you should be able to recode it for your needs.
Code:
int a, i = 0;
//vertical grid lines
for(a = 0; a < 40; a+=10)
{
MoveToEx(hdc, a, 1, NULL);
LineTo(hdc, a, 400);
}
//horizontal grid lines
for(a = 0; a < 40; a+=10)
{
MoveToEx(hdc, 1, a, NULL);
LineTo(hdc, 400, a);
}
As i say check up on those params im very tired right now. But you can see that what its doing is just repeating line drawing across your rectangle to form a grid.
Hope thats of some help,
TNT