Chinaunix首页 | 论坛 | 博客
  • 博客访问: 967968
  • 博文数量: 108
  • 博客积分: 3243
  • 博客等级: 中校
  • 技术积分: 964
  • 用 户 组: 普通用户
  • 注册时间: 2008-06-15 22:09
文章分类

全部博文(108)

文章存档

2020年(2)

2019年(1)

2018年(2)

2017年(9)

2016年(20)

2015年(1)

2013年(1)

2012年(12)

2011年(28)

2010年(27)

2009年(4)

2008年(1)

分类: 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

}

 

 只在主窗口中实现以上代码时才可以执行.

阅读(2335) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~