Drawing a grid on a plain rectangle

This is a discussion on Drawing a grid on a plain rectangle within the Windows Programming forums, part of the Platform Specific Boards category; I am trying to draw a grid onto a plain rectangle, and am finding this quite difficult to do so.. ...

  1. #1
    Registered User
    Join Date
    Dec 2001
    Posts
    12

    Lightbulb Drawing a grid on a plain rectangle

    I am trying to draw a grid onto a plain rectangle, and am finding this quite difficult to do so..

    basically i have a RECT structure which draws a rectangle using the function SetRect. eg

    SetRect(&r,1,1,400,400)

    paints a Rectangle in the WM_PAINT when created.

    I was thinking of drawing loads of mini rectangles inside this but am having trouble doing so....

    can anyone suggest an easier way or hint as to whether im going about this the correct way??

  2. #2
    Registered User (TNT)'s Avatar
    Join Date
    Aug 2001
    Location
    UK
    Posts
    339
    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
    TNT
    You Can Stop Me, But You Cant Stop Us All

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Tips for drawing a grid
    By countchocula in forum C Programming
    Replies: 12
    Last Post: 04-19-2008, 08:47 AM
  2. Drawing a rectangle in a control
    By Joelito in forum Windows Programming
    Replies: 6
    Last Post: 12-15-2006, 07:51 PM
  3. Drawing a rectangle
    By maxorator in forum Windows Programming
    Replies: 2
    Last Post: 08-01-2006, 09:37 AM
  4. Drawing rectangle in a web page
    By alphaoide in forum Tech Board
    Replies: 3
    Last Post: 02-20-2005, 07:40 PM
  5. Help With pointers in classes.
    By indigo0086 in forum C++ Programming
    Replies: 12
    Last Post: 10-10-2002, 03:03 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21