Форум программистов, компьютерный форум, киберфорум
C++/CLI Windows Forms
Войти
Регистрация
Восстановить пароль
Карта форума Темы раздела Блоги Сообщество Поиск Заказать работу  
 
3 / 2 / 1
Регистрация: 17.11.2018
Сообщений: 41
1

Как создать очередь в Windows Form

14.11.2020, 20:31. Показов 622. Ответов 0
Метки нет (Все метки)

Author24 — интернет-сервис помощи студентам
Добрый ,уважаемые господа) Такая вот задача "С помощью Windows From реализовать очередь , которая будет добавлять элементы , удалять первый , выводить первый , выводить последний и выводить размер очереди". И стала такая проблема, объявление в Windows Form отличается от обычного с++ и на простое queue<string> myQueue; , компилятор возмущается. Пробовал сделать так : Queue<System::String> numbers = new Queue<System::String>; , но тоже не подошло. Сам только начал работать с Windows From , нуждаюсь в помощи ( можно больше объяснений ) и да #include <queue> подключить не забыл . На элементы самой формы не обращайте внимение
C++
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
#pragma once 
#include <queue>
#include <string>
 
namespace Program {
 
    using namespace System;
    using namespace System::ComponentModel;
    using namespace System::Collections;
    using namespace System::Windows::Forms;
    using namespace System::Data;
    using namespace System::Drawing;
 
    public ref class MenuForm : public System::Windows::Forms::Form
    {
    private:
        Queue<System::String> numbers = new Queue<System::String>;
    public:
        MenuForm(void)
        {
             InitializeComponent();
        }
    protected:
        ~MenuForm()
        {
            if (components)
            {
                delete components;
            }
        }
    public: System::Windows::Forms::Button^ addSave;
    public: System::Windows::Forms::TextBox^ textBox_Input;
    private: System::Windows::Forms::GroupBox^ groupBox1;
    private: System::Windows::Forms::CheckBox^ checkBox1;
    private: System::Windows::Forms::CheckBox^ checkBox2;
    private: System::Windows::Forms::CheckBox^ checkBox3;
    public: System::Windows::Forms::TextBox^ textBox1;
    private: System::ComponentModel::Container ^components;
#pragma region Windows Form Designer generated code
        void InitializeComponent(void){
            this->addSave = (gcnew System::Windows::Forms::Button());
            this->textBox_Input = (gcnew System::Windows::Forms::TextBox());
            this->groupBox1 = (gcnew System::Windows::Forms::GroupBox());
            this->checkBox1 = (gcnew System::Windows::Forms::CheckBox());
            this->checkBox2 = (gcnew System::Windows::Forms::CheckBox());
            this->checkBox3 = (gcnew System::Windows::Forms::CheckBox());
            this->textBox1 = (gcnew System::Windows::Forms::TextBox());
            this->groupBox1->SuspendLayout();
            this->SuspendLayout();
            // 
            // addSave
            // 
            this->addSave->BackColor = System::Drawing::Color::Gold;
            this->addSave->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 11.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
                static_cast<System::Byte>(204)));
            this->addSave->Location = System::Drawing::Point(437, 34);
            this->addSave->Name = L"addSave";
            this->addSave->Size = System::Drawing::Size(101, 30);
            this->addSave->TabIndex = 1;
            this->addSave->Text = L"Add";
            this->addSave->UseVisualStyleBackColor = false;
            this->addSave->UseWaitCursor = true;
            this->addSave->Click += gcnew System::EventHandler(this, &MenuForm::addSave_Click);
            // 
            // textBox_Input
            // 
            this->textBox_Input->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
                static_cast<System::Byte>(204)));
            this->textBox_Input->Location = System::Drawing::Point(6, 34);
            this->textBox_Input->Multiline = true;
            this->textBox_Input->Name = L"textBox_Input";
            this->textBox_Input->Size = System::Drawing::Size(425, 30);
            this->textBox_Input->TabIndex = 2;
            this->textBox_Input->UseWaitCursor = true;
            // 
            // groupBox1
            // 
            this->groupBox1->Controls->Add(this->textBox_Input);
            this->groupBox1->Controls->Add(this->addSave);
            this->groupBox1->Location = System::Drawing::Point(12, 12);
            this->groupBox1->Name = L"groupBox1";
            this->groupBox1->Size = System::Drawing::Size(544, 86);
            this->groupBox1->TabIndex = 6;
            this->groupBox1->TabStop = false;
            this->groupBox1->Text = L"Ввод строки в очередь";
            this->groupBox1->UseWaitCursor = true;
            // 
            // checkBox1
            // 
            this->checkBox1->AutoSize = true;
            this->checkBox1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9.75F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
                static_cast<System::Byte>(204)));
            this->checkBox1->Location = System::Drawing::Point(12, 122);
            this->checkBox1->Name = L"checkBox1";
            this->checkBox1->Size = System::Drawing::Size(186, 20);
            this->checkBox1->TabIndex = 7;
            this->checkBox1->Text = L"Изъять первый элемент";
            this->checkBox1->UseVisualStyleBackColor = true;
            this->checkBox1->UseWaitCursor = true;
            // 
            // checkBox2
            // 
            this->checkBox2->AutoSize = true;
            this->checkBox2->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9.75F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
                static_cast<System::Byte>(204)));
            this->checkBox2->Location = System::Drawing::Point(12, 148);
            this->checkBox2->Name = L"checkBox2";
            this->checkBox2->Size = System::Drawing::Size(202, 20);
            this->checkBox2->TabIndex = 8;
            this->checkBox2->Text = L"Получить первый элемент";
            this->checkBox2->UseVisualStyleBackColor = true;
            this->checkBox2->UseWaitCursor = true;
            // 
            // checkBox3
            // 
            this->checkBox3->AutoSize = true;
            this->checkBox3->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9.75F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
                static_cast<System::Byte>(204)));
            this->checkBox3->Location = System::Drawing::Point(12, 174);
            this->checkBox3->Name = L"checkBox3";
            this->checkBox3->Size = System::Drawing::Size(194, 20);
            this->checkBox3->TabIndex = 9;
            this->checkBox3->Text = L"Вывести размер очереди";
            this->checkBox3->UseVisualStyleBackColor = true;
            this->checkBox3->UseWaitCursor = true;
            // 
            // textBox1
            // 
            this->textBox1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
                static_cast<System::Byte>(204)));
            this->textBox1->Location = System::Drawing::Point(12, 200);
            this->textBox1->Multiline = true;
            this->textBox1->Name = L"textBox1";
            this->textBox1->Size = System::Drawing::Size(425, 30);
            this->textBox1->TabIndex = 10;
            this->textBox1->UseWaitCursor = true;
            // 
            // MenuForm
            // 
            this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
            this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
            this->BackColor = System::Drawing::SystemColors::ActiveCaption;
            this->ClientSize = System::Drawing::Size(568, 264);
            this->Controls->Add(this->textBox1);
            this->Controls->Add(this->checkBox3);
            this->Controls->Add(this->checkBox2);
            this->Controls->Add(this->checkBox1);
            this->Controls->Add(this->groupBox1);
            this->Cursor = System::Windows::Forms::Cursors::WaitCursor;
            this->FormBorderStyle = System::Windows::Forms::FormBorderStyle::Fixed3D;
            this->MaximizeBox = false;
            this->Name = L"MenuForm";
            this->SizeGripStyle = System::Windows::Forms::SizeGripStyle::Hide;
            this->StartPosition = System::Windows::Forms::FormStartPosition::CenterScreen;
            this->Text = L"Работа с очередью";
            this->TopMost = true;
            this->TransparencyKey = System::Drawing::Color::Black;
            this->UseWaitCursor = true;
            this->groupBox1->ResumeLayout(false);
            this->groupBox1->PerformLayout();
            this->ResumeLayout(false);
            this->PerformLayout();
 
        }
#pragma endregion
private: System::Void addSave_Click(System::Object^ sender, System::EventArgs^ e);
};
}
Исполняемый файл
C++
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include "MenuForm.h"
 
using namespace System;
using namespace System::Windows::Forms;
 
[STAThreadAttribute]
void main(array<String^>^ args) {
    Application::EnableVisualStyles();
    Application::SetCompatibleTextRenderingDefault(false); 
    Program::MenuForm form;
    Application::Run(%form);
 
}
 
System::Void Program::MenuForm::addSave_Click(System::Object^ sender, System::EventArgs^ e)
{
    myQueue.push(textBox_Input);
}
0
Programming
Эксперт
94731 / 64177 / 26122
Регистрация: 12.04.2006
Сообщений: 116,782
14.11.2020, 20:31
Ответы с готовыми решениями:

Как создать Windows Form на vs 2017?
Готовая консольная программа есть. Вообще не понятно, в интернете размыто.

Как создать меню в Windows Form
Здравствуйте, подскажите как создать меню в форме. Есть элемент MenuStrip. При нажатии на пункт...

Создать win form, используя шаблон windows form в clr, однако такого шаблона на моей студии 2013 нет
есть необходимость создать win form используя шаблон windows form в clr, однако такого шаблона на...

Как создать базу данных программно из Windows Form?
Заранее извиняюсь, возможно не в тот раздел пишу, но я новичок и хочу узнать ответ на один из...

0
14.11.2020, 20:31
IT_Exp
Эксперт
87844 / 49110 / 22898
Регистрация: 17.06.2006
Сообщений: 92,604
14.11.2020, 20:31
Помогаю со студенческими работами здесь

Как создать представителя класса, добавленного в проект Windows Form C#?
Добавил в проект новый класс в виде отдельного файла, теперь пытаюсь создать в основном коде его...

Как и где создать метод, который будет доступен всем формам Windows Form?
Как и где создать метод, который будет доступен всем формам Windows Form.Хотел через Program.cs, не...

Как создать Windows Form Project из Empty Project)
Если можно дайте ссылку для прочтения и самоизучения, либо покажите на пальцах,по пунктах.

Не могу создать Windows Form
Добрый день. Подскажите, нет класс Windows.Form в Visual.Basic.net (Visual Studio 2015). Что...

Создать приложение Windows Form
Добрый день! Помогите, пожалуйста, с заданием. Написала код на С#, представляющий собой парсер...

Создать консоль в Windows Form
Как можно создать консоль в Windows Form приложении?


Искать еще темы с ответами

Или воспользуйтесь поиском по форуму:
1
Ответ Создать тему
КиберФорум - форум программистов, компьютерный форум, программирование
Powered by vBulletin
Copyright ©2000 - 2024, CyberForum.ru