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

Будильник, несколько сигналов по кнопке

25.04.2014, 00:18. Показов 659. Ответов 0
Метки нет (Все метки)

Студворк — интернет-сервис помощи студентам
Доброго времени суток,
Подскажите пожалуйста, вот я сделал будильник,хотелось бы добавить несколько сигналов по кнопке, но не представляю как сделать.
Заранее спасибо)
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
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
#pragma once
 
namespace Будильник {
 
    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>
    /// Сводка для Form1
    /// </summary>
    public ref class Form1 : public System::Windows::Forms::Form
    {
    public:
        Form1(void)
        {
            InitializeComponent();
            //
            //TODO: добавьте код конструктора
            //
        }
 
    protected:
        /// <summary>
        /// Освободить все используемые ресурсы.
        /// </summary>
        ~Form1()
        {
            if (components)
            {
                delete components;
            }
        }
    private: System::Windows::Forms::TabControl^  tabControl1;
    protected:
    private: System::Windows::Forms::TabPage^  tabPage1;
    private: System::Windows::Forms::Button^  button4;
    private: System::Windows::Forms::Button^  button3;
    private: System::Windows::Forms::Label^  label3;
    private: System::Windows::Forms::Button^  button2;
    private: System::Windows::Forms::Label^  label2;
    private: System::Windows::Forms::Button^  button1;
    private: System::Windows::Forms::NumericUpDown^  numericUpDown2;
    private: System::Windows::Forms::NumericUpDown^  numericUpDown1;
    private: System::Windows::Forms::Label^  label1;
    private: System::Windows::Forms::TabPage^  tabPage2;
    private: System::Windows::Forms::OpenFileDialog^  openFileDialog1;
    private: System::Windows::Forms::NotifyIcon^  notifyIcon1;
    private: System::Windows::Forms::Timer^  timer1;
 
    protected:
 
 
 
 
 
 
 
 
 
 
 
 
    protected:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
    protected: 
 
 
 
 
 
 
 
 
 
 
 
 
    private: System::ComponentModel::IContainer^  components;
 
    private:
        /// <summary>
        /// Требуется переменная конструктора.
        /// </summary>
 
 
#pragma region Windows Form Designer generated code
        /// <summary>
        /// Обязательный метод для поддержки конструктора - не изменяйте
        /// содержимое данного метода при помощи редактора кода.
        /// </summary>
        void InitializeComponent(void)
        {
            this->components = (gcnew System::ComponentModel::Container());
            System::ComponentModel::ComponentResourceManager^  resources = (gcnew System::ComponentModel::ComponentResourceManager(Form1::typeid));
            this->tabControl1 = (gcnew System::Windows::Forms::TabControl());
            this->tabPage1 = (gcnew System::Windows::Forms::TabPage());
            this->button4 = (gcnew System::Windows::Forms::Button());
            this->button3 = (gcnew System::Windows::Forms::Button());
            this->label3 = (gcnew System::Windows::Forms::Label());
            this->button2 = (gcnew System::Windows::Forms::Button());
            this->label2 = (gcnew System::Windows::Forms::Label());
            this->button1 = (gcnew System::Windows::Forms::Button());
            this->numericUpDown2 = (gcnew System::Windows::Forms::NumericUpDown());
            this->numericUpDown1 = (gcnew System::Windows::Forms::NumericUpDown());
            this->label1 = (gcnew System::Windows::Forms::Label());
            this->tabPage2 = (gcnew System::Windows::Forms::TabPage());
            this->openFileDialog1 = (gcnew System::Windows::Forms::OpenFileDialog());
            this->notifyIcon1 = (gcnew System::Windows::Forms::NotifyIcon(this->components));
            this->timer1 = (gcnew System::Windows::Forms::Timer(this->components));
            this->tabControl1->SuspendLayout();
            this->tabPage1->SuspendLayout();
            (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->numericUpDown2))->BeginInit();
            (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->numericUpDown1))->BeginInit();
            this->SuspendLayout();
            // 
            // tabControl1
            // 
            this->tabControl1->Controls->Add(this->tabPage1);
            this->tabControl1->Controls->Add(this->tabPage2);
            this->tabControl1->Location = System::Drawing::Point(12, 12);
            this->tabControl1->Name = L"tabControl1";
            this->tabControl1->SelectedIndex = 0;
            this->tabControl1->Size = System::Drawing::Size(137, 281);
            this->tabControl1->TabIndex = 0;
            // 
            // tabPage1
            // 
            this->tabPage1->Controls->Add(this->button4);
            this->tabPage1->Controls->Add(this->button3);
            this->tabPage1->Controls->Add(this->label3);
            this->tabPage1->Controls->Add(this->button2);
            this->tabPage1->Controls->Add(this->label2);
            this->tabPage1->Controls->Add(this->button1);
            this->tabPage1->Controls->Add(this->numericUpDown2);
            this->tabPage1->Controls->Add(this->numericUpDown1);
            this->tabPage1->Controls->Add(this->label1);
            this->tabPage1->Location = System::Drawing::Point(4, 22);
            this->tabPage1->Name = L"tabPage1";
            this->tabPage1->Padding = System::Windows::Forms::Padding(3);
            this->tabPage1->Size = System::Drawing::Size(129, 255);
            this->tabPage1->TabIndex = 0;
            this->tabPage1->Text = L"tabPage1";
            this->tabPage1->UseVisualStyleBackColor = true;
            // 
            // button4
            // 
            this->button4->Location = System::Drawing::Point(9, 161);
            this->button4->Name = L"button4";
            this->button4->Size = System::Drawing::Size(106, 23);
            this->button4->TabIndex = 18;
            this->button4->Text = L"Воспроизвести";
            this->button4->UseVisualStyleBackColor = true;
            this->button4->Click += gcnew System::EventHandler(this, &Form1::button4_Click_1);
            // 
            // button3
            // 
            this->button3->Location = System::Drawing::Point(9, 190);
            this->button3->Name = L"button3";
            this->button3->Size = System::Drawing::Size(106, 23);
            this->button3->TabIndex = 17;
            this->button3->Text = L"Остановить";
            this->button3->UseVisualStyleBackColor = true;
            this->button3->Click += gcnew System::EventHandler(this, &Form1::button3_Click_1);
            // 
            // label3
            // 
            this->label3->AutoSize = true;
            this->label3->Location = System::Drawing::Point(6, 63);
            this->label3->Name = L"label3";
            this->label3->Size = System::Drawing::Size(35, 13);
            this->label3->TabIndex = 16;
            this->label3->Text = L"label3";
            // 
            // button2
            // 
            this->button2->Location = System::Drawing::Point(9, 219);
            this->button2->Name = L"button2";
            this->button2->Size = System::Drawing::Size(106, 23);
            this->button2->TabIndex = 15;
            this->button2->Text = L"В трей";
            this->button2->UseVisualStyleBackColor = true;
            this->button2->Click += gcnew System::EventHandler(this, &Form1::button2_Click_1);
            // 
            // label2
            // 
            this->label2->AutoSize = true;
            this->label2->Location = System::Drawing::Point(6, 38);
            this->label2->Name = L"label2";
            this->label2->Size = System::Drawing::Size(35, 13);
            this->label2->TabIndex = 14;
            this->label2->Text = L"label2";
            // 
            // button1
            // 
            this->button1->Location = System::Drawing::Point(9, 132);
            this->button1->Name = L"button1";
            this->button1->Size = System::Drawing::Size(106, 23);
            this->button1->TabIndex = 13;
            this->button1->Text = L"Установить";
            this->button1->UseVisualStyleBackColor = true;
            this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click_1);
            // 
            // numericUpDown2
            // 
            this->numericUpDown2->Location = System::Drawing::Point(65, 106);
            this->numericUpDown2->Name = L"numericUpDown2";
            this->numericUpDown2->Size = System::Drawing::Size(50, 20);
            this->numericUpDown2->TabIndex = 12;
            // 
            // numericUpDown1
            // 
            this->numericUpDown1->Location = System::Drawing::Point(9, 106);
            this->numericUpDown1->Name = L"numericUpDown1";
            this->numericUpDown1->Size = System::Drawing::Size(50, 20);
            this->numericUpDown1->TabIndex = 11;
            // 
            // label1
            // 
            this->label1->AutoSize = true;
            this->label1->Location = System::Drawing::Point(6, 15);
            this->label1->Name = L"label1";
            this->label1->Size = System::Drawing::Size(35, 13);
            this->label1->TabIndex = 10;
            this->label1->Text = L"label1";
            // 
            // tabPage2
            // 
            this->tabPage2->Location = System::Drawing::Point(4, 22);
            this->tabPage2->Name = L"tabPage2";
            this->tabPage2->Padding = System::Windows::Forms::Padding(3);
            this->tabPage2->Size = System::Drawing::Size(443, 341);
            this->tabPage2->TabIndex = 1;
            this->tabPage2->Text = L"tabPage2";
            this->tabPage2->UseVisualStyleBackColor = true;
            // 
            // openFileDialog1
            // 
            this->openFileDialog1->FileName = L"openFileDialog1";
            this->openFileDialog1->FileOk += gcnew System::ComponentModel::CancelEventHandler(this, &Form1::openFileDialog1_FileOk_1);
            // 
            // notifyIcon1
            // 
            this->notifyIcon1->Icon = (cli::safe_cast<System::Drawing::Icon^>(resources->GetObject(L"notifyIcon1.Icon")));
            this->notifyIcon1->Text = L"notifyIcon1";
            this->notifyIcon1->Visible = true;
            this->notifyIcon1->MouseDoubleClick += gcnew System::Windows::Forms::MouseEventHandler(this, &Form1::notifyIcon1_MouseDoubleClick);
            // 
            // timer1
            // 
            this->timer1->Enabled = true;
            this->timer1->Interval = 1000;
            this->timer1->Tick += gcnew System::EventHandler(this, &Form1::timer1_Tick_1);
            // 
            // Form1
            // 
            this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
            this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
            this->ClientSize = System::Drawing::Size(163, 303);
            this->Controls->Add(this->tabControl1);
            this->Name = L"Form1";
            this->Text = L"Будильник";
            this->Load += gcnew System::EventHandler(this, &Form1::Form1_Load);
            this->tabControl1->ResumeLayout(false);
            this->tabPage1->ResumeLayout(false);
            this->tabPage1->PerformLayout();
            (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->numericUpDown2))->EndInit();
            (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->numericUpDown1))->EndInit();
            this->ResumeLayout(false);
 
        }
#pragma endregion
            static bool up;
            DateTime needtime;
            WMPLib::WindowsMediaPlayer^player;
            bool canPlay;
            bool isPlay;
    private: System::Void Form1_Load(System::Object^  sender, System::EventArgs^  e) {
                 canPlay = false;
                 isPlay = false;
                 player= gcnew WMPLib::WindowsMediaPlayer();
                 numericUpDown1->Maximum = 23;
                 numericUpDown1->Minimum = 0;
                 numericUpDown2->Maximum = 59;
                 numericUpDown2->Minimum = 0;
                 numericUpDown1->Value = DateTime::Now.Hour;
                 numericUpDown2->Value = DateTime::Now.Minute + 5;
                 label1->Text = DateTime::Now.ToLongTimeString();   
                 if (numericUpDown2->Value > 59){
                     numericUpDown1->Value += 1;
                     numericUpDown2->Value = 60 - DateTime::Now.Minute + 5;
                 }
 
                 notifyIcon1->Visible = false;
                 //isSet = false;
                 timer1->Interval = 1000;
                 timer1->Enabled = true;
                 needtime = DateTime(DateTime::Now.Year ,DateTime::Now.Month,DateTime::Now.Day,Convert::ToInt16(numericUpDown1->Value),Convert::ToInt16(numericUpDown2->Value), 0, 0);
                 
             }
             void Up(){
                 if (!up){
                label3->Text="Звенит";
                player->settings->volume=50;
                player->controls->play();
                up=true; 
                this->Show(); 
                notifyIcon1->Visible = false;
                 }
             }
    private: System::Void timer1_Tick(System::Object^  sender, System::EventArgs^  e) {
                 label2->Text= "" +needtime;
                 label1->Text = ""+DateTime::Now.Day +"."+ DateTime::Now.Month +"."+ DateTime::Now.Year +" "+ DateTime::Now.ToLongTimeString();
            if (DateTime::Now >= needtime){
                Up();
             }
 
             }
             
private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
             openFileDialog1->ShowDialog();
         }
private: System::Void button2_Click(System::Object^  sender, System::EventArgs^  e) {
             this->Hide();
             notifyIcon1->Visible = true;
              notifyIcon1->Text = "Будильник - " + needtime.ToShortTimeString();
         }
private: System::Void notifyIcon1_DoubleClick(System::Object^  sender, System::EventArgs^  e) {
             this->Show(); 
             notifyIcon1->Visible = false; 
         }
private: System::Void button3_Click(System::Object^  sender, System::EventArgs^  e) {
             if (up){
             player->controls->stop();
             label3->Text = "Остановлен";
             }
         }
private: System::Void openFileDialog1_FileOk(System::Object^  sender, System::ComponentModel::CancelEventArgs^  e) {
             player->URL=openFileDialog1->FileName;
             player->controls->stop();
             needtime = DateTime(DateTime::Now.Year ,DateTime::Now.Month,DateTime::Now.Day,Convert::ToInt16(numericUpDown1->Value),Convert::ToInt16(numericUpDown2->Value), 0, 0);
 
                 if (DateTime::Compare(DateTime::Now, needtime) > 0)
                     needtime = needtime.AddDays(1);
 
                 notifyIcon1->Text = "Будильник - " + needtime.ToShortTimeString();
                 canPlay = true;
         }
private: System::Void button4_Click(System::Object^  sender, System::EventArgs^  e) {
             if(canPlay)
             {
                 if(isPlay)
                 {
                     button4->Text = "Воспроизвести";
                     player->controls->stop();
                 }
                 else
                 {
                     button4->Text = "Стоп";
                     player->controls->play();
                 }
                 isPlay = !isPlay;
             }
         }
private: System::Void button1_Click_1(System::Object^  sender, System::EventArgs^  e) {
             openFileDialog1->ShowDialog();
}
private: System::Void timer1_Tick_1(System::Object^  sender, System::EventArgs^  e) {
             label2->Text = "" + needtime;
             label1->Text = "" + DateTime::Now.Day + "." + DateTime::Now.Month + "." + DateTime::Now.Year + " " + DateTime::Now.ToLongTimeString();
             if (DateTime::Now >= needtime)
             {
                 Up();
             }
}
private: System::Void openFileDialog1_FileOk_1(System::Object^  sender, System::ComponentModel::CancelEventArgs^  e) {
             player->URL = openFileDialog1->FileName;
             player->controls->stop();
             needtime = DateTime(DateTime::Now.Year, DateTime::Now.Month, DateTime::Now.Day, Convert::ToInt16(numericUpDown1->Value), Convert::ToInt16(numericUpDown2->Value), 0, 0);
 
             if (DateTime::Compare(DateTime::Now, needtime) > 0)
                 needtime = needtime.AddDays(1);
 
             notifyIcon1->Text = "Будильник - " + needtime.ToShortTimeString();
             canPlay = true;
}
private: System::Void button4_Click_1(System::Object^  sender, System::EventArgs^  e) {
             if (canPlay)
             {
                 if (isPlay)
                 {
                     button4->Text = "Воспроизвести";
                     player->controls->stop();
                 }
                 else
                 {
                     button4->Text = "Стоп";
                     player->controls->play();
                 }
                 isPlay = !isPlay;
             }
}
private: System::Void button3_Click_1(System::Object^  sender, System::EventArgs^  e) {
             if (up)
             {
                 player->controls->stop();
                 label3->Text = "Остановлен";
             }
}
private: System::Void button2_Click_1(System::Object^  sender, System::EventArgs^  e) {
             this->Hide();
             notifyIcon1->Visible = true;
             notifyIcon1->Text = "Будильник - " + needtime.ToShortTimeString();
}
private: System::Void notifyIcon1_MouseDoubleClick(System::Object^  sender, System::Windows::Forms::MouseEventArgs^  e) {
             this->Show();
             notifyIcon1->Visible = false;
}
};
}
0
Programming
Эксперт
39485 / 9562 / 3019
Регистрация: 12.04.2006
Сообщений: 41,671
Блог
25.04.2014, 00:18
Ответы с готовыми решениями:

Несколько звуковых сигналов спикера при включении ПК
Когда включаю комп слышен единый сигнал биоса(как и должно быть) а через несколько секунд издаются многоразовые короткие пикси, то ли в...

Несколько надписей на кнопке
Можно ли добавить на кнопку многострочный текст с разными шрифтами/размером?

Несколько надписей на кнопке
Хочу добавить несколько надписей поверх кнопки, но не знаю как это сделать. Надписи должны быть поверх кнопки, так, чтобы они не...

0
Надоела реклама? Зарегистрируйтесь и она исчезнет полностью.
inter-admin
Эксперт
29715 / 6470 / 2152
Регистрация: 06.03.2009
Сообщений: 28,500
Блог
25.04.2014, 00:18
Помогаю со студенческими работами здесь

Несколько действий на одной кнопке
Как на одну кнопку (Button) задать несколько действий? По типу play/pause? Всем спасибо.

Щелкаем по одной кнопке - выполняются несколько процедур.
Можно ли, и как правильно, если одним событием, нажптием на одну кнопку, (Private Sub Кнопка0_Click()), надо выполнить одновременно...

подскажите как сделать несколько видов сортировок на одной кнопке
Есть массив, состоящий из списка Авторов, нужно сделать сортировку этого массива в алфавитном порядке по убыванию и по возрастанию, и обе...

Выбрать один или несколько CheckBox одновременно и по кнопке запустить определенные батники
есть 5 CheckBox'ов. 1 - запустить 1 батник 2 - запустить 2 батник 3 - запустить 3 батник 4 - запустить 4 батник 5 - отметить все...

Построить временные диаграммы выходных сигналов триггеров для заданных входных сигналов
1 задание. Построить временную диаграмму выходных сигналов T-триггера при заданных входных сигналах, если записана 1 2 задание. Построить...


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

Или воспользуйтесь поиском по форуму:
1
Ответ Создать тему
Новые блоги и статьи
Оттенки серого
Argus19 18.03.2026
Оттенки серого Нашёл в интернете 3 прекрасных модуля: Модуль класса открытия диалога открытия/ сохранения файла на Win32 API; Модуль класса быстрого перекодирования цветного изображения в оттенки. . .
SDL3 для Desktop (MinGW): Рисуем цветные прямоугольники с помощью рисовальщика SDL3 на Си и C++
8Observer8 17.03.2026
Содержание блога Финальные проекты на Си и на C++: finish-rectangles-sdl3-c. zip finish-rectangles-sdl3-cpp. zip
Символические и жёсткие ссылки в Linux.
algri14 15.03.2026
Существует два типа ссылок — символические и жёсткие. Ссылка в Linux — это запись в каталоге, которая может указывать либо на inode «файла-ИСТОЧНИКА», тогда это будет «жёсткая ссылка» (hard link),. . .
[Owen Logic] Поддержание уровня воды в резервуаре количеством включённых насосов: моделирование и выбор регулятора
ФедосеевПавел 14.03.2026
Поддержание уровня воды в резервуаре количеством включённых насосов: моделирование и выбор регулятора ВВЕДЕНИЕ Выполняя задание на управление насосной группой заполнения резервуара,. . .
делаю науч статью по влиянию грибов на сукцессию
anaschu 13.03.2026
прикрепляю статью
SDL3 для Desktop (MinGW): Создаём пустое окно с нуля для 2D-графики на SDL3, Си и C++
8Observer8 10.03.2026
Содержание блога Финальные проекты на Си и на C++: hello-sdl3-c. zip hello-sdl3-cpp. zip Результат:
Установка CMake и MinGW 13.1 для сборки С и C++ приложений из консоли и из Qt Creator в EXE
8Observer8 10.03.2026
Содержание блога MinGW - это коллекция инструментов для сборки приложений в EXE. CMake - это система сборки приложений. Здесь описаны базовые шаги для старта программирования с помощью CMake и. . .
Как дизайн сайта влияет на конверсию: 7 решений, которые реально повышают заявки
Neotwalker 08.03.2026
Многие до сих пор воспринимают дизайн сайта как “красивую оболочку”. На практике всё иначе: дизайн напрямую влияет на то, оставит человек заявку или уйдёт через несколько секунд. Даже если у вас. . .
КиберФорум - форум программистов, компьютерный форум, программирование
Powered by vBulletin
Copyright ©2000 - 2026, CyberForum.ru