Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jul 7th, 2006, 10:56 AM   #1
Zap
Guest
 
Posts: n/a
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?
  Reply With Quote
Old Jul 7th, 2006, 12:58 PM   #2
Mad_guy
Hobbyist Programmer
 
Mad_guy's Avatar
 
Join Date: Oct 2004
Location: Sandstorm, Techno Club
Posts: 239
Rep Power: 4 Mad_guy is on a distinguished road
Send a message via AIM to Mad_guy Send a message via MSN to Mad_guy
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.
__________________
os: mac os 10.5.4
revision control: git
editor: emacs

site
Mad_guy is offline   Reply With Quote
Old Jul 7th, 2006, 1:36 PM   #3
Zap
Guest
 
Posts: n/a
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.
  Reply With Quote
Old Jul 7th, 2006, 2:11 PM   #4
Prm753
Professional Programmer
 
Prm753's Avatar
 
Join Date: Oct 2005
Location: United States
Posts: 447
Rep Power: 4 Prm753 is on a distinguished road
Send a message via AIM to Prm753 Send a message via MSN to Prm753
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
__________________
The world's first athletic computer geek!
The home of PrProgramsStudios
How not to post a question: <-- Please don't reply
Prm753 is offline   Reply With Quote
Old Jul 7th, 2006, 2:30 PM   #5
Zap
Guest
 
Posts: n/a
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...
  Reply With Quote
Old Jul 7th, 2006, 7:00 PM   #6
frankish
Hobbyist Programmer
 
frankish's Avatar
 
Join Date: Oct 2005
Location: Ohio
Posts: 177
Rep Power: 0 frankish is an unknown quantity at this point
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.
frankish is offline   Reply With Quote
Old Jul 7th, 2006, 8:12 PM   #7
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
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.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Jul 7th, 2006, 8:41 PM   #8
frankish
Hobbyist Programmer
 
frankish's Avatar
 
Join Date: Oct 2005
Location: Ohio
Posts: 177
Rep Power: 0 frankish is an unknown quantity at this point
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?
frankish is offline   Reply With Quote
Old Jul 7th, 2006, 10:23 PM   #9
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
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.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Jul 7th, 2006, 11:41 PM   #10
Zap
Guest
 
Posts: n/a
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
  Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 6:54 PM.

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