hWnd
Type: HWND
A handle to the window whose messages are to be retrieved. The window must belong to the current thread.
If hWnd is NULL, GetMessage retrieves messages for any window that belongs to the current thread, and any messages on the current thread's message queue whose hwnd value is NULL (see the MSG structure). Therefore if hWnd is NULL, both window messages and thread messages are processed.
What is the diff between window and thread...? thanks
Are you looking for a formal definition? See Wikipedia: http://en.wikipedia.org/wiki/Thread_(computing) . That's a thread. As you can see, a thread has no relation to a window by itself. In Windows programming there is this concept of a window, which is a structure that defines a visible or invisible region of a workspace that is capable of receiving messages via a message queue provided by the operating system. In this context you find relationship between a window and a thread: A thread that creates a window using CreateWindow or CreateWindowEx() is said to be the owner of that window. This is a useful concept to programmers. It helps to synchronize.