In the dialog box, the edit box ID is idc_time and the associated variable is m_time of cstring.
Add code in oninitdialog:
Cstring strtime;
Ctime TM;
TM = ctime: getcurrenttime (); // get the current system time
Strtime = TM. Format ("% Y % m % d % x"); // format the system time. Even if the system time is displayed in the format set in the format
Setdlgitemtext (idc_time, strtime); // The initialization edit box is displayed.
Settimer (, null); // start the timer
Add the wm_timer message processing function to the dialog box and add the following code:
Cstring strtime;
Ctime TM;
TM = ctime: getcurrenttime ();
Strtime = TM. Format ("% Y-% m-% d % H: % m: % s ");
Setdlgitemtext (idc_time, strtime); // display the system time
The running result of the above program section is: June 25 10:10:10
Other time styles: (content between "" in the format brackets)
1. "% Y % m % d % x" Y: 2009 Y: 09 m: 06 D: 05
2. "% C": 06/25/09 10:10:10