#pragma once

namespace WindowsFormApplication1 {

	using namespace System;
	using namespace System::ComponentModel;
	using namespace System::Collections;
	using namespace System::Windows::Forms;
	using namespace System::Data;
	using namespace System::Drawing;

	/// <summary>
	/// Summary for Form1
	/// </summary>
	public ref class Form1 : public System::Windows::Forms::Form
	{
	public:
		Form1(void)
		{
			InitializeComponent();
			//
			//TODO: Add the constructor code here
			//
		}

	protected:
		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		~Form1()
		{
			if (components)
			{
				delete components;
			}
		}

	protected: 

	private:
		/// <summary>
		/// Required designer variable.
		/// </summary>
		System::ComponentModel::Container ^components;

#pragma region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		void InitializeComponent(void)
		{
			this->SuspendLayout();
			// 
			// Form1
			// 
			this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
			this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
			this->ClientSize = System::Drawing::Size(284, 262);
			this->Name = L"Form1";
			this->Text = L"Form1";
			this->Load += gcnew System::EventHandler(this, &Form1::Form1_Load);
			this->ResumeLayout(false);

		}
#pragma endregion
	private: System::Void Form1_Load(System::Object^  sender, System::EventArgs^  e) {
				 Form^ okno = gcnew Form;
             okno->Height=120;
             okno->Width=200;
             okno->FormClosing+=
               gcnew FormClosingEventHandler(this,&Form1::okno_FormClosing);
             TextBox^ haslo = gcnew TextBox;
             haslo->Location=Point(20,30);
             haslo->PasswordChar='*';
             Button^ przycisk = gcnew Button;
             przycisk->Click += gcnew EventHandler(this,&Form1::przycisk_Click);
             przycisk->Location=Point(20,60);
             przycisk->Text="OK";
             Label^ etykieta = gcnew Label;
             etykieta->Text="Podaj hasło:";
             etykieta->Location=Point(20,10);
             okno->Controls->Add(haslo);
             okno->Controls->Add(przycisk);
             okno->Controls->Add(etykieta);
             okno->ShowDialog();

			 }
	private: System::Void okno_FormClosing(System::Object^  sender,
  System::Windows::Forms::FormClosingEventArgs^  e) {
             if ((((Form^)sender)->Controls[0]->Text)!="Haslo")
                e->Cancel=true;
             else
                e->Cancel=false;
         }

	private: System::Void przycisk_Click(System::Object^  sender, System::EventArgs^  e) {
             ((Form^)((Button^)sender)->Parent)->Close();
         }

	};
}

