【目的】
多くの種類のコントロールを使用して動作を連携させる。

【プログラム概要】
いろいろなプログレスバーを表示する。

【コントロール】
・実行ボタン(buttonRun)
・プログレスバー値テキストボックス(textBoxValue)
・プログレスバー(progressBar)

[プログレスバー設定グループボックス]
・プログレスバースタイル変更ラジオボタン(radioButtonBlocks)
・プログレスバースタイル変更ラジオボタン(radioButtonContinuous)
・プログレスバースタイル変更ラジオボタン(radioButtonMarquee)
・プログレスバースタイル文字列(textBoxStyle)

[速度設定グループボックス]
・プログレスバー速度設定トラックバー(trackBarSpeed)
・プログレスバー速度設定数値アップダウン(numericUpDownSpeed)
・プログレスバー速度リセットボタン(buttonSpeedReset)

【画面例】
[メインフォーム]



【実行例】
[メインフォーム]
プログレスバースタイルを「Continuous」とし、プログレスバー速度を「8」とした場合


#include <windows.h>private: System::Void buttonRun_Click(System::Object^ sender, System::EventArgs^ e) { this->buttonRun->Enabled = false; // プログレスバースタイルの設定 if( this->radioButtonBlocks->Checked == true ) { this->progressBar->Style = ProgressBarStyle::Blocks; } else if( this->radioButtonContinuous->Checked == true ) { this->progressBar->Style = ProgressBarStyle::Continuous; } else { this->progressBar->Style = ProgressBarStyle::Marquee; } for( int i = this->progressBar->Minimum; i < this->progressBar->Maximum; i ++ ) { // プログレスバーの表示更新 this->progressBar->Value = i; // プログレスバー値テキストボックスの更新 this->textBoxValue->Text = ( i + 1 ).ToString(); // 画面再描画 Refresh(); // 処理一時停止(ミリ秒) Sleep( ( this->trackBarSpeed->Maximum - this->trackBarSpeed->Value + 1 ) * 10 ); } this->progressBar->Value = this->progressBar->Minimum; this->progressBar->Style = ProgressBarStyle::Blocks; this->buttonRun->Enabled = true;}private: System::Void radioButtonBlocks_CheckedChanged(System::Object^ sender, System::EventArgs^ e) { this->textBoxStyle->Text = ProgressBarStyle::Blocks.ToString();}private: System::Void radioButtonContinuous_CheckedChanged(System::Object^ sender, System::EventArgs^ e) { this->textBoxStyle->Text = ProgressBarStyle::Continuous.ToString();}private: System::Void radioButtonMarquee_CheckedChanged(System::Object^ sender, System::EventArgs^ e) { this->textBoxStyle->Text = ProgressBarStyle::Marquee.ToString();}private: System::Void trackBarSpeed_Scroll(System::Object^ sender, System::EventArgs^ e) { this->numericUpDownSpeed->Value = this->trackBarSpeed->Value;}private: System::Void numericUpDownSpeed_ValueChanged(System::Object^ sender, System::EventArgs^ e) { this->trackBarSpeed->Value = (int)this->numericUpDownSpeed->Value;}private: System::Void buttonSpeedReset_Click(System::Object^ sender, System::EventArgs^ e) { this->numericUpDownSpeed->Value = 5; this->trackBarSpeed->Value = 5;}