How to register a form for a WM_DEVICECHANGE message in Windows Mobile
I am using C # .NET 3.5 Compact Framework to write some code .. please someone tell me how to register a form for WM_DEVICECHANGE
and how to handle this message in WindowProc
..
if i do, i get a hint of changing the hardware of the device. I am not getting how to write, please advise.
thank
source to share
The key is to create a class that derives from NativeWindow, give this handle of your form an AssignHandle call and override the WndProc function (allowing you to do what you want with WM_DEVICECHANGE).
See the example on this MSDN page for details: Overriding the NativeWindow.WndProc Method
[EDIT] Not really sure if the NativeWindow class is still available in a lightweight program. If not, Alex Yakhnin has a class and example application on how to catch messages available here . Hope this helps.
source to share
Actually WM_DEVICECHANGE is unlikely to be what you want. You probably want to connect to the Windows CE device notification queue by calling RequestDeviceNotifications and passing it a handle to the queue created with CreateMsgQueue .
If you don't like writing all this P / Invoke code as usual, Smart Device Framework has already implemented it in a more logical object model.
source to share