Here I am going to ramble about something, just tell me if I am on the right track.

This is a discussion on Here I am going to ramble about something, just tell me if I am on the right track. within the A Brief History of Cprogramming.com forums, part of the Community Boards category; On a Rect rc; WAIT STILL FORMATING Code: rc.top ================== rc.left | | rc.right | | | | | | ...

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

    Here I am going to ramble about something, just tell me if I am on the right track.

    On a Rect rc;
    WAIT STILL FORMATING


    Code:
                
                           rc.top
                 ==================
     rc.left    |                        | rc.right
                 |                         |
                 |                         |
                 |                         |
                 |                         |
                 ==================
                               rc.bottom
    
    
    Ok, this is the first part of the question, is this analogy right?
    Last edited by incognito; 04-03-2002 at 02:21 PM.
    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
    Feb 2002
    Posts
    591
    I would say it is

  3. #3
    left crog... back when? incognito's Avatar
    Join Date
    Oct 2001
    Posts
    1,427
    Now for the code........

    Code:
    bool Prog_Init()
    {
    	//create a solid red pen
    	hpenNew=CreatePen(PS_SOLID,0,RGB(255,0,0));
    
    	//retrieve the client rectangle for the window
    	RECT rcClient;
    	GetClientRect(hWndMain,&rcClient);
    
    	hrgnClip=CreateEllipticRgn(0,0,rcClient.right,rcClient.bottom);
    
    		
    	//borrow the dc from the main window
    	HDC hdc=GetDC(hWndMain);
    
    	//select the new pen into the dc, and keep the old one
    	hpenOld=(HPEN)SelectObject(hdc,hpenNew);
    
    	//select the clipping region into the dc
    	SelectObject(hdc,hrgnClip);
    
    	//make vertical stripes
    	int nStripeX=rcClient.right/10;
    	int nCount;
    
    	//loop through and draw the stripes
    	for(nCount=0;nCount<10;nCount++)
    	{
    		//moveto the top of the client area
    		MoveToEx(hdc,nStripeX*nCount,0,NULL);
    
    		//line to the bottom of the client area
    		LineTo(hdc,nStripeX*nCount,rcClient.bottom);
    	}
    
    	//make the horizontal stripes
    	int nStripeY=rcClient.bottom/10;
    
    	//loop through and draw the stripes
    	for(nCount=0;nCount<10;nCount++)
    	{
    		//move to the left of the client area
    		MoveToEx(hdc,0,nStripeY*nCount,NULL);
    
    		//line to the right of the client area
    		LineTo(hdc,rcClient.right,nStripeY*nCount);
    	}
    
    	//return the borrowed dc to the system
    	ReleaseDC(hWndMain,hdc);
    
    	return(true);//return success
    }
    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
    left crog... back when? incognito's Avatar
    Join Date
    Oct 2001
    Posts
    1,427
    Not done.......Wait!!!!!!!!
    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.

  5. #5
    Used Registerer jdinger's Avatar
    Join Date
    Feb 2002
    Posts
    1,065
    Besides the slight offset on some parts (which I'm guessing is just a typo), then yes. That's a correct visual representation of a RECT structure's members.

  6. #6
    Used Registerer jdinger's Avatar
    Join Date
    Feb 2002
    Posts
    1,065
    Elchulo2002, this looks exactly like code from Panzera's DX7.0 Iso Programming book. Is there something specific you're having trouble with? I'm almost finished with the book, so let me know if you are having trouble with a specific chapter/exercise.

  7. #7
    left crog... back when? incognito's Avatar
    Join Date
    Oct 2001
    Posts
    1,427
    Originally posted by jdinger
    Elchulo2002, this looks exactly like code from Panzera's DX7.0 Iso Programming book. Is there something specific you're having trouble with? I'm almost finished with the book, so let me know if you are having trouble with a specific chapter/exercise.
    Yes it is.........I will PM later about it Thanks ......oh I am formatting my question on another window so cya...... this is actually kind of funny...lol
    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.

  8. #8
    left crog... back when? incognito's Avatar
    Join Date
    Oct 2001
    Posts
    1,427
    This is what I think.........oh BTW I am the book just pretty much gave me the code for this one, so it's up to me to "find" out how it works..........go figure....


    int nStripeX=rcClient.right/10;
    //assigns rc.client/10 to nstripeX, this would be assuming that the rect was 800*600, this would be 800/10 or 80 that's being assignged to nStripeX.




    //loop through and draw the stripes
    for(nCount=0;nCount<10;nCount++)
    {
    //moveto the top of the client area
    MoveToEx(hdc,nStripeX*nCount,0,NULL);

    //line to the bottom of the client area
    LineTo(hdc,nStripeX*nCount,rcClient.bottom);
    }



    Ok first of all MoveToEx(hdc,nStripeX*nCount,0,NULL);
    ok so I think that here we move our current poing to
    nStripeX*nCount or 80, and our Y coordinate would be zero.....
    so this would be moving our point to the top left corner of our screen (not exactly the top but you know around there)?

    (remember tell me which parts are wrong or right)

    LineTo(hdc,nStripeX*nCount,rcClient.bottom);
    This lines our original point to nStripeX*nCount or 80 again and why would be rcClient.bottom which would be 600 or towards the bottom of the screen therefore making a virtical line..... This loops until it is done 10 times.......Ok Now for your comments please.





    Thank you in Advance.
    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.

  9. #9
    left crog... back when? incognito's Avatar
    Join Date
    Oct 2001
    Posts
    1,427
    And oh yeah the Spaces of between the line would increase, because as ncount increases this value is multiplied by the coordinates?
    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.

  10. #10
    Used Registerer jdinger's Avatar
    Join Date
    Feb 2002
    Posts
    1,065
    Ok first of all MoveToEx(hdc,nStripeX*nCount,0,NULL);
    ok so I think that here we move our current poing to
    nStripeX*nCount or 80, and our Y coordinate would be zero.....
    so this would be moving our point to the top left corner of our screen (not exactly the top but you know around there)?
    Correct. Not quite the top-left corner. The top is correct but it is 80 pixels from the left corner. Coord would be (80,0).

    LineTo(hdc,nStripeX*nCount,rcClient.bottom);
    This lines our original point to nStripeX*nCount or 80 again and why would be rcClient.bottom which would be 600 or towards the bottom of the screen therefore making a virtical line..... This loops until it is done 10 times.......Ok Now for your comments please.
    Yes, this makes a vertical line. This exercise doesn't have too much purpose except to give you an idea of how Regions work (and to be honest you'll hardly ever (if ever) use regions).

  11. #11
    left crog... back when? incognito's Avatar
    Join Date
    Oct 2001
    Posts
    1,427
    Whoho, it feels good when you get something right


    What about this "And oh yeah the Spaces of between the line would increase, because as ncount increases this value is multiplied by the coordinates?"

    Also why is this rcClient.right/10;
    divided by the again, like tell me what it is doing in words, so I can get an idea......Thanks
    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.

  12. #12
    Used Registerer jdinger's Avatar
    Join Date
    Feb 2002
    Posts
    1,065
    Originally posted by elchulo2002
    And oh yeah the Spaces of between the line would increase, because as ncount increases this value is multiplied by the coordinates?
    Exactly. This is the same principle that most game programmers use to cycle through their animation frames.

    For instance, you have a bitmap that is 240 pixels wide (6 frames of an animation, each frame is 40 pixels wide). To cycle through you would incriment an int (for instance, iFrame) and multiply iFrame times 40 (the width of each frame) to get the dimensions for your animation RECT.

    Example:
    Code:
    int iFrame;
    RECT rcAnim, rcBitmap;
    
    //simple anim loop
    iFrame++;
    if(iFrame==5) iFrame=0;
    SetRect(&rcAnim,iFrame*40,0,(iFrame*40)+40,40);
    iFrame*40 gives you the starting left of the RECT, so to get the right just add the width of each "frame" to that number.

  13. #13
    Used Registerer jdinger's Avatar
    Join Date
    Feb 2002
    Posts
    1,065
    Originally posted by elchulo2002
    Whoho, it feels good when you get something right :)
    Glad to be able to help! :D

    Originally posted by elchulo2002
    Also why is this rcClient.right/10;
    divided by the again, like tell me what it is doing in words, so I
    can get an idea......Thanks
    This is just a way to get a number that we can use as a refrerence for when you cycle through the animation (LineTo) part of the loop. It simply gives us 10 evenly spaced lines drawn. So if you wanted 20 you'd just use:

    int nStripeY=rcClient.bottom/20;

    rcClient.bottom is the farthest distance from 0 so we set our integer value based off of it. This way if you want to have 20 evenly spaced lines (irregardless of the size of your window) you'll always have it. As long as you trigger it to refigure the value of nStripeY whenever you get a WM_PAINT message. ie: you can resize your window to any size and you'll always have 20 evenly spaced vertical lines.

  14. #14
    left crog... back when? incognito's Avatar
    Join Date
    Oct 2001
    Posts
    1,427
    Ok Thank you.........Guess I can move on now with my reading......


    PS. Check your PM Box.
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 19
    Last Post: 12-18-2007, 09:24 AM
  2. Linked List Part 2
    By Nish in forum C Programming
    Replies: 18
    Last Post: 03-09-2005, 04:05 PM
  3. Keeping track of static external structure
    By pwilfred in forum C Programming
    Replies: 6
    Last Post: 03-13-2003, 05:23 PM
  4. F1 track analyser
    By Unregistered in forum Game Programming
    Replies: 1
    Last Post: 01-22-2002, 08:48 AM
  5. I want to get back on the track..
    By Lameth in forum C++ Programming
    Replies: 1
    Last Post: 11-15-2001, 04:30 AM

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