当前位置:首页
开发技术指南» 文章正文
    引言:
 

 

    摘要: 说明:散分给前十名兄弟!!!!!!!! 满十人后即刻结贴!!! ......
    摘要: 我在网上找了好几天,就是没有一个地方能下的。所以就跑到这里来求救。急需!!(现在没时间去买d版) ......


SetTimer问题

STDMETHODIMP   CFlash::Play(BSTR   bstrFile,   long   hInstance,   long   hWnd)  
  {  
  //   TODO:   Add   your   implementation   code   here  
  try  
  {  
  m_hWnd=(HWND)hWnd;  
  _bstr_t   file(bstrFile);  
  m_hWnd=::MCIWndCreate((HWND)hWnd,(HINSTANCE)hInstance,WS_POPUP|WS_VISIBLE|MCIWNDF_NOPLAYBAR|MCIWNDF_NOMENU,(char*)file);  
  RECT   rect;  
  ::GetWindowRect(m_hWnd,&rect);  
  int   sx,sy;  
  sx=(::GetSystemMetrics(SM_CXSCREEN)-rect.right+rect.left)/2;      
  sy=(::GetSystemMetrics(SM_CYSCREEN)   -rect.bottom+rect.top)/2;    
  ::SetWindowPos(m_hWnd,HWND_TOPMOST,sx,sy,0,0,SWP_SHOWWINDOW|SWP_NOSIZE);    
  g_nLength=MCIWndGetLength(m_hWnd);    
  MCIWndPlay(m_hWnd);    
          SetTimer(m_hWnd,1,50,TimerProc);  
   
  // m_hWnd=::M  
  }  
  catch   (...)    
  {  
  AtlTrace("error:%ul",::GetLastError());  
  }  
   
  return   S_OK;  
  }  
   
   
  void   CALLBACK     CFlash::TimerProc(HWND   hwnd,   //   handle   of   window   for   timer   messages      
  UINT   uMsg,   //   WM_TIMER   message  
  UINT   idEvent,   //   timer   identifier      
  DWORD   dwTime   //   current   system   time  
  )  
  {  
  long   nLength;    
  BOOL   bEscape=::GetKeyState(VK_ESCAPE)&0x0100;  
  nLength=MCIWndGetPosition(hwnd);    
  //视频放完,或点击ESC键,关闭视频窗口  
  if((nLength>=g_nLength)||(bEscape))  
  {      
  KillTimer(hwnd,idEvent);    
  MCIWndEnd(hwnd);  
  MCIWndClose(hwnd);    
  MCIWndDestroy(hwnd);      
  }  
   
   
  }  
   
   
  出现错误:error   C2664:   SetTimer   :   cannot   convert   parameter   4   from   void   (struct   HWND__   *,unsigned   int,unsigned   int,unsigned   long)   to   void   (__stdcall   *)(struct   HWND__   *,unsigned   int,unsigned   int,unsigned   long)  
                  None   of   the   functions   with   this   name   in   scope   match   the   target   type  
   
   
  请问各位怎么修改?

NO.1   作者: jemmylau

回调函数必须为静态函数或者全局函数  
   
  这里放在类中,就只能用静态成员函数了,你的是吗?

NO.2   作者: guoxiny

如果是类成员函数,那么这个回调函数必须是静态的;一般都把回调函数定义为全局的。类的成员函数是根据类对象的偏移类确定其地址的,你把你的回调函数定义类成员,这样是无法确定函数地址的。

NO.3   作者: zhoujinhua

SetTimer(hwnd,ID_TIME,100,(TIMERPROC)TimerProc);   应该这样设定  
  VOID   CALLBACK   TimerProc(HWND   hwnd,UINT   uMsg,UINT   idEvent,DWORD   dwTime)  
   
 

NO.4   作者: yg_xh

你的TimerProc函数没有使用CFlash的非静态成员,可以把TimerProc函数申明为静态函数就可以了

NO.5   作者: lichungen

up  
  回调函数一定要是静态或全局的


    摘要: 我现在是想将比如有一个字符串“22:10:45”转换成时间格式的该怎么写啊? ......
» 本期热门文章:

©2000-2007 All Rights Reserved. 最佳浏览:1024X768 MSIE