Skip to main content
gamedev.net
🔒 Locked

WndProc

Started by biscuitz 7 replies 1.4k views
Original Post
biscuitz
biscuitz
Is it possible to remove WndProc from the program? I don't want/need it. I put the message switch right in the message loop. I've tried removing WndProc from the program, but (obviously) the program doesn't funcion properly (shuts down after startup). ATM case WM_DESTROY is in WndProc, tried moving it around but then the window wouldnt shut down. Any ideas on how to remove WndProc? :) The reason I want to remove it from the program is because I find it annoying jumping back and forth between main.cpp and wndproc.cpp and it'd be nice if everything could be put inside WinMain(), so that it "looks" like a Linear program but it's still using Window's state machine.
Shiny
Shiny
Whether you want a Wndproc or not, it is an essential fixture of Win32 GUI programming (well, if you have to use Win32 API anyway...). There are a few suggestions I could offer, but I think you should read on the MSDN about WndProc first...then you may see why getting rid of it completely isn't really feasible :)

~Shiny
------------'C makes it easy to shoot yourself in the foot. C++ makes it harder, but when you do, it blows away your whole leg.' -Bjarne Stroustrup
Evil Steve
Evil Steve
As Shiny said, if you have a window, you need a wndproc. There's a way around it (sort of); you can pass DefWindowProc as the lpfnWndProc member of your WNDCLASS, but then you'll be severely limited in what your app can do (E.g. painting the window, responding to any events, preventing default behaviour, etc).
AbandonedAccount
AbandonedAccount
You can put WndProc in main.cpp to prevent jumping back and forth between files. You can also just split your IDE to show two files at once.

Others have already covered why removing WndProc is rarely a good idea.
tendifo
tendifo
Plus, why have all your code in the one main() function? It'll be easier to read and manage if it has its own function.
biscuitz
biscuitz
I've read up a lot on MSDN. I saved a bunch of RTF files of it on my HD ^_^ (not the whole MSDN library, but still I have plenty of MSDN on my HD)

Hmm :) Ye i'll have to keep WndProc in, so that the window works correctly and so that I can still use it if I have to.

Right now I have an if else switch, which handles WM_DESTROY else calls DefWindowProc(). So far I've found that I can't handle the WM_CONTEXTMENU message inside the message loop >.< It just can't be processed unless it's inside WndProc. So I just switched to WM_RBUTTONCLICK and works fine. [cool]

@ tendifo: I want it to look like a linear program. I want to be able to see what the message loop is doing right there, rather than in WndProc. Also I don't stick *everything* inside main() function, only small stuff and modules. If it's small enough I'll put it straight in the msg loop. If it's kinda long then I'll create a function and put it in a separate file.

Hopefully I won't be too limited in msgs that can be processed in the msg loop. A good thing is I have WndProc as backup. :)

EDIT
=D I think programming in the message loop will be more powerful than programming in WndProc alone. In the message loop I can grab the time and the position of the cursor no matter what message I'm handling :D

How can I use member "time" of the MSG structure for making a game have independent frame rate? ^_^ (I'm thinkin devide it by some number or something but I don't exactly know what; grr I couldn't find any info in MSDN )
LessBread
LessBread
Quote:
Original post by biscuitz
I've read up a lot on MSDN. I saved a bunch of RTF files of it on my HD ^_^ (not the whole MSDN library, but still I have plenty of MSDN on my HD)


Look into ordering yourself a copy of the Platform SDK. Looks like Microsoft has renamed their SDK, Windows® Server 2003 R2 Platform SDK Full Download. Poke around there for information about having them mail it to you on disk.



"I thought what I'd do was, I'd pretend I was one of those deaf-mutes." - the Laughing Man
dmail
dmail
Quote:
Original post by biscuitz
I've read up a lot on MSDN. I saved a bunch of RTF files of it on my HD ^_^ (not the whole MSDN library, but still I have plenty of MSDN on my HD)
...

MSDN is now free(english link)

biscuitz
biscuitz
:( No money and 400 MB - 1000 MB is way too big download.

[Edited by - biscuitz on August 26, 2006 4:03:09 PM]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.