Jump to content
  • Advertisement
Sign in to follow this  
Ahmet

windows programming

This topic is 4467 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 am a newbie in game programing and ask you a quesstion about creating a window. Windows use WndProc( HWND hWnd , UINT msg ,WPARAM wParam, LPARAM lParam) function to handle windows' messages which has below structure typedef struct tagMSG { HWND hwnd; UINT message; WPARAM wParam; LPARAM lParam; DWORD time; POINT pt; } MSG; msg structure already has the window handle , wParam and lParam . Why we have to resend the hWnd , wParam and lParam parameters?WndProc can't be satisfied with a single msg parameter?Same thing is valid for DefWindowProc() . thanks for all help :)

Share this post


Link to post
Share on other sites
Advertisement
The WndProc doesn't actually get the MSG variable, it just gets a few members of it. I'd like to know why WnyProc doesn't just get passed the MSG that's getting handled in the message loop, actually...

EDIT: Oh, I think that's what you're saying... never mind then [smile]

Share this post


Link to post
Share on other sites
Quote:
Original post by Ahmet
Why we have to resend the hWnd , wParam and lParam parameters?WndProc can't be satisfied with a single msg parameter?Same thing is valid for DefWindowProc() .
thanks for all help :)



You don't.
You don't send the msg struct to wndproc.
The 'UINT msg' parameter in WndProc is the message, e.g. WM_PAINT.
Look on MSDN if you want more information.

Share this post


Link to post
Share on other sites
WM_PAINT is sent as a UINT, which is just an integer. The message also needs the lParam to be passed to the window proc with it.

Share this post


Link to post
Share on other sites
Rewrite to make things more obvious:

WndProc( HWND hwnd, UINT message ,WPARAM wParam, LPARAM lParam)

Compare to
typedef struct tagMSG {
HWND hwnd;
UINT message;
WPARAM wParam;
LPARAM lParam;
DWORD time;
POINT pt;
} MSG;

Your high level code gets the MSG structure from GetMessage or PeekMessage, and DispatchMessage feeds WndProc with the hwnd, the message and the params.

HTH,

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!