0

そこで、カウントダウンが終わってから写真を撮るアプリを開発しています。私はWindows7でwin32タイマーを使用しましたが、WindowsMetroでそれを適用する方法がわかりません。設定された時間が経過した後にイベントをトリガーする方法に関するヘルプまたはC++のサンプルコードが必要です。よろしくお願いします

4

2 に答える 2

1

C ++では、DispatcherTimerを宣言し、それに1つのイベントハンドラーを登録します。

DispatcherTimerクラス-http://msdn.microsoft.com/library/windows/apps/windows.ui.xaml.dispatchertimer

http://msdn.microsoft.com/en-us/library/system.windows.threading.dispatchertimer.aspx

サンプルコード:

using namespace Windows::UI::Xaml;
using namespace Windows::Foundation;


void Application1::MainPage::Button_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
{
    DispatcherTimer^ timer = ref new DispatcherTimer;
    timer->Tick += ref new Windows::UI::Xaml::EventHandler(this, &Application1::MainPage::DispatcherTimer_Tick);
    TimeSpan t;
    t.Duration=1000;
    timer->Interval = t;
    timer->Start();
}

void Application1::MainPage::DispatcherTimer_Tick(Platform::Object^ sender, Platform::Object^ e)
{
   // Put TO DO stuff here...
}
于 2012-08-22T04:41:30.773 に答える
0

Windows::UI::Xaml::DispatcherTimer

ドキュメントには、その使用例が含まれています。例は C# ですが、C++/CX に変換するのは簡単です。

于 2012-08-22T01:40:18.653 に答える