How do I add an event-handler to a newly created window using C++?
_hWnd = CreateWindow( NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL );
It is a dummy window that is intended to do nothing but wait for the WM_DEVICECHANGE event and is to be registered using RegisterDeviceNotification. How do I attach the event-handler to this window? I am using Visual Studio 2008. Thanks.
You can do it by setting the window procedure with SetWindowLongPtr and the GWL_WNDPROC flag.
SetWindowLongPtr(_hWnd, GWL_WNDPROC, myWndProc);
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