Главная страница

Лабораторная работа 13 vol 2. Построение и обоснование модели проекта


Скачать 0.61 Mb.
НазваниеПостроение и обоснование модели проекта
Дата29.04.2022
Размер0.61 Mb.
Формат файлаdocx
Имя файлаЛабораторная работа 13 vol 2.docx
ТипЛабораторная работа
#504361
страница2 из 3
1   2   3



Рисунок 20 – Обновленная форма приложения

Для клавиш, содержащие цифры добавим следующий код:

if (vvod == true)

{

textBox1->Text = textBox1->Text + button14->Text;

}

if (vvod == false)

{

textBox2->Text = textBox2->Text + button14->Text;

}

Для клавиши Ввода добавим следующий код:

if (vvod == true)

{

textBox1->Text = textBox1->Text + button18->Text;

}

if (vvod == false)

{

textBox2->Text = textBox2->Text + button18->Text;

}

Для клавиши удаления символа добавим следующий код:

if (vvod == true)

{

if (textBox1->Text->Length != 0)

{

textBox1->Text = textBox1->Text->Remove(textBox1->Text->Length - 1);

}

else

{

textBox1->Text = textBox1->Text->Insert(textBox1->Text->Length, "");

}

}

if (vvod == false)

{

if (textBox2->Text->Length != 0)

{

textBox2->Text = textBox2->Text->Remove(textBox2->Text->Length - 1);

}

else

{

textBox2->Text = textBox2->Text->Insert(textBox2->Text->Length, "");

}

}
Текст программы:

Файл MyForm.cpp:

#include "MyForm.h"

using namespace System;

using namespace System::Windows::Forms;

[STAThreadAttribute]

void Main(array^ args)

{

Application::EnableVisualStyles();

Application::SetCompatibleTextRenderingDefault(false);

ProstoCalculator::MyForm form;

Application::Run(% form);

}

Файл MyForm.h:

#define _USE_MATH_DEFINES

#include
namespace ProstoCalculator {

using namespace System;

using namespace System::ComponentModel;

using namespace System::Collections;

using namespace System::Windows::Forms;

using namespace System::Data;

using namespace System::Drawing;
///

/// Сводка для MyForm

///


public ref class MyForm : public System::Windows::Forms::Form

{

public:

MyForm(void)

{

InitializeComponent();

//

//TODO: добавьте код конструктора

//

}
protected:

///

/// Освободить все используемые ресурсы.

///


MyForm()

{

if (components)

{

delete components;

}

}

private: System::Windows::Forms::TextBox^ textBox1;

protected:

private: System::Windows::Forms::TextBox^ textBox2;

private: System::Windows::Forms::Label^ label1;

private: System::Windows::Forms::Button^ button1;

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::Label^ label2;

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^ button17;

private: System::Windows::Forms::Button^ button18;

private: System::Windows::Forms::Button^ button19;

private: System::Windows::Forms::Button^ button20;


private:

///

/// Обязательная переменная конструктора.

///


System::ComponentModel::Container ^components;
#pragma region Windows Form Designer generated code

///

/// Требуемый метод для поддержки конструктора — не изменяйте

/// содержимое этого метода с помощью редактора кода.

///


void InitializeComponent(void)

{

this->textBox1 = (gcnew System::Windows::Forms::TextBox());

this->textBox2 = (gcnew System::Windows::Forms::TextBox());

this->label1 = (gcnew System::Windows::Forms::Label());

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->label2 = (gcnew System::Windows::Forms::Label());

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->button17 = (gcnew System::Windows::Forms::Button());

this->button18 = (gcnew System::Windows::Forms::Button());

this->button19 = (gcnew System::Windows::Forms::Button());

this->button20 = (gcnew System::Windows::Forms::Button());

this->SuspendLayout();

//

// textBox1

//

this->textBox1->Location = System::Drawing::Point(12, 12);

this->textBox1->Name = L"textBox1";

this->textBox1->Size = System::Drawing::Size(110, 20);

this->textBox1->TabIndex = 0;

//

// textBox2

//

this->textBox2->Location = System::Drawing::Point(139, 12);

this->textBox2->Name = L"textBox2";

this->textBox2->Size = System::Drawing::Size(110, 20);

this->textBox2->TabIndex = 1;

//

// label1

//

this->label1->AutoSize = true;

this->label1->Location = System::Drawing::Point(12, 35);

this->label1->Name = L"label1";

this->label1->Size = System::Drawing::Size(35, 13);

this->label1->TabIndex = 2;

this->label1->Text = L"label1";

//

// button1

//

this->button1->Location = System::Drawing::Point(12, 51);

this->button1->Name = L"button1";

this->button1->Size = System::Drawing::Size(75, 23);

this->button1->TabIndex = 3;

this->button1->Text = L"button1";

this->button1->UseVisualStyleBackColor = true;

this->button1->Click += gcnew System::EventHandler(this, &MyForm::button1_Click);

//

// button2

//

this->button2->Location = System::Drawing::Point(93, 51);

this->button2->Name = L"button2";

this->button2->Size = System::Drawing::Size(75, 23);

this->button2->TabIndex = 4;

this->button2->Text = L"button2";

this->button2->UseVisualStyleBackColor = true;

this->button2->Click += gcnew System::EventHandler(this, &MyForm::button2_Click);

//

// button3

//

this->button3->Location = System::Drawing::Point(174, 51);

this->button3->Name = L"button3";

this->button3->Size = System::Drawing::Size(75, 23);

this->button3->TabIndex = 5;

this->button3->Text = L"button3";

this->button3->UseVisualStyleBackColor = true;

this->button3->Click += gcnew System::EventHandler(this, &MyForm::button3_Click);

//

// button4

//

this->button4->Location = System::Drawing::Point(255, 51);

this->button4->Name = L"button4";

this->button4->Size = System::Drawing::Size(75, 23);

this->button4->TabIndex = 6;

this->button4->Text = L"button4";

this->button4->UseVisualStyleBackColor = true;

this->button4->Click += gcnew System::EventHandler(this, &MyForm::button4_Click);

//

// button5

//

this->button5->Location = System::Drawing::Point(12, 80);

this->button5->Name = L"button5";

this->button5->Size = System::Drawing::Size(75, 23);

this->button5->TabIndex = 7;

this->button5->Text = L"button5";

this->button5->UseVisualStyleBackColor = true;

this->button5->Click += gcnew System::EventHandler(this, &MyForm::button5_Click);

//

// label2

//

this->label2->AutoSize = true;

this->label2->Location = System::Drawing::Point(2, 234);

this->label2->Name = L"label2";

this->label2->Size = System::Drawing::Size(35, 13);

this->label2->TabIndex = 8;

this->label2->Text = L"label2";

//

// button6

//

this->button6->Location = System::Drawing::Point(93, 80);

this->button6->Name = L"button6";

this->button6->Size = System::Drawing::Size(75, 23);

this->button6->TabIndex = 9;

this->button6->Text = L"button6";

this->button6->UseVisualStyleBackColor = true;

this->button6->Click += gcnew System::EventHandler(this, &MyForm::button6_Click);

//

// button7

//

this->button7->Location = System::Drawing::Point(174, 80);

this->button7->Name = L"button7";

this->button7->Size = System::Drawing::Size(75, 23);

this->button7->TabIndex = 10;

this->button7->Text = L"button7";

this->button7->UseVisualStyleBackColor = true;

this->button7->Click += gcnew System::EventHandler(this, &MyForm::button7_Click);

//

// button8

//

this->button8->Location = System::Drawing::Point(255, 81);

this->button8->Name = L"button8";

this->button8->Size = System::Drawing::Size(75, 23);

this->button8->TabIndex = 11;

this->button8->Text = L"button8";

this->button8->UseVisualStyleBackColor = true;

this->button8->Click += gcnew System::EventHandler(this, &MyForm::button8_Click);

//

// button9

//

this->button9->Location = System::Drawing::Point(12, 109);

this->button9->Name = L"button9";

this->button9->Size = System::Drawing::Size(75, 23);

this->button9->TabIndex = 12;

this->button9->Text = L"button9";

this->button9->UseVisualStyleBackColor = true;

this->button9->Click += gcnew System::EventHandler(this, &MyForm::button9_Click);

//

// button10

//

this->button10->Location = System::Drawing::Point(93, 109);

this->button10->Name = L"button10";

this->button10->Size = System::Drawing::Size(75, 23);

this->button10->TabIndex = 13;

this->button10->Text = L"button10";

this->button10->UseVisualStyleBackColor = true;

this->button10->Click += gcnew System::EventHandler(this, &MyForm::button10_Click);

//

// button11

//

this->button11->Location = System::Drawing::Point(174, 109);

this->button11->Name = L"button11";

this->button11->Size = System::Drawing::Size(75, 23);

this->button11->TabIndex = 14;

this->button11->Text = L"button11";

this->button11->UseVisualStyleBackColor = true;

this->button11->Click += gcnew System::EventHandler(this, &MyForm::button11_Click);

//

// button12

//

this->button12->Location = System::Drawing::Point(255, 110);

this->button12->Name = L"button12";

this->button12->Size = System::Drawing::Size(75, 23);

this->button12->TabIndex = 15;

this->button12->Text = L"button12";

this->button12->UseVisualStyleBackColor = true;

this->button12->Click += gcnew System::EventHandler(this, &MyForm::button12_Click);

//

// button13

//

this->button13->Location = System::Drawing::Point(12, 138);

this->button13->Name = L"button13";

this->button13->Size = System::Drawing::Size(75, 23);

this->button13->TabIndex = 16;

this->button13->Text = L"button13";

this->button13->UseVisualStyleBackColor = true;

this->button13->Click += gcnew System::EventHandler(this, &MyForm::button13_Click);

//

// button14

//

this->button14->Location = System::Drawing::Point(93, 138);

this->button14->Name = L"button14";

this->button14->Size = System::Drawing::Size(75, 23);

this->button14->TabIndex = 17;

this->button14->Text = L"button14";

this->button14->UseVisualStyleBackColor = true;

this->button14->Click += gcnew System::EventHandler(this, &MyForm::button14_Click);

//

// button15

//

this->button15->Location = System::Drawing::Point(174, 138);

this->button15->Name = L"button15";

this->button15->Size = System::Drawing::Size(75, 23);

this->button15->TabIndex = 18;

this->button15->Text = L"button15";

this->button15->UseVisualStyleBackColor = true;

this->button15->Click += gcnew System::EventHandler(this, &MyForm::button15_Click);

//

// button16

//

this->button16->Location = System::Drawing::Point(255, 139);

this->button16->Name = L"button16";

this->button16->Size = System::Drawing::Size(75, 23);

this->button16->TabIndex = 19;

this->button16->Text = L"button16";

this->button16->UseVisualStyleBackColor = true;

this->button16->Click += gcnew System::EventHandler(this, &MyForm::button16_Click);

//

// button17

//

this->button17->Location = System::Drawing::Point(12, 167);

this->button17->Name = L"button17";

this->button17->Size = System::Drawing::Size(75, 23);

this->button17->TabIndex = 20;

this->button17->Text = L"button17";

this->button17->UseVisualStyleBackColor = true;

this->button17->Click += gcnew System::EventHandler(this, &MyForm::button17_Click);

//

// button18

//

this->button18->Location = System::Drawing::Point(93, 167);

this->button18->Name = L"button18";

this->button18->Size = System::Drawing::Size(75, 23);

this->button18->TabIndex = 21;

this->button18->Text = L"button18";

this->button18->UseVisualStyleBackColor = true;

this->button18->Click += gcnew System::EventHandler(this, &MyForm::button18_Click);

//

// button19

//

this->button19->Location = System::Drawing::Point(174, 167);

this->button19->Name = L"button19";

this->button19->Size = System::Drawing::Size(75, 23);

this->button19->TabIndex = 22;

this->button19->Text = L"button19";

this->button19->UseVisualStyleBackColor = true;

this->button19->Click += gcnew System::EventHandler(this, &MyForm::button19_Click);

//

// button20

//

this->button20->Location = System::Drawing::Point(255, 168);

this->button20->Name = L"button20";

this->button20->Size = System::Drawing::Size(75, 23);

this->button20->TabIndex = 23;

this->button20->Text = L"button20";

this->button20->UseVisualStyleBackColor = true;

this->button20->Click += gcnew System::EventHandler(this, &MyForm::button20_Click);

//

// MyForm

//

this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);

this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;

this->ClientSize = System::Drawing::Size(348, 261);

this->Controls->Add(this->button20);

this->Controls->Add(this->button19);

this->Controls->Add(this->button18);

this->Controls->Add(this->button17);

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);
1   2   3


написать администратору сайта