Facebook
From Crimson Tern, 3 Years ago, written in C++.
Embed
Download Paste or View Raw
Hits: 146
  1. #pragma once
  2. #include "okno1.h"
  3.  
  4. namespace Project24 {
  5.  
  6.         using namespace System;
  7.         using namespace System::ComponentModel;
  8.         using namespace System::Collections;
  9.         using namespace System::Windows::Forms;
  10.         using namespace System::Data;
  11.         using namespace System::Drawing;
  12.  
  13.         /// <summary>
  14.         /// Summary for MyForm
  15.         /// </summary>
  16.         public ref class MyForm : public System::Windows::Forms::Form
  17.         {
  18.         public:
  19.                 MyForm(void)
  20.                 {
  21.                         InitializeComponent();
  22.                         //
  23.                         //TODO: Add the constructor code here
  24.                         //
  25.                 }
  26.  
  27.         protected:
  28.                 /// <summary>
  29.                 /// Clean up any resources being used.
  30.                 /// </summary>
  31.                 ~MyForm()
  32.                 {
  33.                         if (components)
  34.                         {
  35.                                 delete components;
  36.                         }
  37.                 }
  38.         private: System::Windows::Forms::Button^  button1;
  39.         private: System::Windows::Forms::Button^  button2;
  40.         private: System::Windows::Forms::Label^  label1;
  41.         private: System::Windows::Forms::Timer^  timer1;
  42.         private: System::Windows::Forms::Button^  button3;
  43.         private: System::ComponentModel::IContainer^  components;
  44.         protected:
  45.  
  46.         private:
  47.                 /// <summary>
  48.                 /// Required designer variable.
  49.                 /// </summary>
  50.  
  51.  
  52. #pragma region Windows Form Designer generated code
  53.                 /// <summary>
  54.                 /// Required method for Designer support - do not modify
  55.                 /// the contents of this method with the code editor.
  56.                 /// </summary>
  57.                 void InitializeComponent(void)
  58.                 {
  59.                         this->components = (gcnew System::ComponentModel::Container());
  60.                         this->button1 = (gcnew System::Windows::Forms::Button());
  61.                         this->button2 = (gcnew System::Windows::Forms::Button());
  62.                         this->label1 = (gcnew System::Windows::Forms::Label());
  63.                         this->timer1 = (gcnew System::Windows::Forms::Timer(this->components));
  64.                         this->button3 = (gcnew System::Windows::Forms::Button());
  65.                         this->SuspendLayout();
  66.                         //
  67.                         // button1
  68.                         //
  69.                         this->button1->Location = System::Drawing::Point(86, 103);
  70.                         this->button1->Name = L"button1";
  71.                         this->button1->Size = System::Drawing::Size(75, 23);
  72.                         this->button1->TabIndex = 0;
  73.                         this->button1->Text = L"button1";
  74.                         this->button1->UseVisualStyleBackColor = true;
  75.                         this->button1->Click += gcnew System::EventHandler(this, &MyForm::button1_Click);
  76.                         //
  77.                         // button2
  78.                         //
  79.                         this->button2->Location = System::Drawing::Point(86, 169);
  80.                         this->button2->Name = L"button2";
  81.                         this->button2->Size = System::Drawing::Size(75, 23);
  82.                         this->button2->TabIndex = 1;
  83.                         this->button2->Text = L"button2";
  84.                         this->button2->UseVisualStyleBackColor = true;
  85.                
  86.                         //
  87.                         // label1
  88.                         //
  89.                         this->label1->AutoSize = true;
  90.                         this->label1->Location = System::Drawing::Point(103, 57);
  91.                         this->label1->Name = L"label1";
  92.                         this->label1->Size = System::Drawing::Size(35, 13);
  93.                         this->label1->TabIndex = 2;
  94.                         this->label1->Text = L"label1";
  95.                         //
  96.                         // timer1
  97.                         //
  98.                         this->timer1->Enabled = true;
  99.                         this->timer1->Interval = 1000;
  100.                         this->timer1->Tick += gcnew System::EventHandler(this, &MyForm::timer1_Tick);
  101.                         //
  102.                         // button3
  103.                         //
  104.                         this->button3->Location = System::Drawing::Point(213, 249);
  105.                         this->button3->Name = L"button3";
  106.                         this->button3->Size = System::Drawing::Size(75, 23);
  107.                         this->button3->TabIndex = 3;
  108.                         this->button3->Text = L"button3";
  109.                         this->button3->UseVisualStyleBackColor = true;
  110.                         //
  111.                         // MyForm
  112.                         //
  113.                         this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
  114.                         this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
  115.                         this->ClientSize = System::Drawing::Size(476, 396);
  116.                         this->Controls->Add(this->button3);
  117.                         this->Controls->Add(this->label1);
  118.                         this->Controls->Add(this->button2);
  119.                         this->Controls->Add(this->button1);
  120.                         this->Name = L"MyForm";
  121.                         this->Text = L"MyForm";
  122.                        
  123.                         this->ResumeLayout(false);
  124.                         this->PerformLayout();
  125.  
  126.                 }
  127.                 okno1^okno;
  128.                 int a;
  129.                 int b;
  130.                
  131. #pragma endregion
  132.  
  133.  
  134.         private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
  135.                 okno = gcnew okno1;
  136.                 this->Hide();
  137.                 okno->ShowDialog();
  138.                 this->Show();
  139.                 b = okno->x;
  140.                 timer1->Interval = b;
  141.         }
  142.         //private: System::Void button2_Click(System::Object^  sender, System::EventArgs^  e) {
  143.                
  144.                 //b = okno->x;
  145.                        
  146.                         //label1->Text = a.ToString();
  147.                         //timer1->Interval =b;
  148.        
  149.         //}
  150.        
  151.         private: System::Void timer1_Tick(System::Object^  sender, System::EventArgs^  e) {
  152.                
  153.                
  154.                 a++;
  155.                 label1->Text = a.ToString();
  156.                 button3->Location =Point (rand() % 300, rand() % 200);
  157.  
  158.         }
  159.  
  160. };
  161. }
  162.