2013-02-03 47 views
0

我正在为名为MusicBee的musicplayer编写一个插件。 该插件适用于Logitech G键盘LCD。 现在我将每30ms看一下按钮活动,以便在按下按钮时它的速度非常快。 我将使用windows.h的setTimer函数,但我无法让它在我的dll文件中工作。 有人可以帮我解决这个小问题吗?SetTimer函数在一个dll文件中

我的代码是(的TimerProc功能是静态函数):

Logitech * Logitech::LogitechObject; 

Logitech::Logitech(): stopthread(false), firstTime(true), position(0), duration(0) 
{ 
    LogitechObject = this; 

    SetTimer(NULL, 1, 30, &Logitech::TimerProc); 
} 

Logitech::~Logitech() 
{ 
    stopthread = true; 
    this->state = StatePlay::Undefined; 
    timerThread.detach(); 
} 

VOID CALLBACK Logitech::TimerProc(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime) 
{ 
    LogitechObject->time = 0; 
    LogitechObject->m_lcd.SetProgressBarPosition(LogitechObject->progressbar, static_cast<FLOAT>(100)); 
    LogitechObject->m_lcd.Update(); 

    SetTimer(NULL, 1, 30, &Logitech::TimerProc); 
} 

回答

0

为了SetTimer的工作应用程序应运行 “的消息泵” 环路(GetMessage()/DispatchMessage())。没有它WM_TIMER消息将不会被传递,所以你的TimerProc将不会被调用。

改为使用CreateTimerQueueTimer()

+0

现在我将我的settimer更改为CreateTimerQueueTimer(NULL,NULL,&Logitech :: TimerProc,this,0,1250,WT_EXECUTEDEFAULT);现在每次启动它都会崩溃。它会是什么? –

相关问题