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?
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 03: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.
I would say it is
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.
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.
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.
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...lolOriginally 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.
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.
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.
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.
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).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)?
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).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.
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.
Exactly. This is the same principle that most game programmers use to cycle through their animation frames.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?
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:
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.Code:int iFrame; RECT rcAnim, rcBitmap; //simple anim loop iFrame++; if(iFrame==5) iFrame=0; SetRect(&rcAnim,iFrame*40,0,(iFrame*40)+40,40);
Glad to be able to help! :DOriginally posted by elchulo2002
Whoho, it feels good when you get something right :)
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: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
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.
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.