Page 1 of 1

Detecing a Windows Event DBT_DEVICEARRIVAL

Posted: Fri Sep 10, 2004 4:19 pm
by larry
I need to detect an actual MS windows event specifically

DBT_DEVICEARRIVAL

when a USB device is plugged in. windows boradcasts this to all top level windows.

how do I detect these using wxWidgets event handlers?

Thanks

larry

Re: Detecing a Windows Event DBT_DEVICEARRIVAL

Posted: Fri Sep 10, 2004 4:27 pm
by Ryan Norton
larry wrote:I need to detect an actual MS windows event specifically

DBT_DEVICEARRIVAL

when a USB device is plugged in. windows boradcasts this to all top level windows.

how do I detect these using wxWidgets event handlers?

Thanks

larry
You need to override MSWWindowProc

In the class declaration:
[syntax="c"]
virtual WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
[/syntax]

In the implementation:
[syntax="c"]
WXLRESULT wxMediaWindow::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
{
if (nMsg == DBT_DEVICEARRIVAL)
{
//
//TODO: PUT STUFF HERE
//
return wxWindow::MSWDefWindowProc(nMsg, wParam, lParam);
}
return wxWindow::MSWWindowProc(nMsg, wParam, lParam);
}
[/syntax]

Posted: Sat Sep 11, 2004 2:11 am
by larry
do you mean in this function

long wxWindowMSW::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
{


}

in src/msw/window.cpp

so I have to modify the wx source?

I dont see how the call will get to my wx event handler?

Posted: Sat Sep 11, 2004 2:19 am
by Ryan Norton
larry wrote:do you mean in this function

long wxWindowMSW::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
{


}

in src/msw/window.cpp

so I have to modify the wx source?

I dont see how the call will get to my wx event handler?
No - it's a virtual function and you override it in your class - the call to wxWindow::MSWWindowProc calls the wx event handler.

Posted: Sat Sep 11, 2004 6:10 pm
by larry
Duh i knew that