Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

VC++ MFC - WM_DEVICECHANGE message handling

344 views
Skip to first unread message

Simon Sadler

unread,
Feb 2, 2001, 9:39:18 AM2/2/01
to
I have a bit of a problem.

I have a simple, dialog based, VC++ app using the MFC, it does nothing except
what the app wizard produced. I want my app to pick up and process the
WM_DEVICECHANGE message which gets sent to top level windows when the os detects
a device change (surprise surprise), e.g. something being plugged in a USB port
etc. However when I go to class wizard to add the message handler, no matter what
class I select the message never appears as one that I can handle!! Obviously I
don't want to go messing with the app wizard generated code .

Any suggestions? Ideally some sample code would great.

Cheers

Simon

David Lowndes

unread,
Feb 2, 2001, 12:36:45 PM2/2/01
to
>I have a simple, dialog based, VC++ app using the MFC, it does nothing except
>what the app wizard produced. I want my app to pick up and process the
>WM_DEVICECHANGE message which gets sent to top level windows when the os detects
>a device change (surprise surprise), e.g. something being plugged in a USB port
>etc. However when I go to class wizard to add the message handler, no matter what
>class I select the message never appears as one that I can handle!

Simon,

Class Wizard only supports the more common messages. It's not
difficult to add a message handler yourself, however searching though
the MFC docs, there is already one you can use.

Add ON_WM_DEVICECHANGE() to your message map, and implement a member
function afx_msg void OnDeviceChange( UINT, DWORD ).

Dave
--
MVP VC++ FAQ: http://www.mvps.org/vcfaq
My address is altered to discourage junk mail.
Please post responses to the newsgroup thread,
there's no need for follow-up email copies.

Sam Hobbs

unread,
Feb 2, 2001, 12:50:25 PM2/2/01
to
The first thing I do in situations such as this is to look in the
documentation, which you have already done. The next step for me is to
search the documentation. I discovered that the WM_DEVICECHANGE message is
sent as a WM_COMMAND message. I also found CWnd::OnDeviceChange, but I sure
do not find any of those in the ClassWizard.

So my next step sometimes is to search the internet. I found the CodeGuru
web site a few years ago by searching the internet for an API function. I
found:

http://codeguru.earthweb.com/multimedia/cd_audio.shtml

Which might help.


"Simon Sadler" <simon....@sema.co.uk> wrote in message
news:0b7701c08d25$ec447670$b1e62ecf@tkmsftngxa04...

0 new messages