Intercept a WM_ message into a class
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: Intercept a WM_ message into a class

Hybrid View

  1. #1
    Join Date
    Aug 2009
    Posts
    23

    Intercept a WM_ message into a class

    I was wondering how to intercept a WM_ specific message into a C++ class, I need to use the RegisterDeviceNotification function to register a specific WM_ message (I need a window here right?) and then intercept it and call the appropriate function

    The C++ class should be included in any project, from a console one to a win32 to a mfc one. My idea is to create the skeleton of a win32 window and then use the WndProc for that window, is this stupid?

    Is there any (surely) better solution?

  2. #2
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    801

    Re: Intercept a WM_ message into a class

    I'm not sure I understand your point. You would normally use RegisterDeviceNotification() API in a service application to receive device notifications only. (I believe you can use it with a simple windowed-app as well, in which case all notifications will be sent via the WM_DEVICECHANGE message to its main window.)

    What kinds of messages do you need to intercept?

  3. #3
    Join Date
    Aug 2009
    Posts
    23

    Re: Intercept a WM_ message into a class

    Thank you for your interest.

    I need to intercept WM_DEVICECHANGE in my C++ class. The purpose of this class was to let everyone use a HID device more easily (a wrapper for the HID apis)

    So I am asking myself: why a device change event should be monitored via windows? Why do I have to use a win32 window (or a mfc window) to intercept the device change message? Isn't it stupid? A console application won't be able to use my HID class and communicate with a device without having a window associated, right? That's absolutely stupid, there must be something I don't really know in-depth

  4. #4
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    801

    Re: Intercept a WM_ message into a class

    That's why I told you that you need to use a service application for that. To be honest with you the primary application of the RegisterDeviceNotification() API is for services, the window message is provided on the side.

  5. #5
    Join Date
    Aug 2009
    Posts
    23

    Re: Intercept a WM_ message into a class

    Okay, solution is on the way. I'll start working asap and if I have more problems I'll let you know

    Thanks

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center