How to create an alarm using C ++ Builder

Source: Internet
Author: User
How to use C ++ Builder to create an alert clock-Linux general technology-Linux programming and kernel information. All the online worms in my crush have been in the following dilemmas: When I had an appointment with a girl/boyfriend, I waited in the old place at half past seven, but crawled until late at night in front of the computer. When I reflected it, my friends had already gone to the dust, I have to spend a few more days to apologize. If you are a friend, do not follow the steps below to make a simple alarm so that you can enjoy surfing the internet with peace of mind. You only need to open this application while surfing the Internet and set the appointment time (which can also be the default. When the time is approaching, the music starts to sound. Go to the appointment.

The alarm program consists of the following components:

No. component type component name Function
1 Tlabel l_Clock_1 displays "input date"
2 TdateTimePicker dtp_Clock_1 select a date
3 Tlabel l_Clock_2 displays "input time"
4 TdateTimePacker tdp_Clock_2 select the time
5 TmediaPlayer mp_Clock playing music
6 Tbutton B _Clock_Open open again
7 Ttimer t_Clock timing Detection
8 Tbutton B _Clock_Close close the application

Screen component list

Screen component Overview

Note: The Kind attribute of dtp_Clock_1 is set to dtkDate, And the Kind attribute of dtp_Clock_2 is set to dtkTime. the FileName attribute of mp_Clock is set to any mid, wav, and avi files on the host. Set the Interval attribute of t_Clock to 10.

Event Description:

① OnTimer of t_Clock:
{
// Trigger the demo program on time
Struct date d;
Struct time t;
AnsiString thour, tmin, tsec;
Int dyear;
Int dintyear;
Int dmon, dday;
AnsiString tinthour, tintmin, tintsec;
AnsiString dintmon, dintday;
// Obtain the date of the current day
Getdate (& d );
Dyear = d. da_year;
Dday = d. da_day;
Dmon = d. da_mon;
Dintyear = StrToInt (dint. SubString (1, 2 ));
Dintmon = dint. SubString (4, 2 );
Dintday = dint. SubString (7,2 );
// Obtain the current time
Gettime (& t );
Thour = AnsiString (t. ti_hour );
Tmin = AnsiString (t. ti_min );
// Tsec = AnsiString (t. ti_sec );
// Tint = AnsiString (DateTimePicker1-> Time );
Tinthour = tint. SubString (10, 2 );
Tintmin = tint. SubString (13, 2 );
// Tintsec = tint. SubString (16, 2 );
// Alarm service function
If (StrToInt (thour) = StrToInt (tinthour ))&&
(StrToInt (tmin) = StrToInt (tintmin ))
& (StrToInt (AnsiString (dyear). SubString (3, 2 ))
= Dintyear) & (StrToInt (dmon) = StrToInt (dintmon ))
& (StrToInt (dday) = StrToInt (dintday )))
{
DTimer-> Enabled = false;
MediaPlayer1-> Open ();
MediaPlayer1-> Play ();
}
}
② B _Clock_Open OnClick:
{
T_Clock-> Enabled = true;
}
③ B _Clock_Close OnClick
{
Application-> Terminate ();
}

Of course, this program can be expanded and refined. For example, if I only detect the trigger condition, of course, it can detect the second or only the time.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.