Advertisement
Kajoj

Zegarko - Jebać visual studio

Mar 20th, 2017
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 6.81 KB | None | 0 0
  1. #pragma once
  2.  
  3. namespace aaaa {
  4.  
  5.     using namespace System;
  6.     using namespace System::ComponentModel;
  7.     using namespace System::Collections;
  8.     using namespace System::Windows::Forms;
  9.     using namespace System::Data;
  10.     using namespace System::Drawing;
  11.    
  12.     int hours = 0;
  13.     int minutes = 0;
  14.     int seconds = 0;
  15.     /// <summary>
  16.     /// Summary for Form1
  17.     /// </summary>
  18.     public ref class Form1 : public System::Windows::Forms::Form
  19.     {
  20.     public:
  21.         Form1(void)
  22.         {
  23.             InitializeComponent();
  24.             //
  25.             //TODO: Add the constructor code here
  26.             //
  27.         }
  28.  
  29.     protected:
  30.         /// <summary>
  31.         /// Clean up any resources being used.
  32.         /// </summary>
  33.         ~Form1()
  34.         {
  35.             if (components)
  36.             {
  37.                 delete components;
  38.             }
  39.         }
  40.     private: System::Windows::Forms::ProgressBar^  progressBar1;
  41.     protected:
  42.     private: System::Windows::Forms::Label^  HH;
  43.     private: System::Windows::Forms::Label^  label2;
  44.     private: System::Windows::Forms::Label^  MM;
  45.     private: System::Windows::Forms::Label^  label1;
  46.     private: System::Windows::Forms::Label^  SS;
  47.     private: System::Windows::Forms::Timer^  timer1;
  48.     private: System::ComponentModel::IContainer^  components;
  49.  
  50.     private:
  51.         /// <summary>
  52.         /// Required designer variable.
  53.         /// </summary>
  54.  
  55.  
  56. #pragma region Windows Form Designer generated code
  57.         /// <summary>
  58.         /// Required method for Designer support - do not modify
  59.         /// the contents of this method with the code editor.
  60.         /// </summary>
  61.         void InitializeComponent(void)
  62.         {
  63.             this->components = (gcnew System::ComponentModel::Container());
  64.             this->progressBar1 = (gcnew System::Windows::Forms::ProgressBar());
  65.             this->HH = (gcnew System::Windows::Forms::Label());
  66.             this->label2 = (gcnew System::Windows::Forms::Label());
  67.             this->MM = (gcnew System::Windows::Forms::Label());
  68.             this->label1 = (gcnew System::Windows::Forms::Label());
  69.             this->SS = (gcnew System::Windows::Forms::Label());
  70.             this->timer1 = (gcnew System::Windows::Forms::Timer(this->components));
  71.             this->SuspendLayout();
  72.             //
  73.             // progressBar1
  74.             //
  75.             this->progressBar1->Location = System::Drawing::Point(12, 238);
  76.             this->progressBar1->Name = L"progressBar1";
  77.             this->progressBar1->Size = System::Drawing::Size(268, 23);
  78.             this->progressBar1->TabIndex = 0;
  79.             //
  80.             // HH
  81.             //
  82.             this->HH->AutoSize = true;
  83.             this->HH->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 24.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
  84.                 static_cast<System::Byte>(238)));
  85.             this->HH->Location = System::Drawing::Point(67, 118);
  86.             this->HH->Name = L"HH";
  87.             this->HH->Size = System::Drawing::Size(53, 38);
  88.             this->HH->TabIndex = 1;
  89.             this->HH->Text = L"00";
  90.             //
  91.             // label2
  92.             //
  93.             this->label2->AutoSize = true;
  94.             this->label2->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 24.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
  95.                 static_cast<System::Byte>(238)));
  96.             this->label2->Location = System::Drawing::Point(110, 118);
  97.             this->label2->Name = L"label2";
  98.             this->label2->Size = System::Drawing::Size(26, 38);
  99.             this->label2->TabIndex = 2;
  100.             this->label2->Text = L":";
  101.             //
  102.             // MM
  103.             //
  104.             this->MM->AutoSize = true;
  105.             this->MM->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 24.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
  106.                 static_cast<System::Byte>(238)));
  107.             this->MM->Location = System::Drawing::Point(126, 118);
  108.             this->MM->Name = L"MM";
  109.             this->MM->Size = System::Drawing::Size(53, 38);
  110.             this->MM->TabIndex = 3;
  111.             this->MM->Text = L"00";
  112.             this->MM->Click += gcnew System::EventHandler(this, &Form1::MM_Click);
  113.             //
  114.             // label1
  115.             //
  116.             this->label1->AutoSize = true;
  117.             this->label1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 24.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
  118.                 static_cast<System::Byte>(238)));
  119.             this->label1->Location = System::Drawing::Point(169, 118);
  120.             this->label1->Name = L"label1";
  121.             this->label1->Size = System::Drawing::Size(26, 38);
  122.             this->label1->TabIndex = 4;
  123.             this->label1->Text = L":";
  124.             //
  125.             // SS
  126.             //
  127.             this->SS->AutoSize = true;
  128.             this->SS->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 24.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
  129.                 static_cast<System::Byte>(238)));
  130.             this->SS->Location = System::Drawing::Point(185, 118);
  131.             this->SS->Name = L"SS";
  132.             this->SS->Size = System::Drawing::Size(53, 38);
  133.             this->SS->TabIndex = 5;
  134.             this->SS->Text = L"00";
  135.             //
  136.             // timer1
  137.             //
  138.             this->timer1->Enabled = true;
  139.             this->timer1->Interval = 1000;
  140.             this->timer1->Tick += gcnew System::EventHandler(this, &Form1::timer1_Tick);
  141.             //
  142.             // Form1
  143.             //
  144.             this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
  145.             this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
  146.             this->ClientSize = System::Drawing::Size(292, 273);
  147.             this->Controls->Add(this->SS);
  148.             this->Controls->Add(this->label1);
  149.             this->Controls->Add(this->MM);
  150.             this->Controls->Add(this->label2);
  151.             this->Controls->Add(this->HH);
  152.             this->Controls->Add(this->progressBar1);
  153.             this->Name = L"Form1";
  154.             this->Text = L"Form1";
  155.             this->ResumeLayout(false);
  156.             this->PerformLayout();
  157.  
  158.             //Ustawienie czasu
  159.             DateTime czas = DateTime::Now;
  160.             hours = czas.Hour;
  161.             minutes = czas.Minute;
  162.             seconds = czas.Second;
  163.             if (System::Convert::ToString(hours)->Length==1)
  164.                 HH->Text="0"+System::Convert::ToString(hours);
  165.             else
  166.                 HH->Text=System::Convert::ToString(hours);
  167.             if (System::Convert::ToString(minutes)->Length==1)
  168.                 MM->Text="0"+System::Convert::ToString(minutes);
  169.             else
  170.                 MM->Text=System::Convert::ToString(minutes);
  171.             if (System::Convert::ToString(seconds)->Length==1)
  172.                 SS->Text="0"+System::Convert::ToString(seconds);
  173.             else
  174.                 SS->Text=System::Convert::ToString(seconds);
  175.  
  176.         }
  177. #pragma endregion
  178.     private: System::Void timer1_Tick(System::Object^  sender, System::EventArgs^  e) {
  179.                 seconds ++;
  180.                 if (seconds>=60)
  181.                 {
  182.                     seconds = 0;
  183.                     minutes ++;
  184.                 }
  185.                 if (minutes>=60)
  186.                 {
  187.                     minutes = 0;
  188.                     hours ++;
  189.                 }
  190.                 if (hours>=24)
  191.                 {
  192.                     hours = 0;
  193.                 }
  194.                 if (System::Convert::ToString(hours)->Length==1)
  195.                     HH->Text="0"+System::Convert::ToString(hours);
  196.                 else
  197.                     HH->Text=System::Convert::ToString(hours);
  198.                 if (System::Convert::ToString(minutes)->Length==1)
  199.                     MM->Text="0"+System::Convert::ToString(minutes);
  200.                 else
  201.                     MM->Text=System::Convert::ToString(minutes);
  202.                 if (System::Convert::ToString(seconds)->Length==1)
  203.                     SS->Text="0"+System::Convert::ToString(seconds);
  204.                 else
  205.                     SS->Text=System::Convert::ToString(seconds);
  206.              }
  207. private: System::Void MM_Click(System::Object^  sender, System::EventArgs^  e) {
  208.          }
  209. };
  210. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement