Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding an Event Handler to a Newly Created Window using C++

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.

like image 323
Jim Fell Avatar asked Dec 01 '25 17:12

Jim Fell


1 Answers

You can do it by setting the window procedure with SetWindowLongPtr and the GWL_WNDPROC flag.

SetWindowLongPtr(_hWnd, GWL_WNDPROC, myWndProc);

Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!