分类: C/C++
2011-06-10 11:39:55
xxx.h
protected:
bool winEvent(MSG *msg,long * result);
xxx.cpp
bool CBlurayTranscoderDlg::winEvent(MSG *msg,long * result)
{
int msgType = msg->message;
if(msgType == WM_DEVICECHANGE)
{
qDebug() << "winEvent in MgFrame : WM_DEVICECHANGE" ;
PDEV_BROADCAST_HDR lpdb = (PDEV_BROADCAST_HDR)msg->lParam;
switch(msg->wParam)
{
case DBT_DEVICEARRIVAL:
if (lpdb -> dbch_devicetype == DBT_DEVTYP_VOLUME)
{
PDEV_BROADCAST_VOLUME lpdbv = (PDEV_BROADCAST_VOLUME)lpdb;
if (lpdbv -> dbcv_flags & DBTF_MEDIA)
{
/*此处可以做你想做的事*/
qDebug() << "CD_Arrived ";
}
}
break;
case DBT_DEVICEREMOVECOMPLETE:
if (lpdb -> dbch_devicetype == DBT_DEVTYP_VOLUME)
{
PDEV_BROADCAST_VOLUME lpdbv = (PDEV_BROADCAST_VOLUME)lpdb;
if (lpdbv -> dbcv_flags & DBTF_MEDIA)
{
// 弹出光驱,此处可以做你想做的事
qDebug() << "CD_Removed";
}
}
break;
} // skip the rest
} // end of if msgType
return false; // let qt handle the rest
}
只在主窗口中实现以上代码时才可以执行.