Created
July 31, 2015 10:10
-
-
Save uekkie/293cdb45e49b52089e58 to your computer and use it in GitHub Desktop.
一定時間がたったらメソッド実行。SetTimer/KillTimer内包のDelayFunkJr ref: http://qiita.com/hirocueki/items/55573d2774721d665bca
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DelayFunkJr::spinning_toe_hold(1000, [](){ | |
::MessageBox( 0, _T("いきてるってなーんだろ"), MB_OK); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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