Detecing a Windows Event DBT_DEVICEARRIVAL

This forum can be used to talk about general design strategies, new ideas and questions in general related to wxWidgets. If you feel your questions doesn't fit anywhere, put it here.
Post Reply
larry
In need of some credit
In need of some credit
Posts: 4
Joined: Fri Sep 10, 2004 4:15 pm

Detecing a Windows Event DBT_DEVICEARRIVAL

Post 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
User avatar
Ryan Norton
wxWorld Domination!
wxWorld Domination!
Posts: 1319
Joined: Mon Aug 30, 2004 6:01 pm

Re: Detecing a Windows Event DBT_DEVICEARRIVAL

Post 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]
[Mostly retired moderator, still check in to clean up some stuff]
larry
In need of some credit
In need of some credit
Posts: 4
Joined: Fri Sep 10, 2004 4:15 pm

Post 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?
User avatar
Ryan Norton
wxWorld Domination!
wxWorld Domination!
Posts: 1319
Joined: Mon Aug 30, 2004 6:01 pm

Post 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.
[Mostly retired moderator, still check in to clean up some stuff]
larry
In need of some credit
In need of some credit
Posts: 4
Joined: Fri Sep 10, 2004 4:15 pm

Post by larry »

Duh i knew that
Post Reply