Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save uekkie/293cdb45e49b52089e58 to your computer and use it in GitHub Desktop.
Save uekkie/293cdb45e49b52089e58 to your computer and use it in GitHub Desktop.
一定時間がたったらメソッド実行。SetTimer/KillTimer内包のDelayFunkJr ref: http://qiita.com/hirocueki/items/55573d2774721d665bca
DelayFunkJr::spinning_toe_hold(1000, [](){
::MessageBox( 0, _T("いきてるってなーんだろ"), MB_OK);
});
#include <functional>
typedef std::function<void()> Func;
class DelayFunkJr
{
public:
static void spinning_toe_hold(UINT Elapse, Func func)
{
Funk_ = func;
timer_id_= ::SetTimer( NULL, NULL, Elapse, DelayFunkJr::hey_Terry );
}
private:
static void CALLBACK hey_Terry(HWND hwnd,UINT uMsg, UINT_PTR idEvent, DWORD dwTime )
{
::KillTimer( NULL, timer_id_ );
if ( Funk_ ){
Funk_();
}
reset();
}
static void reset()
{
Funk_ = nullptr;
timer_id_ = 0;
}
static Func Funk_;
static UINT_PTR timer_id_;
};
Func DelayFunkJr::Funk_ = nullptr;
UINT_PTR DelayFunkJr::timer_id_ = 0;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment