WindowProc

wc.lpfnWndProc = WindowProc;

So I thought that WindowProc was a function and that it needed to be called like WindowProc(); with some variables inside. Am I missing something here is WindowProc also a variable someplace? What is going on? Attached is the rest of the code

int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE, PWSTR pCmdLine, int nCmdShow)
{
// Register the window class.
const wchar_t CLASS_NAME[] = L"Sample Window Class";

WNDCLASS wc = { };

wc.lpfnWndProc = WindowProc;
wc.hInstance = hInstance;
wc.lpszClassName = CLASS_NAME;

RegisterClass(&wc);

// Create the window.
WindowProc isn't being called here, just its address is taken.
You should look up function pointers.
What is going on?


Yes, you are. It is implicit call but from an user point of view it is explicit one.
WndProc is said to be The Call Back executed on each hardware move including
the moment of creation excluding the file system and a like.
Make sure that WINAPI wWinMain substitute right calling convention.
Usually it is stdcall. Depends.
When you use the name of of a function (without parenthesis), a pointer to that function is return..

[read more]
http://cplusplus.com/doc/tutorial/pointers/
Topic archived. No new replies allowed.