Jump to content
  • Advertisement
Sign in to follow this  
shishio

What is this code doing?

This topic is 4811 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm reading Charles Petzold's "Programming Windows 5th Edition" and I was looking at this Blokout1 program, he has this chunk of code in the CALLBACK function:
	case WM_LBUTTONDOWN:
		ptBeg.x = ptEnd.x = LOWORD(lParam);
		ptBeg.y = ptEnd.y = HIWORD(lParam);

		//DrawBoxOutline(hwnd, ptBeg, ptEnd);

		SetCursor(LoadCursor(NULL, IDC_CROSS));

		fBlocking = TRUE;
		return 0;

The DrawBoxOutline function is:

void DrawBoxOutline(HWND hwnd, POINT ptBeg, POINT ptEnd)
{
	HDC hdc;

	hdc = GetDC(hwnd);

	SetROP2(hdc, R2_NOT);
	SelectObject(hdc, GetStockObject(NULL_BRUSH));
	Rectangle(hdc, ptBeg.x, ptBeg.y, ptEnd.x, ptEnd.y);

	ReleaseDC(hwnd, hdc);
}

If you've noticed I've commented out the call to the DrawBoxOutline function... because I don't know what it's for! It will never draw a rectangle because the beginning and end point are the same, am I right? I feel like I missing something here... [edit] Washu: Like, so...you can click edit on your post to see how. [Edited by - Washu on June 16, 2005 12:06:43 AM]

Share this post


Link to post
Share on other sites
Advertisement
By the way how do you make that white block of code in your posts so you can write code neatly?

Share this post


Link to post
Share on other sites
You use the <source> </source> tags. I don't have that book here so I can't check out the page and it's been a while since I've done win32 programming so I'll leave the answer to someone else, though I think that it will draw a single pixel where the mouse has been clicked.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
(source lang="c++") hello (/source)

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
 Hello 

Share this post


Link to post
Share on other sites
Just so everyone knows, to make the tags look correct, such as [source] [/source], you will have to use HTML entities. So the code for the [ is &#91; and the ] is &#93; [smile] For more entities take a look at this page.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!