Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   C++ (http://www.programmingforums.org/forum15.html)
-   -   Windows Encapsulation (http://www.programmingforums.org/showthread.php?t=10653)

Zap Jul 7th, 2006 11:56 AM

Windows Encapsulation
 
This maybe a dumb question, but I was thinking of making a header that pretty much takes care of the windows message procedure (execpt of course, wm_command) and a few other things for me so my code will be more readable. Although, I just started learning windows programming last year and am still kinda getting the hang of it, so I thought it might be good practice for me to get used to typing out and seeing that redunant code, so I could learn it. What do you think? Should I hide the windows code in a class to make things easy or leave it how it is?

Mad_guy Jul 7th, 2006 1:58 PM

You only need to type out code in the message handler if you really need it. There are some [semi-]obligatory parts of the message handler (WM_QUIT and WM_CLOSE really), but if you aren't going to respond to a message or don't really care about it, let DefWindowProc handle it.

If you just want to make your message handler look better, check out the Message Cracker macro's in windowsx.h.

Zap Jul 7th, 2006 2:36 PM

Thanks, I'll check it out. I was just going to encase some redunant code in a class just to make it easier for people to read. Because people complain when you shove too much code in one place.

Prm753 Jul 7th, 2006 3:11 PM

Quote:

Originally Posted by Zap
Because people complain when you shove too much code in one place.

Off-topic alert: Don't read my code then. I have so much code crammed into so few space.... :p

Zap Jul 7th, 2006 3:30 PM

It's just easier on the eyes. I have some friends who aren't great with windows api, or C++ in general. It's best I can show them better organized code so they can understand...

frankish Jul 7th, 2006 8:00 PM

encapsulation, the word sucks. To make a long tip short stick to the Windows API or Microsoft MFC. It's a pain in the ass to encapsulate the Windows API. I'm taking this from experience.

DaWei Jul 7th, 2006 9:12 PM

Encapsulation is great. I take my vitamins by swallowing one gelatin thangy instead of trying to pick up all those tiny little flecks of this and that. I work on my carburetor by removing one assembly from one place instead of having to take part from my hood ornament, part from my trunk, and part from my turn signal. If someone represents sticking a sow's ear up a hog's ass and coming out with a silk purse as a fait accompli, well, that's just a bad job and a typical huckster's approach. Don't mistake the two.

frankish Jul 7th, 2006 9:41 PM

Quote:

Originally Posted by DaWei
Encapsulation is great. I take my vitamins by swallowing one gelatin thangy instead of trying to pick up all those tiny little flecks of this and that. I work on my carburetor by removing one assembly from one place instead of having to take part from my hood ornament, part from my trunk, and part from my turn signal. If someone represents sticking a sow's ear up a hog's ass and coming out with a silk purse as a fait accompli, well, that's just a bad job and a typical huckster's approach. Don't mistake the two.

Ok, but have you tried encasulating the Windows API?

DaWei Jul 7th, 2006 11:23 PM

When I saw the plaid jacket and white shoes, I left. One needs to develop discernment. Who wants to traipse around the world yelling, "Hey, Bob", "Hey, Bob" when unthinking echoes are so cheap.

Zap Jul 8th, 2006 12:41 AM

Quote:

encapsulation, the word sucks. To make a long tip short stick to the Windows API or Microsoft MFC. It's a pain in the ass to encapsulate the Windows API. I'm taking this from experience.
I'm using windowsx.h which does provide data hiding. It makes things more readable and makes things a bit simpiler. Atleast as far as message queues go. It qualifies as API because it ships with the sdk (it basically a bunch of macros...) Seems like a simple soultion to hide spegetti code without use of objects. Objects might be able to make the code more reuseable. As well as cut down on size (and make the code self retaining) I was thinking about going in this direction but can't think of an effective way to do it...

Quote:

When I saw the plaid jacket and white shoes, I left. One needs to develop discernment. Who wants to traipse around the world yelling, "Hey, Bob", "Hey, Bob" when unthinking echoes are so cheap.
Quote:

Encapsulation is great. I take my vitamins by swallowing one gelatin thangy instead of trying to pick up all those tiny little flecks of this and that. I work on my carburetor by removing one assembly from one place instead of having to take part from my hood ornament, part from my trunk, and part from my turn signal. If someone represents sticking a sow's ear up a hog's ass and coming out with a silk purse as a fait accompli, well, that's just a bad job and a typical huckster's approach. Don't mistake the two.

Okay... That's one way of saying encapsulation is very useful... 0.o :confused:


All times are GMT -5. The time now is 12:23 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC