Help With Rectangle,

This is a discussion on Help With Rectangle, within the Windows Programming forums, part of the Platform Specific Boards category; as some of you might already know I am learning programming on my own for now, I've bumped into the ...

  1. #1
    left crog... back when? incognito's Avatar
    Join Date
    Oct 2001
    Posts
    1,427

    Help With Rectangle,

    as some of you might already know I am learning programming on my own for now, I've bumped into the function that draws a rectangle (I think) but I don't know how to implement it.......could anybody please show me an example of it?


    This is all the book says.......

    BOOL Rectangle ( HDC hdc, int nleftrect, int ntoprect, int nrightrect, int nbottomrect );

    return nonzero on failure.....



    could you please show me an example of how this could be used on a win32 program?
    There are some real morons in this world please do not become one of them, do not become a victim of moronitis. PROGRAMMING IS THE FUTURE...THE FUTURE IS NOW!!!!!!!!!

    "...The only real game I thank in the world is baseball..." --Babe Ruth

    "Life is beautiful"-Don Corleone right before he died.

    "The expert on anything was once a beginner" -Baseball poster I own.


    Left cprog on 1-3-2005. Don't know when I am coming back. Thanks to those who helped me over the years.

  2. #2
    Registered User
    Join Date
    Mar 2002
    Posts
    8
    After the window is passed the WM_PAINT message have the window do something similar to the following:

    PAINTSTRUCT ps;
    HDC hDc;
    HPEN hpen;

    hDc=BeginPaint([handle of window to draw to], &ps);
    //Create a pen to draw with
    hpen=CreatePen(PS_SOLID, 1, RGB(0,0,0));
    //Select pen into the device context
    SelectOjbect(hDc, hpen);
    //draw the rectangle (using current pen)
    Rectangle(hDc, 0, 0, 25, 25);
    ......
    EndPaint([window handle], &ps);
    DeleteObject(hpen);

    Hope this helps.

  3. #3
    left crog... back when? incognito's Avatar
    Join Date
    Oct 2001
    Posts
    1,427
    Thank you very much Been......I Shall save this info
    There are some real morons in this world please do not become one of them, do not become a victim of moronitis. PROGRAMMING IS THE FUTURE...THE FUTURE IS NOW!!!!!!!!!

    "...The only real game I thank in the world is baseball..." --Babe Ruth

    "Life is beautiful"-Don Corleone right before he died.

    "The expert on anything was once a beginner" -Baseball poster I own.


    Left cprog on 1-3-2005. Don't know when I am coming back. Thanks to those who helped me over the years.

  4. #4
    Registered User
    Join Date
    Mar 2002
    Posts
    8
    Glad I could help.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Rectangle class
    By blackant in forum C++ Programming
    Replies: 1
    Last Post: 04-23-2009, 09:33 AM
  2. segmetation fault (reading and writing file in c)
    By tasosa in forum C Programming
    Replies: 5
    Last Post: 04-13-2009, 07:04 AM
  3. Struct Program to find Point in Rectangle
    By DMJKobam in forum C++ Programming
    Replies: 2
    Last Post: 04-09-2009, 09:56 PM
  4. Point passed rectangle...
    By Hunter2 in forum Game Programming
    Replies: 15
    Last Post: 10-10-2003, 10:57 AM
  5. Collision detection algorithm
    By Hannwaas in forum Game Programming
    Replies: 5
    Last Post: 11-30-2001, 01:27 PM

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