Форум программистов, компьютерный форум, киберфорум
C++/CLI Windows Forms
Войти
Регистрация
Восстановить пароль
Блоги Сообщество Поиск Заказать работу  
 
Рейтинг 5.00/8: Рейтинг темы: голосов - 8, средняя оценка - 5.00
1 / 1 / 0
Регистрация: 22.12.2020
Сообщений: 140

Не прогружается 2 форма

11.04.2021, 12:41. Показов 1779. Ответов 13
Метки нет (Все метки)

Студворк — интернет-сервис помощи студентам
Здравствуйте!
MyForm.h
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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
#pragma once
#include <winsock2.h>
#include <cstdio>
#include <string>
#include "MyForm1.h"
#pragma comment(lib, "ws2_32.lib")
 
namespace ff {
 
    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>
    /// Сводка для MyForm
    /// </summary>
    public ref class MyForm : public System::Windows::Forms::Form
    {
    public:
        MyForm(void)
        {
            InitializeComponent();
            //
            //TODO: добавьте код конструктора
            //
        }
 
    protected:
        /// <summary>
        /// Освободить все используемые ресурсы.
        /// </summary>
        ~MyForm()
        {
            if (components)
            {
                delete components;
            }
        }
 
    private: System::Windows::Forms::TextBox^  textBox1;
    private: System::Windows::Forms::TextBox^  textBox2;
    private: System::Windows::Forms::Button^  button1;
    private: System::Windows::Forms::MenuStrip^  menuStrip1;
    private: System::Windows::Forms::ToolStripMenuItem^  настройкиToolStripMenuItem;
    private: System::Windows::Forms::ToolStripMenuItem^  подключениеToolStripMenuItem;
 
 
 
 
 
 
 
 
    private: System::ComponentModel::IContainer^  components;
 
 
    protected:
 
    private:
        /// <summary>
        /// Требуется переменная конструктора.
        /// </summary>
 
 
#pragma region Windows Form Designer generated code
        /// <summary>
        /// Обязательный метод для поддержки конструктора - не изменяйте
        /// содержимое данного метода при помощи редактора кода.
        /// </summary>
        SOCKET Connection;
        void InitializeComponent(void)
        {
            System::ComponentModel::ComponentResourceManager^  resources = (gcnew System::ComponentModel::ComponentResourceManager(MyForm::typeid));
            this->textBox1 = (gcnew System::Windows::Forms::TextBox());
            this->textBox2 = (gcnew System::Windows::Forms::TextBox());
            this->button1 = (gcnew System::Windows::Forms::Button());
            this->menuStrip1 = (gcnew System::Windows::Forms::MenuStrip());
            this->настройкиToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
            this->подключениеToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
            this->menuStrip1->SuspendLayout();
            this->SuspendLayout();
            // 
            // textBox1
            // 
            this->textBox1->Anchor = static_cast<System::Windows::Forms::AnchorStyles>(((System::Windows::Forms::AnchorStyles::Bottom | System::Windows::Forms::AnchorStyles::Left)
                | System::Windows::Forms::AnchorStyles::Right));
            this->textBox1->BackColor = System::Drawing::Color::FromArgb(static_cast<System::Int32>(static_cast<System::Byte>(200)), static_cast<System::Int32>(static_cast<System::Byte>(200)),
                static_cast<System::Int32>(static_cast<System::Byte>(200)));
            this->textBox1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9.75F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
                static_cast<System::Byte>(204)));
            this->textBox1->ForeColor = System::Drawing::Color::Green;
            this->textBox1->Location = System::Drawing::Point(0, 378);
            this->textBox1->Margin = System::Windows::Forms::Padding(0);
            this->textBox1->Multiline = true;
            this->textBox1->Name = L"textBox1";
            this->textBox1->ScrollBars = System::Windows::Forms::ScrollBars::Vertical;
            this->textBox1->Size = System::Drawing::Size(785, 42);
            this->textBox1->TabIndex = 1;
            this->textBox1->TextChanged += gcnew System::EventHandler(this, &MyForm::textBox1_TextChanged);
            // 
            // textBox2
            // 
            this->textBox2->Anchor = static_cast<System::Windows::Forms::AnchorStyles>((((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Bottom)
                | System::Windows::Forms::AnchorStyles::Left)
                | System::Windows::Forms::AnchorStyles::Right));
            this->textBox2->BackColor = System::Drawing::Color::Black;
            this->textBox2->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
                static_cast<System::Byte>(204)));
            this->textBox2->ForeColor = System::Drawing::Color::Green;
            this->textBox2->Location = System::Drawing::Point(0, 27);
            this->textBox2->Multiline = true;
            this->textBox2->Name = L"textBox2";
            this->textBox2->ReadOnly = true;
            this->textBox2->Size = System::Drawing::Size(831, 355);
            this->textBox2->TabIndex = 2;
            this->textBox2->TextChanged += gcnew System::EventHandler(this, &MyForm::textBox2_TextChanged);
            // 
            // button1
            // 
            this->button1->Anchor = static_cast<System::Windows::Forms::AnchorStyles>((System::Windows::Forms::AnchorStyles::Bottom | System::Windows::Forms::AnchorStyles::Right));
            this->button1->Cursor = System::Windows::Forms::Cursors::Hand;
            this->button1->Image = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"button1.Image")));
            this->button1->Location = System::Drawing::Point(785, 380);
            this->button1->Margin = System::Windows::Forms::Padding(0);
            this->button1->MaximumSize = System::Drawing::Size(46, 40);
            this->button1->Name = L"button1";
            this->button1->Size = System::Drawing::Size(46, 40);
            this->button1->TabIndex = 3;
            this->button1->UseVisualStyleBackColor = true;
            this->button1->Click += gcnew System::EventHandler(this, &MyForm::button1_Click);
            // 
            // menuStrip1
            // 
            this->menuStrip1->Items->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(1) { this->настройкиToolStripMenuItem });
            this->menuStrip1->Location = System::Drawing::Point(0, 0);
            this->menuStrip1->Name = L"menuStrip1";
            this->menuStrip1->Size = System::Drawing::Size(831, 24);
            this->menuStrip1->TabIndex = 5;
            this->menuStrip1->Text = L"menuStrip1";
            this->menuStrip1->ItemClicked += gcnew System::Windows::Forms::ToolStripItemClickedEventHandler(this, &MyForm::menuStrip1_ItemClicked);
            // 
            // настройкиToolStripMenuItem
            // 
            this->настройкиToolStripMenuItem->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(1) { this->подключениеToolStripMenuItem });
            this->настройкиToolStripMenuItem->Image = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"настройкиToolStripMenuItem.Image")));
            this->настройкиToolStripMenuItem->Name = L"настройкиToolStripMenuItem";
            this->настройкиToolStripMenuItem->Size = System::Drawing::Size(95, 20);
            this->настройкиToolStripMenuItem->Text = L"Настройки";
            // 
            // подключениеToolStripMenuItem
            // 
            this->подключениеToolStripMenuItem->CheckOnClick = true;
            this->подключениеToolStripMenuItem->Image = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"подключениеToolStripMenuItem.Image")));
            this->подключениеToolStripMenuItem->Name = L"подключениеToolStripMenuItem";
            this->подключениеToolStripMenuItem->Size = System::Drawing::Size(152, 22);
            this->подключениеToolStripMenuItem->Text = L"Подключение";
            this->подключениеToolStripMenuItem->Click += gcnew System::EventHandler(this, &MyForm::подключениеToolStripMenuItem_Click);
            // 
            // MyForm
            // 
            this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
            this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
            this->BackColor = System::Drawing::SystemColors::ButtonHighlight;
            this->BackgroundImageLayout = System::Windows::Forms::ImageLayout::Center;
            this->ClientSize = System::Drawing::Size(831, 421);
            this->Controls->Add(this->menuStrip1);
            this->Controls->Add(this->button1);
            this->Controls->Add(this->textBox2);
            this->Controls->Add(this->textBox1);
            this->DoubleBuffered = true;
            this->Icon = (cli::safe_cast<System::Drawing::Icon^>(resources->GetObject(L"$this.Icon")));
            this->MainMenuStrip = this->menuStrip1;
            this->Name = L"MyForm";
            this->StartPosition = System::Windows::Forms::FormStartPosition::CenterScreen;
            this->Text = L"Chat v1.3";
            this->Load += gcnew System::EventHandler(this, &MyForm::MyForm_Load);
            this->menuStrip1->ResumeLayout(false);
            this->menuStrip1->PerformLayout();
            this->ResumeLayout(false);
            this->PerformLayout();
 
        }
#pragma endregion
    private: System::Void textBox1_TextChanged(System::Object^  sender, System::EventArgs^  e) {
    }
    private: System::Void label1_Click(System::Object^  sender, System::EventArgs^  e) {
    }
    private: System::Void MyForm_Load(System::Object^  sender, System::EventArgs^  e) {
    }
 
    private: System::Void textBox2_TextChanged(System::Object^  sender, System::EventArgs^  e) {
    }
    private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
 
    }
private: System::Void numericUpDown1_ValueChanged(System::Object^  sender, System::EventArgs^  e) {
}
private: System::Void contextMenuStrip1_Opening(System::Object^  sender, System::ComponentModel::CancelEventArgs^  e) {
}
private: System::Void menuStrip1_ItemClicked(System::Object^  sender, System::Windows::Forms::ToolStripItemClickedEventArgs^  e) {
 
}
private: LPTHREAD_START_ROUTINE ClientHandler() {
             char msg[256];
             while (true)
             {
                 recv(Connection, msg, sizeof(msg), NULL);
                 printf("%s\n", msg);
             }
}
private: System::Void подключениеToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e) {
             MyForm1^ f2 = gcnew MyForm1();
             f2->Show();
             while (true)
             {
                 if (strcmp(ni, "") && np != 0 && strcmp(nn, ""))
                 {
                     break;
                 }
             } 
             WSAData wsaData;
             WORD DLLVersion = MAKEWORD(2, 1);
             if (WSAStartup(DLLVersion, &wsaData) != 0){
                 printf("erorr");
                 exit(1);
             }
 
             SOCKADDR_IN addr;
             int sizeofaddr = sizeof(addr);
             addr.sin_addr.s_addr = inet_addr(ni);
             addr.sin_port = htons(*np);
             addr.sin_family = AF_INET;
 
             Connection = socket(AF_INET, SOCK_STREAM, NULL);
             if (connect(Connection, (SOCKADDR*)&addr, sizeof(addr)) != 0) {
                 printf("error failed connect to server");
                 exit(1);
             };
             printf("[CONNECTED]\n");
 
             send(Connection, nn, sizeof(nn), NULL);
 
             CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE)ff::MyForm::ClientHandler(), NULL, NULL, NULL);
 
             char msgl[256];
             while (true)
             {
                 fgets(msgl, 256, stdin);
                 send(Connection, msgl, sizeof(msgl), NULL);
                 Sleep(20);
             }
 
 
             system("pause");
}
};
}
Здесь проблема
MyForm1.h
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
169
170
171
172
173
174
#pragma once
 
namespace ff {
 
    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>
    /// Сводка для MyForm1
    /// </summary>
 
    typedef unsigned short u_short;
    static char ni[16];
    static u_short np[6];
    static char nn[20];
 
    public ref class MyForm1 : public System::Windows::Forms::Form
    {
    public:
        MyForm1(void)
        {
            InitializeComponent();
            //
            //TODO: добавьте код конструктора
            //
        }
 
    protected:
        /// <summary>
        /// Освободить все используемые ресурсы.
        /// </summary>
        ~MyForm1()
        {
            if (components)
            {
                delete components;
            }
        }
 
    protected:
    private: System::Windows::Forms::TextBox^  textBox1;
    private: System::Windows::Forms::Label^  label1;
    private: System::Windows::Forms::TextBox^  textBox2;
    private: System::Windows::Forms::Label^  label2;
    private: System::Windows::Forms::Label^  label3;
    private: System::Windows::Forms::TextBox^  textBox3;
    private: System::Windows::Forms::Button^  button1;
 
    private:
        /// <summary>
        /// Требуется переменная конструктора.
        /// </summary>
        System::ComponentModel::Container ^components;
 
#pragma region Windows Form Designer generated code
        /// <summary>
        /// Обязательный метод для поддержки конструктора - не изменяйте
        /// содержимое данного метода при помощи редактора кода.
        /// </summary>
        void InitializeComponent(void)
        {
            System::ComponentModel::ComponentResourceManager^  resources = (gcnew System::ComponentModel::ComponentResourceManager(MyForm1::typeid));
            this->textBox1 = (gcnew System::Windows::Forms::TextBox());
            this->label1 = (gcnew System::Windows::Forms::Label());
            this->textBox2 = (gcnew System::Windows::Forms::TextBox());
            this->label2 = (gcnew System::Windows::Forms::Label());
            this->label3 = (gcnew System::Windows::Forms::Label());
            this->textBox3 = (gcnew System::Windows::Forms::TextBox());
            this->button1 = (gcnew System::Windows::Forms::Button());
            this->SuspendLayout();
            // 
            // textBox1
            // 
            this->textBox1->Location = System::Drawing::Point(85, 183);
            this->textBox1->Name = L"textBox1";
            this->textBox1->Size = System::Drawing::Size(100, 20);
            this->textBox1->TabIndex = 2;
            // 
            // label1
            // 
            this->label1->AutoSize = true;
            this->label1->Location = System::Drawing::Point(122, 150);
            this->label1->Name = L"label1";
            this->label1->Size = System::Drawing::Size(27, 13);
            this->label1->TabIndex = 3;
            this->label1->Text = L"Ник";
            // 
            // textBox2
            // 
            this->textBox2->Location = System::Drawing::Point(85, 106);
            this->textBox2->Name = L"textBox2";
            this->textBox2->Size = System::Drawing::Size(100, 20);
            this->textBox2->TabIndex = 4;
            // 
            // label2
            // 
            this->label2->AutoSize = true;
            this->label2->Location = System::Drawing::Point(122, 74);
            this->label2->Name = L"label2";
            this->label2->Size = System::Drawing::Size(32, 13);
            this->label2->TabIndex = 5;
            this->label2->Text = L"Порт";
            // 
            // label3
            // 
            this->label3->AutoSize = true;
            this->label3->Location = System::Drawing::Point(122, 9);
            this->label3->Name = L"label3";
            this->label3->Size = System::Drawing::Size(17, 13);
            this->label3->TabIndex = 6;
            this->label3->Text = L"IP";
            // 
            // textBox3
            // 
            this->textBox3->Location = System::Drawing::Point(85, 37);
            this->textBox3->Name = L"textBox3";
            this->textBox3->Size = System::Drawing::Size(100, 20);
            this->textBox3->TabIndex = 7;
            // 
            // button1
            // 
            this->button1->Location = System::Drawing::Point(85, 227);
            this->button1->Name = L"button1";
            this->button1->Size = System::Drawing::Size(100, 23);
            this->button1->TabIndex = 8;
            this->button1->Text = L"Подключиться";
            this->button1->UseVisualStyleBackColor = true;
            this->button1->Click += gcnew System::EventHandler(this, &MyForm1::button1_Click);
            // 
            // MyForm1
            // 
            this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
            this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
            this->ClientSize = System::Drawing::Size(284, 262);
            this->Controls->Add(this->button1);
            this->Controls->Add(this->textBox3);
            this->Controls->Add(this->label3);
            this->Controls->Add(this->label2);
            this->Controls->Add(this->textBox2);
            this->Controls->Add(this->label1);
            this->Controls->Add(this->textBox1);
            this->Icon = (cli::safe_cast<System::Drawing::Icon^>(resources->GetObject(L"$this.Icon")));
            this->MaximumSize = System::Drawing::Size(300, 300);
            this->Name = L"MyForm1";
            this->StartPosition = System::Windows::Forms::FormStartPosition::CenterScreen;
            this->Text = L"Подключение";
            this->ResumeLayout(false);
            this->PerformLayout();
 
        }
#pragma endregion
    public: System::Void p(){
                 for (int i = 0; i < textBox2->Text->Length; i++)
                 {
                     np[i] = textBox2->Text[i];
                 }   
                 for (int i = 0; i < textBox3->Text->Length; i++)
                 {
                     ni[i] = textBox3->Text[i];
                 }
                 for (int i = 0; i < textBox1->Text->Length; i++)
                 {
                     nn[i] = textBox1->Text[i];
                 }
    }
    private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
                 p();
    }
    };
}
0
cpp_developer
Эксперт
20123 / 5690 / 1417
Регистрация: 09.04.2010
Сообщений: 22,546
Блог
11.04.2021, 12:41
Ответы с готовыми решениями:

Не прогружается форма
Добрый вечер, не компилируется программа, ссылаясь на то, что некоторые значения принимают нули. Хотя ранее работало великолепно. Такое...

Не прогружается начальная форма программы
Программа написана на VB.net установлена на 14 компьютерах, и у некоторых юзеров время от времени перестает грузиться - на панели задач...

Не прогружается ПК
Мать: P4 TITAN Hyper Threading VRM 10.0 Видеокарта: Palit ??? Оперативная память: 1024 mb Samsung БП:Sleeve Bearling 400w HDD:...

13
1 / 1 / 0
Регистрация: 22.12.2020
Сообщений: 140
11.04.2021, 12:47  [ТС]
Скрин:
0
Администратор
Эксперт .NET
 Аватар для OwenGlendower
18262 / 14187 / 5366
Регистрация: 17.03.2014
Сообщений: 28,872
Записей в блоге: 1
11.04.2021, 15:14
Цитата Сообщение от qwaz Посмотреть сообщение
Здесь проблема
MyForm1.h
Нет. Проблема здесь:
Цитата Сообщение от qwaz Посмотреть сообщение
C++
1
2
3
MyForm1^ f2 = gcnew MyForm1();
f2->Show();
while (true)
Вы не даете форме прорисоваться заняв главный поток.
0
1 / 1 / 0
Регистрация: 22.12.2020
Сообщений: 140
11.04.2021, 16:39  [ТС]
А можно код как реализовать это с потоками winapi
0
Администратор
Эксперт .NET
 Аватар для OwenGlendower
18262 / 14187 / 5366
Регистрация: 17.03.2014
Сообщений: 28,872
Записей в блоге: 1
11.04.2021, 17:12
qwaz, код сейчас не смогу привести. Смотрите класс System::Threading::Thread
0
1 / 1 / 0
Регистрация: 22.12.2020
Сообщений: 140
11.04.2021, 18:32  [ТС]
Пытался почему-то не получается и все равно виснет
0
Администратор
Эксперт .NET
 Аватар для OwenGlendower
18262 / 14187 / 5366
Регистрация: 17.03.2014
Сообщений: 28,872
Записей в блоге: 1
11.04.2021, 18:36
qwaz, показывайте код
0
1 / 1 / 0
Регистрация: 22.12.2020
Сообщений: 140
12.04.2021, 06:06  [ТС]
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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
#pragma once
#include <winsock2.h>
#include <cstdio>
#include <string>
#include "MyForm1.h"
#pragma comment(lib, "ws2_32.lib")
#pragma warning(default:4716)
 
namespace ff {
 
    using namespace System;
    using namespace System::Threading;
    using namespace System::ComponentModel;
    using namespace System::Collections;
    using namespace System::Windows::Forms;
    using namespace System::Data;
    using namespace System::Drawing;
 
 
    /// <summary>
    /// Сводка для MyForm
    /// </summary>
    public ref class MyForm : public System::Windows::Forms::Form
    {
    public:
        MyForm(void)
        {
            InitializeComponent();
            //
            //TODO: добавьте код конструктора
            //
        }
 
    protected:
        /// <summary>
        /// Освободить все используемые ресурсы.
        /// </summary>
        ~MyForm()
        {
            if (components)
            {
                delete components;
            }
        }
 
    private: System::Windows::Forms::TextBox^  textBox1;
    private: System::Windows::Forms::TextBox^  textBox2;
    private: System::Windows::Forms::Button^  button1;
    private: System::Windows::Forms::MenuStrip^  menuStrip1;
    private: System::Windows::Forms::ToolStripMenuItem^  настройкиToolStripMenuItem;
    private: System::Windows::Forms::ToolStripMenuItem^  подключениеToolStripMenuItem;
 
 
 
 
 
 
 
 
    private: System::ComponentModel::IContainer^  components;
 
 
    protected:
 
    private:
        /// <summary>
        /// Требуется переменная конструктора.
        /// </summary>
 
SOCKET Connection;
 
#pragma region Windows Form Designer generated code
        /// <summary>
        /// Обязательный метод для поддержки конструктора - не изменяйте
        /// содержимое данного метода при помощи редактора кода.
        /// </summary>
        void InitializeComponent(void)
        {
            System::ComponentModel::ComponentResourceManager^  resources = (gcnew System::ComponentModel::ComponentResourceManager(MyForm::typeid));
            this->textBox1 = (gcnew System::Windows::Forms::TextBox());
            this->textBox2 = (gcnew System::Windows::Forms::TextBox());
            this->button1 = (gcnew System::Windows::Forms::Button());
            this->menuStrip1 = (gcnew System::Windows::Forms::MenuStrip());
            this->настройкиToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
            this->подключениеToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
            this->menuStrip1->SuspendLayout();
            this->SuspendLayout();
            // 
            // textBox1
            // 
            this->textBox1->Anchor = static_cast<System::Windows::Forms::AnchorStyles>(((System::Windows::Forms::AnchorStyles::Bottom | System::Windows::Forms::AnchorStyles::Left)
                | System::Windows::Forms::AnchorStyles::Right));
            this->textBox1->BackColor = System::Drawing::Color::FromArgb(static_cast<System::Int32>(static_cast<System::Byte>(200)), static_cast<System::Int32>(static_cast<System::Byte>(200)),
                static_cast<System::Int32>(static_cast<System::Byte>(200)));
            this->textBox1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9.75F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
                static_cast<System::Byte>(204)));
            this->textBox1->ForeColor = System::Drawing::Color::Green;
            this->textBox1->Location = System::Drawing::Point(0, 378);
            this->textBox1->Margin = System::Windows::Forms::Padding(0);
            this->textBox1->Multiline = true;
            this->textBox1->Name = L"textBox1";
            this->textBox1->ScrollBars = System::Windows::Forms::ScrollBars::Vertical;
            this->textBox1->Size = System::Drawing::Size(785, 42);
            this->textBox1->TabIndex = 1;
            this->textBox1->TextChanged += gcnew System::EventHandler(this, &MyForm::textBox1_TextChanged);
            // 
            // textBox2
            // 
            this->textBox2->Anchor = static_cast<System::Windows::Forms::AnchorStyles>((((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Bottom)
                | System::Windows::Forms::AnchorStyles::Left)
                | System::Windows::Forms::AnchorStyles::Right));
            this->textBox2->BackColor = System::Drawing::Color::Black;
            this->textBox2->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
                static_cast<System::Byte>(204)));
            this->textBox2->ForeColor = System::Drawing::Color::Green;
            this->textBox2->Location = System::Drawing::Point(0, 27);
            this->textBox2->Multiline = true;
            this->textBox2->Name = L"textBox2";
            this->textBox2->ReadOnly = true;
            this->textBox2->Size = System::Drawing::Size(831, 355);
            this->textBox2->TabIndex = 2;
            this->textBox2->TextChanged += gcnew System::EventHandler(this, &MyForm::textBox2_TextChanged);
            // 
            // button1
            // 
            this->button1->Anchor = static_cast<System::Windows::Forms::AnchorStyles>((System::Windows::Forms::AnchorStyles::Bottom | System::Windows::Forms::AnchorStyles::Right));
            this->button1->Cursor = System::Windows::Forms::Cursors::Hand;
            this->button1->Image = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"button1.Image")));
            this->button1->Location = System::Drawing::Point(785, 380);
            this->button1->Margin = System::Windows::Forms::Padding(0);
            this->button1->MaximumSize = System::Drawing::Size(46, 40);
            this->button1->Name = L"button1";
            this->button1->Size = System::Drawing::Size(46, 40);
            this->button1->TabIndex = 3;
            this->button1->UseVisualStyleBackColor = true;
            this->button1->Click += gcnew System::EventHandler(this, &MyForm::button1_Click);
            // 
            // menuStrip1
            // 
            this->menuStrip1->Items->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(1) { this->настройкиToolStripMenuItem });
            this->menuStrip1->Location = System::Drawing::Point(0, 0);
            this->menuStrip1->Name = L"menuStrip1";
            this->menuStrip1->Size = System::Drawing::Size(831, 24);
            this->menuStrip1->TabIndex = 5;
            this->menuStrip1->Text = L"menuStrip1";
            this->menuStrip1->ItemClicked += gcnew System::Windows::Forms::ToolStripItemClickedEventHandler(this, &MyForm::menuStrip1_ItemClicked);
            // 
            // настройкиToolStripMenuItem
            // 
            this->настройкиToolStripMenuItem->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(1) { this->подключениеToolStripMenuItem });
            this->настройкиToolStripMenuItem->Image = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"настройкиToolStripMenuItem.Image")));
            this->настройкиToolStripMenuItem->Name = L"настройкиToolStripMenuItem";
            this->настройкиToolStripMenuItem->Size = System::Drawing::Size(95, 20);
            this->настройкиToolStripMenuItem->Text = L"Настройки";
            // 
            // подключениеToolStripMenuItem
            // 
            this->подключениеToolStripMenuItem->CheckOnClick = true;
            this->подключениеToolStripMenuItem->Image = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"подключениеToolStripMenuItem.Image")));
            this->подключениеToolStripMenuItem->Name = L"подключениеToolStripMenuItem";
            this->подключениеToolStripMenuItem->Size = System::Drawing::Size(152, 22);
            this->подключениеToolStripMenuItem->Text = L"Подключение";
            this->подключениеToolStripMenuItem->Click += gcnew System::EventHandler(this, &MyForm::подключениеToolStripMenuItem_Click);
            // 
            // MyForm
            // 
            this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
            this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
            this->BackColor = System::Drawing::SystemColors::ButtonHighlight;
            this->BackgroundImageLayout = System::Windows::Forms::ImageLayout::Center;
            this->ClientSize = System::Drawing::Size(831, 421);
            this->Controls->Add(this->menuStrip1);
            this->Controls->Add(this->button1);
            this->Controls->Add(this->textBox2);
            this->Controls->Add(this->textBox1);
            this->DoubleBuffered = true;
            this->Icon = (cli::safe_cast<System::Drawing::Icon^>(resources->GetObject(L"$this.Icon")));
            this->MainMenuStrip = this->menuStrip1;
            this->Name = L"MyForm";
            this->StartPosition = System::Windows::Forms::FormStartPosition::CenterScreen;
            this->Text = L"Chat v1.3";
            this->Load += gcnew System::EventHandler(this, &MyForm::MyForm_Load);
            this->menuStrip1->ResumeLayout(false);
            this->menuStrip1->PerformLayout();
            this->ResumeLayout(false);
            this->PerformLayout();
 
        }
#pragma endregion
    private: System::Void textBox1_TextChanged(System::Object^  sender, System::EventArgs^  e) {
    }
    private: System::Void label1_Click(System::Object^  sender, System::EventArgs^  e) {
    }
    private: System::Void MyForm_Load(System::Object^  sender, System::EventArgs^  e) {
    }
 
    private: System::Void textBox2_TextChanged(System::Object^  sender, System::EventArgs^  e) {
    }
    private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
                 char msgl[256];
                 for (int i = 0; i < textBox1->Text->Length; i++)
                 {
                     msgl[i] = textBox1->Text[i];
                 }
                 msgl[strlen(msgl) - 1] = '\0';
                 for (int i = 0; i < strlen(msgl); i++)
                 {
                     textBox2->Text = Convert::ToString(msgl[i]);
                 }
    }
    private: LPTHREAD_START_ROUTINE ClientHandler() {
                 char msg[256];
                 while (true)
                 {
                     recv(Connection, msg, sizeof(msg), NULL);
                     for (int i = 0; i < strlen(msg); i++)
                     {
                         textBox2->Text = Convert::ToString(msg[i]);
                     }
                 }
             }
private: System::Void numericUpDown1_ValueChanged(System::Object^  sender, System::EventArgs^  e) {
}
private: LPTHREAD_START_ROUTINE fn(){
             MyForm1^ f2 = gcnew MyForm1();
             f2->Show();
}
private: System::Void contextMenuStrip1_Opening(System::Object^  sender, System::ComponentModel::CancelEventArgs^  e) {
}
private: System::Void menuStrip1_ItemClicked(System::Object^  sender, System::Windows::Forms::ToolStripItemClickedEventArgs^  e) {
 
}
private: System::Void подключениеToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e) { 
             CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE)fn(), NULL, NULL, NULL);
             WSAData wsaData;
             WORD DLLVersion = MAKEWORD(2, 1);
             if (WSAStartup(DLLVersion, &wsaData) != 0){
                 exit(1);
             }
 
             SOCKADDR_IN addr;
             int sizeofaddr = sizeof(addr);
             addr.sin_addr.s_addr = inet_addr(ni);
             addr.sin_port = htons(*np);
             addr.sin_family = AF_INET;
 
             Connection = socket(AF_INET, SOCK_STREAM, NULL);
             if (connect(Connection, (SOCKADDR*)&addr, sizeof(addr)) != 0) {
                 exit(1);
             };
 
             send(Connection, nn, sizeof(nn), NULL);
 
             CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE)ClientHandler(), NULL, NULL, NULL);
}
};
}
0
Администратор
Эксперт .NET
 Аватар для OwenGlendower
18262 / 14187 / 5366
Регистрация: 17.03.2014
Сообщений: 28,872
Записей в блоге: 1
12.04.2021, 07:41
qwaz, этот код точно компилируется?
0
1 / 1 / 0
Регистрация: 22.12.2020
Сообщений: 140
12.04.2021, 08:22  [ТС]
Да.У меня на visual studio 2013 норм все
0
Администратор
Эксперт .NET
 Аватар для OwenGlendower
18262 / 14187 / 5366
Регистрация: 17.03.2014
Сообщений: 28,872
Записей в блоге: 1
12.04.2021, 08:48
qwaz, что-то сомневаюсь. Вы объявляете методы возвращающие LPTHREAD_START_ROUTINE, но значение не возвращается. Это должно привести к ошибке компиляции. Проверьте окно ошибок. Методы на самом деле должны возвращать void. И в метод CreateThread нужно передавать адрес метода, а не его результат.
0
1 / 1 / 0
Регистрация: 22.12.2020
Сообщений: 140
12.04.2021, 09:38  [ТС]
1>c:\users\king\desktop\программы\probni ki\ff\ff\MyForm.h(233): error C2440: приведение типов: невозможно преобразовать "overloaded-function" в "LPTHREAD_START_ROUTINE"
1> Конечному типу не соответствует ни одной функции с данным именем в области видимости
1>c:\users\king\desktop\программы\probni ki\ff\ff\MyForm.h(233): error C2660: CreateThread: функция не принимает 5 аргументов
1>c:\users\king\desktop\программы\probni ki\ff\ff\MyForm.h(259): error C2440: приведение типов: невозможно преобразовать "overloaded-function" в "LPTHREAD_START_ROUTINE"
1> Конечному типу не соответствует ни одной функции с данным именем в области видимости
1>c:\users\king\desktop\программы\probni ki\ff\ff\MyForm.h(259): error C2660: CreateThread: функция не принимает 5 аргументов
0
Администратор
Эксперт .NET
 Аватар для OwenGlendower
18262 / 14187 / 5366
Регистрация: 17.03.2014
Сообщений: 28,872
Записей в блоге: 1
12.04.2021, 09:41
qwaz, вот видите. Исправляйте ошибки.
0
1 / 1 / 0
Регистрация: 22.12.2020
Сообщений: 140
12.04.2021, 10:34  [ТС]
Эти ошибки после исправления появились
0
Надоела реклама? Зарегистрируйтесь и она исчезнет полностью.
raxper
Эксперт
30234 / 6612 / 1498
Регистрация: 28.12.2010
Сообщений: 21,154
Блог
12.04.2021, 10:34
Помогаю со студенческими работами здесь

Не прогружается JSON
URL url = new URL(&quot;http://api.vk.com/method/users.get?user_ids=durov&quot;); URLConnection urlConnection = (HttpURLConnection)...

Скрипт не прогружается
Здравствуйте! Решил реализовать одну идею ecть скрипт: myscript.php на прогрузку заказов Моя задача через cron (nano) запустить его в...

Не прогружается изображение
Вообщем суть такая, у меня есть приложение с открытым кодом, а при декомпиляции ресурсы оттуда не прогружаются, в итоге и новые картинки я...

Не прогружается background
Background перестал загружать фоновое изображение, показывает только тогда, когда захожу в режим инкогнито.

Не прогружается BIOS
Только взял себе новые комплектующие Мать: Asus F2A85-M LE Проц: AMD Trinity A8-5600K 3/6Ghz/4MB Оперативка: Corsair DDR3-1600 8192MB...


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

Или воспользуйтесь поиском по форуму:
14
Ответ Создать тему
Новые блоги и статьи
Использование SDL3-callbacks вместо функции main() на Android, Desktop и WebAssembly
8Observer8 24.01.2026
Если вы откроете примеры для начинающих на официальном репозитории SDL3 в папке: examples, то вы увидите, что все примеры используют следующие четыре обязательные функции, а привычная функция main(). . .
моя боль
iceja 24.01.2026
Выложила интерполяцию кубическими сплайнами www. iceja. net REST сервисы временно не работают, только через Web. Написала за 56 рабочих часов этот сайт с нуля. При помощи perplexity. ai PRO , при. . .
Модель сукцессии микоризы
anaschu 24.01.2026
Решили писать научную статью с неким РОманом
http://iceja.net/ математические сервисы
iceja 20.01.2026
Обновила свой сайт http:/ / iceja. net/ , приделала Fast Fourier Transform экстраполяцию сигналов. Однако предсказывает далеко не каждый сигнал (см ограничения http:/ / iceja. net/ fourier/ docs ). Также. . .
http://iceja.net/ сервер решения полиномов
iceja 18.01.2026
Выкатила http:/ / iceja. net/ сервер решения полиномов (находит действительные корни полиномов методом Штурма). На сайте документация по API, но скажу прямо VPS слабенький и 200 000 полиномов. . .
Расчёт переходных процессов в цепи постоянного тока
igorrr37 16.01.2026
/ * Дана цепь(не выше 3-го порядка) постоянного тока с элементами R, L, C, k(ключ), U, E, J. Программа находит переходные токи и напряжения на элементах схемы классическим методом(1 и 2 з-ны. . .
Восстановить юзерскрипты Greasemonkey из бэкапа браузера
damix 15.01.2026
Если восстановить из бэкапа профиль Firefox после переустановки винды, то список юзерскриптов в Greasemonkey будет пустым. Но восстановить их можно так. Для этого понадобится консольная утилита. . .
Сукцессия микоризы: основная теория в виде двух уравнений.
anaschu 11.01.2026
https:/ / rutube. ru/ video/ 7a537f578d808e67a3c6fd818a44a5c4/
КиберФорум - форум программистов, компьютерный форум, программирование
Powered by vBulletin
Copyright ©2000 - 2026, CyberForum.ru