I am following this tutorial: theForger's Win32 API Programming Tutorial
In section 4 (message looping) (Understanding the Message Loop), there is the code:
WNDPROC fWndProc = (WNDPROC)GetWindowLong(Msg.hwnd, GWL_WNDPROC);
fWndProc(Msg.hwnd, Msg.message, Msg.wParam, Msg.lParam);
I tried to compile it, but I got this error message:
GWL_WNDPROC undeclared
What can I do to fix it?
In <WinUser.h>
, the following declarations exist:
/*
* Window field offsets for GetWindowLong()
*/
#define GWL_WNDPROC (-4)
...
#ifdef _WIN64
#undef GWL_WNDPROC
#undef GWL_HINSTANCE
#undef GWL_HWNDPARENT
#undef GWL_USERDATA
#endif /* _WIN64 */
#define GWLP_WNDPROC (-4)
In case _WIN64
is defined (your target is 64 bit), the GWL_WNDPROC
is really undefined. You need use GWLP_WNDPROC
instead.
Also with GWLP_WNDPROC
, you need use GetWindowLongPtr
and SetWindowLongPtr
, but not GetWindowLong
and SetWindowLong
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With