czwartek, 9 marca 2017

Dynamic title form/window in Visual C++



#pragma endregion
private: Form^ title_Window;
private: Button^ close_Button;
private: Label^ info_Text1;
private: Label^ info_Text2;
private: System::Drawing::Font^ font1;
private: System::Drawing::Font^ font2;

private: System::Void Form1_Load(System::Object^  sender, System::EventArgs^  e) {
}
private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
title_Window=gcnew Form;
title_Window->Width=400;
title_Window->Height=300;
title_Window->Text="About application";
title_Window->BackColor=System::Drawing::Color::Azure;
                 close_Button=gcnew Button;
close_Button->Text="&Close";
close_Button->Width=120;
close_Button->Height=60;
close_Button->Location=Point(title_Window->Width/2-close_Button->Width/2,title_Window->Height/2-close_Button->Height/2);
close_Button->BackColor=System::Drawing::Color::Bisque;
close_Button->Click+=gcnew EventHandler(this, &Form1::close_Button_Click);
font1=gcnew System::Drawing::Font(System::Drawing::FontFamily::GenericSansSerif,14,FontStyle::Underline);
font2=gcnew System::Drawing::Font(System::Drawing::FontFamily::GenericSansSerif,12,FontStyle::Regular);
info_Text1=gcnew Label;
info_Text1->Width=250;
info_Text1->Text="l077.blogspot.com";
info_Text1->Font=font1;
info_Text1->Location=Point(title_Window->Width/5,title_Window->Height/6);
info_Text2=gcnew Label;
info_Text2->Width=250;
info_Text2->Text="lukasz.wierzbicki2@gmail.com";
info_Text2->Font=font2;
info_Text2->BackColor=System::Drawing::Color::Yellow;
info_Text2->Location=Point(title_Window->Width/5,title_Window->Height-100);

title_Window->Controls->Add(close_Button);
title_Window->Controls->Add(info_Text1);
title_Window->Controls->Add(info_Text2);
title_Window->Show();
 
}
private: System::Void close_Button_Click(System::Object^ sender,System::EventArgs^ e)
 {
 ((Form^)((Button^)sender)->Parent)->Close();
 }
};
}


Brak komentarzy:

Prześlij komentarz