掲示板システム
ホーム
アクセス解析
カテゴリ
ログアウト
settimer (ID:62337)
名前
ホームページ(ブログ、Twitterなど)のURL (省略可)
本文
TimerProcを使う方法(あっている自身はない) using namespace System::Runtime::InteropServices; private: UINT_PTR nTimerID; GCHandle gch; delegate VOID TimerProcDelegate( HWND, UINT, UINT_PTR, DWORD ); static VOID TimerProc( HWND hwnd, UINT uMsg, UINT_PTR uIDEvent, DWORD dwTime ) { ::KillTimer( hwnd, uIDEvent ); MessageBox::Show( L"TEST" ); } System::Void Form1_Load( System::Object^ sender, System::EventArgs^ e ) { TimerProcDelegate^ timerProcDelegate = gcnew TimerProcDelegate( Form1::TimerProc ); this->gch = GCHandle::Alloc( timerProcDelegate ); IntPtr deletegatePointer = Marshal::GetFunctionPointerForDelegate( timerProcDelegate ); TIMERPROC timerProc = static_cast< TIMERPROC >( deletegatePointer.ToPointer() ); HWND hWnd = static_cast< HWND >( this->Handle.ToPointer() ); this->nTimerID = 1; //GC::Collect(); this->nTimerID = ::SetTimer( hWnd, this->nTimerID, 5000, timerProc ); if ( this->nTimerID == 0 ) { this->gch.Free(); MessageBox::Show( L"タイマーのセットに失敗しました。" ); } } System::Void Form1_FormClosed( System::Object^ sender, System::Windows::Forms::FormClosedEventArgs^ e ) { if ( this->gch.IsAllocated ) { this->gch.Free(); } } 参考 http://msdn2.microsoft.com/ja-jp/library/367eeye0.aspx
←解決時は質問者本人がここをチェックしてください。
更新する
戻る
掲示板システム
Copyright 2021 Takeshi Okamoto All Rights Reserved.