0

I'm writing a plugin for the musicplayer named MusicBee. The plugin is for the Logitech G keyboards LCD. Now I will look at buttons activity every 30ms so everyting is fast when pressing on it. I will use the setTimer function of windows.h but I can't get it to work in my dll file. Can someone help me with this little problem??

The code I have is (TimerProc function is a static function):

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);
}
4

1 回答 1

0

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

改为使用CreateTimerQueueTimer()

于 2013-02-03T17:11:53.427 回答