This is a game, you need to have time to press the button while it is active, but through it disappears when another is active (for the summer practice at the university, an additional task). Guys, well, the question is: is there any process in the form that is being requested all the time, not the same as when loading, when it runs through it once and everything, and so that it is updated all the time? Well, in general, I initially did a start in the button, but then Iβm not sure that other buttons can be pressed during this, and if you can check how the button is pressed while the game is playing (a minute is given to it). And how to find out that the timer has finished. 
#pragma once #include "ctime" #include "iostream" using namespace System; using namespace System::ComponentModel; using namespace System::Collections; using namespace System::Windows::Forms; using namespace System::Data; using namespace System::Drawing; namespace ΠΠ΅ΡΠ½ΡΡΠΏΡΠ°ΠΊΡΠΈΠΊΠ° { /// <summary> /// Π‘Π²ΠΎΠ΄ΠΊΠ° Π΄Π»Ρ Form_Game /// /// ΠΠ½ΠΈΠΌΠ°Π½ΠΈΠ΅! ΠΡΠΈ ΠΈΠ·ΠΌΠ΅Π½Π΅Π½ΠΈΠΈ ΠΈΠΌΠ΅Π½ΠΈ ΡΡΠΎΠ³ΠΎ ΠΊΠ»Π°ΡΡΠ° Π½Π΅ΠΎΠ±Ρ
ΠΎΠ΄ΠΈΠΌΠΎ ΡΠ°ΠΊΠΆΠ΅ ΠΈΠ·ΠΌΠ΅Π½ΠΈΡΡ /// ΡΠ²ΠΎΠΉΡΡΠ²ΠΎ ΠΈΠΌΠ΅Π½ΠΈ ΡΠ°ΠΉΠ»Π° ΡΠ΅ΡΡΡΡΠΎΠ² ("Resource File Name") Π΄Π»Ρ ΡΡΠ΅Π΄ΡΡΠ²Π° ΠΊΠΎΠΌΠΏΠΈΠ»ΡΡΠΈΠΈ ΡΠΏΡΠ°Π²Π»ΡΠ΅ΠΌΠΎΠ³ΠΎ ΡΠ΅ΡΡΡΡΠ°, /// ΡΠ²ΡΠ·Π°Π½Π½ΠΎΠ³ΠΎ ΡΠΎ Π²ΡΠ΅ΠΌΠΈ ΡΠ°ΠΉΠ»Π°ΠΌΠΈ Ρ ΡΠ°ΡΡΠΈΡΠ΅Π½ΠΈΠ΅ΠΌ .resx, ΠΎΡ ΠΊΠΎΡΠΎΡΡΡ
Π·Π°Π²ΠΈΡΠΈΡ Π΄Π°Π½Π½ΡΠΉ ΠΊΠ»Π°ΡΡ. Π ΠΏΡΠΎΡΠΈΠ²Π½ΠΎΠΌ ΡΠ»ΡΡΠ°Π΅, /// ΠΊΠΎΠ½ΡΡΡΡΠΊΡΠΎΡΡ Π½Π΅ ΡΠΌΠΎΠ³ΡΡ ΠΏΡΠ°Π²ΠΈΠ»ΡΠ½ΠΎ ΡΠ°Π±ΠΎΡΠ°ΡΡ Ρ Π»ΠΎΠΊΠ°Π»ΠΈΠ·ΠΎΠ²Π°Π½Π½ΡΠΌΠΈ /// ΡΠ΅ΡΡΡΡΠ°ΠΌΠΈ, ΡΠΎΠΏΠΎΡΡΠ°Π²Π»Π΅Π½Π½ΡΠΌΠΈ Π΄Π°Π½Π½ΠΎΠΉ ΡΠΎΡΠΌΠ΅. /// </summary> public ref class Form_Game : public System::Windows::Forms::Form { public: Form_Game(void) { InitializeComponent(); // //TODO: Π΄ΠΎΠ±Π°Π²ΡΡΠ΅ ΠΊΠΎΠ΄ ΠΊΠΎΠ½ΡΡΡΡΠΊΡΠΎΡΠ° // } protected: /// <summary> /// ΠΡΠ²ΠΎΠ±ΠΎΠ΄ΠΈΡΡ Π²ΡΠ΅ ΠΈΡΠΏΠΎΠ»ΡΠ·ΡΠ΅ΠΌΡΠ΅ ΡΠ΅ΡΡΡΡΡ. /// </summary> ~Form_Game() { if (components) { delete components; } } private: System::Windows::Forms::Button^ button1; protected: private: System::Windows::Forms::Button^ button2; private: System::Windows::Forms::Button^ button3; private: System::Windows::Forms::Button^ button4; private: System::Windows::Forms::Button^ button5; private: System::Windows::Forms::Button^ button6; private: System::Windows::Forms::Button^ button7; private: System::Windows::Forms::Button^ button8; private: System::Windows::Forms::Button^ button9; private: System::Windows::Forms::Button^ button10; private: System::Windows::Forms::Button^ button11; private: System::Windows::Forms::Button^ button12; private: System::Windows::Forms::Button^ button13; private: System::Windows::Forms::Button^ button14; private: System::Windows::Forms::Button^ button15; private: System::Windows::Forms::Button^ button16; private: System::Windows::Forms::Button^ button_start; private: System::Windows::Forms::Button^ button_out; private: System::Windows::Forms::Timer^ timer_game; private: System::ComponentModel::IContainer^ components; private: /// <summary> /// Π’ΡΠ΅Π±ΡΠ΅ΡΡΡ ΠΏΠ΅ΡΠ΅ΠΌΠ΅Π½Π½Π°Ρ ΠΊΠΎΠ½ΡΡΡΡΠΊΡΠΎΡΠ°. /// </summary> #pragma region Windows Form Designer generated code /// <summary> /// ΠΠ±ΡΠ·Π°ΡΠ΅Π»ΡΠ½ΡΠΉ ΠΌΠ΅ΡΠΎΠ΄ Π΄Π»Ρ ΠΏΠΎΠ΄Π΄Π΅ΡΠΆΠΊΠΈ ΠΊΠΎΠ½ΡΡΡΡΠΊΡΠΎΡΠ° - Π½Π΅ ΠΈΠ·ΠΌΠ΅Π½ΡΠΉΡΠ΅ /// ΡΠΎΠ΄Π΅ΡΠΆΠΈΠΌΠΎΠ΅ Π΄Π°Π½Π½ΠΎΠ³ΠΎ ΠΌΠ΅ΡΠΎΠ΄Π° ΠΏΡΠΈ ΠΏΠΎΠΌΠΎΡΠΈ ΡΠ΅Π΄Π°ΠΊΡΠΎΡΠ° ΠΊΠΎΠ΄Π°. /// </summary> void InitializeComponent(void) { this->components = (gcnew System::ComponentModel::Container()); this->button1 = (gcnew System::Windows::Forms::Button()); this->button2 = (gcnew System::Windows::Forms::Button()); this->button3 = (gcnew System::Windows::Forms::Button()); this->button4 = (gcnew System::Windows::Forms::Button()); this->button5 = (gcnew System::Windows::Forms::Button()); this->button6 = (gcnew System::Windows::Forms::Button()); this->button7 = (gcnew System::Windows::Forms::Button()); this->button8 = (gcnew System::Windows::Forms::Button()); this->button9 = (gcnew System::Windows::Forms::Button()); this->button10 = (gcnew System::Windows::Forms::Button()); this->button11 = (gcnew System::Windows::Forms::Button()); this->button12 = (gcnew System::Windows::Forms::Button()); this->button13 = (gcnew System::Windows::Forms::Button()); this->button14 = (gcnew System::Windows::Forms::Button()); this->button15 = (gcnew System::Windows::Forms::Button()); this->button16 = (gcnew System::Windows::Forms::Button()); this->button_start = (gcnew System::Windows::Forms::Button()); this->button_out = (gcnew System::Windows::Forms::Button()); this->timer_game = (gcnew System::Windows::Forms::Timer(this->components)); this->SuspendLayout(); // // button1 // this->button1->Location = System::Drawing::Point(57, 71); this->button1->Name = L"button1"; this->button1->Size = System::Drawing::Size(75, 64); this->button1->TabIndex = 0; this->button1->UseVisualStyleBackColor = true; // // button2 // this->button2->Location = System::Drawing::Point(166, 71); this->button2->Name = L"button2"; this->button2->Size = System::Drawing::Size(75, 64); this->button2->TabIndex = 1; this->button2->UseVisualStyleBackColor = true; // // button3 // this->button3->Location = System::Drawing::Point(276, 71); this->button3->Name = L"button3"; this->button3->Size = System::Drawing::Size(75, 64); this->button3->TabIndex = 2; this->button3->UseVisualStyleBackColor = true; // // button4 // this->button4->Location = System::Drawing::Point(382, 71); this->button4->Name = L"button4"; this->button4->Size = System::Drawing::Size(75, 64); this->button4->TabIndex = 3; this->button4->UseVisualStyleBackColor = true; // // button5 // this->button5->Location = System::Drawing::Point(57, 153); this->button5->Name = L"button5"; this->button5->Size = System::Drawing::Size(75, 64); this->button5->TabIndex = 4; this->button5->UseVisualStyleBackColor = true; // // button6 // this->button6->Location = System::Drawing::Point(166, 153); this->button6->Name = L"button6"; this->button6->Size = System::Drawing::Size(75, 64); this->button6->TabIndex = 5; this->button6->UseVisualStyleBackColor = true; // // button7 // this->button7->Location = System::Drawing::Point(276, 153); this->button7->Name = L"button7"; this->button7->Size = System::Drawing::Size(75, 64); this->button7->TabIndex = 6; this->button7->UseVisualStyleBackColor = true; // // button8 // this->button8->Location = System::Drawing::Point(382, 153); this->button8->Name = L"button8"; this->button8->Size = System::Drawing::Size(75, 64); this->button8->TabIndex = 7; this->button8->UseVisualStyleBackColor = true; // // button9 // this->button9->Location = System::Drawing::Point(57, 243); this->button9->Name = L"button9"; this->button9->Size = System::Drawing::Size(75, 64); this->button9->TabIndex = 8; this->button9->UseVisualStyleBackColor = true; // // button10 // this->button10->Location = System::Drawing::Point(166, 243); this->button10->Name = L"button10"; this->button10->Size = System::Drawing::Size(75, 64); this->button10->TabIndex = 9; this->button10->UseVisualStyleBackColor = true; // // button11 // this->button11->Location = System::Drawing::Point(276, 243); this->button11->Name = L"button11"; this->button11->Size = System::Drawing::Size(75, 64); this->button11->TabIndex = 10; this->button11->UseVisualStyleBackColor = true; // // button12 // this->button12->Location = System::Drawing::Point(382, 243); this->button12->Name = L"button12"; this->button12->Size = System::Drawing::Size(75, 64); this->button12->TabIndex = 11; this->button12->UseVisualStyleBackColor = true; // // button13 // this->button13->Location = System::Drawing::Point(57, 335); this->button13->Name = L"button13"; this->button13->Size = System::Drawing::Size(75, 64); this->button13->TabIndex = 12; this->button13->UseVisualStyleBackColor = true; // // button14 // this->button14->Location = System::Drawing::Point(166, 335); this->button14->Name = L"button14"; this->button14->Size = System::Drawing::Size(75, 64); this->button14->TabIndex = 13; this->button14->UseVisualStyleBackColor = true; // // button15 // this->button15->Location = System::Drawing::Point(276, 335); this->button15->Name = L"button15"; this->button15->Size = System::Drawing::Size(75, 64); this->button15->TabIndex = 14; this->button15->UseVisualStyleBackColor = true; // // button16 // this->button16->Location = System::Drawing::Point(382, 335); this->button16->Name = L"button16"; this->button16->Size = System::Drawing::Size(75, 64); this->button16->TabIndex = 15; this->button16->UseVisualStyleBackColor = true; // // button_start // this->button_start->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 11, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, static_cast<System::Byte>(204))); this->button_start->Location = System::Drawing::Point(-1, -1); this->button_start->Name = L"button_start"; this->button_start->Size = System::Drawing::Size(133, 40); this->button_start->TabIndex = 16; this->button_start->Text = L"Π‘ΡΠ°ΡΡ!"; this->button_start->UseVisualStyleBackColor = true; this->button_start->Click += gcnew System::EventHandler(this, &Form_Game::button_start_Click); // // button_out // this->button_out->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 11, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, static_cast<System::Byte>(204))); this->button_out->Location = System::Drawing::Point(382, -1); this->button_out->Name = L"button_out"; this->button_out->Size = System::Drawing::Size(133, 40); this->button_out->TabIndex = 17; this->button_out->Text = L"ΠΡΡ
ΠΎΠ΄!"; this->button_out->UseVisualStyleBackColor = true; this->button_out->Click += gcnew System::EventHandler(this, &Form_Game::button_out_Click); // // timer_game // this->timer_game->Interval = 60000; // // Form_Game // this->AutoScaleDimensions = System::Drawing::SizeF(6, 13); this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; this->ClientSize = System::Drawing::Size(514, 436); this->Controls->Add(this->button_out); this->Controls->Add(this->button_start); this->Controls->Add(this->button16); this->Controls->Add(this->button15); this->Controls->Add(this->button14); this->Controls->Add(this->button13); this->Controls->Add(this->button12); this->Controls->Add(this->button11); this->Controls->Add(this->button10); this->Controls->Add(this->button9); this->Controls->Add(this->button8); this->Controls->Add(this->button7); this->Controls->Add(this->button6); this->Controls->Add(this->button5); this->Controls->Add(this->button4); this->Controls->Add(this->button3); this->Controls->Add(this->button2); this->Controls->Add(this->button1); this->Name = L"Form_Game"; this->Text = L"Form_Game"; this->Load += gcnew System::EventHandler(this, &Form_Game::Form_Game_Load); this->ResumeLayout(false); } #pragma endregion void BtnFalse() { this->button_out->Enabled = false; this->button_start->Enabled = true; this->button1->Enabled = false; this->button2->Enabled = false; this->button3->Enabled = false; this->button4->Enabled = false; this->button5->Enabled = false; this->button6->Enabled = false; this->button7->Enabled = false; this->button8->Enabled = false; this->button9->Enabled = false; this->button10->Enabled = false; this->button11->Enabled = false; this->button12->Enabled = false; this->button13->Enabled = false; this->button14->Enabled = false; this->button15->Enabled = false; this->button16->Enabled = false; } private: System::Void Form_Game_Load(System::Object^ sender, System::EventArgs^ e) { BtnFalse(); } private: System::Void button_start_Click(System::Object^ sender, System::EventArgs^ e) { this->button_out->Enabled = true; this->button_start->Enabled = false; this->timer_game->Start(); int limit = 60000; while (/*ΠΏΠΎΠΊΠ° Π²ΡΠ΅ΠΌΡ Π² ΡΠ°ΠΉΠΌΠ΅ΡΠ΅ Π½Π΅ Π½ΠΎΠ»Ρ, ΠΊΠ°ΠΊ?*/) { srand(time(0)); int cube = 1 + rand()%16; // Π΄Π»Ρ Π°ΠΊΡΠΈΠ²Π°ΡΠΈΠΈ ΡΠ°Π½Π΄ΠΎΠΌΠ½ΠΎΠΉ ΠΊΠ½ΠΎΠΏΠΊΠΈ if ((this->button_out->Tag) == 1) { //ΠΏΡΡΠ°Π»ΡΡ ΡΠ΄Π΅Π»Π°ΡΡ ΠΏΡΠΎΠ²Π΅ΡΠΊΡ Π½Π°ΠΆΠ°ΡΠΈ ΠΊΠ½ΠΎΠΏΠΊΠΈ this->button_start->Enabled = true; break; } } this->button1->Enabled = true;// ΡΠ΅ΡΠΈΠ» ΠΏΡΠΎΠ²Π΅ΡΠΈΡΡ ΠΏΡΠ°Π²ΠΈΠ»ΡΠ½ΠΎΡΡΡ ΡΠ°Π±ΠΎΡΡ } private: System::Void button_out_Click(System::Object^ sender, System::EventArgs^ e) { this->button_out->Tag = 1; } }; } The copy-and-paste code may be crooked, but everything seems to be clear, the first question :)