Click here to Skip to main content
15,886,806 members
Articles / Programming Languages / C++

Getting System Local Time, Calculating UpTime, Setting an Alarm, Threading, etc.

Rate me:
Please Sign up or sign in to vote.
4.17/5 (4 votes)
6 Jan 2011CPOL1 min read 30.9K   895   17  
Getting System Local Time, Calculating UpTime, Setting an Alarm, threading, etc.
// TinyTimeDlg.h : header file
//

#pragma once
#include "afxwin.h"


// CTinyTimeDlg dialog
class CTinyTimeDlg : public CDialog
{
// Construction
public:
	CTinyTimeDlg(CWnd* pParent = NULL);	// standard constructor

// Dialog Data
	enum { IDD = IDD_TINYTIME_DIALOG };

	protected:
	virtual void DoDataExchange(CDataExchange* pDX);	// DDX/DDV support


// Implementation
protected:
	HICON m_hIcon;

	// Generated message map functions
	virtual BOOL OnInitDialog();
	afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
	afx_msg void OnPaint();
	afx_msg HCURSOR OnQueryDragIcon();
	DECLARE_MESSAGE_MAP()
public:
	afx_msg void OnBnClickedSetturnoff();
	static UINT ShutdownThread(CTinyTimeDlg* pDlg);
	UINT ShutdownThreadHandler(void);

	static UINT UpTimeShutdownThread(CTinyTimeDlg* pDlg);
	UINT UpTimeShutdownThreadHandler(void);

	static UINT AlarmThread(CTinyTimeDlg* pDlg);
	UINT AlarmThreadHandler(void);
private:
	CWinThread* m_ShutdownThread;
	CWinThread* m_UpTimeShutdownThread;
	CWinThread* m_AlarmThread;
public:
	SYSTEMTIME m_ShutdownTime;
	SYSTEMTIME m_UpTimeShutdownTime;
	SYSTEMTIME m_AlarmTime;
	afx_msg void OnBnClickedCancelturnoff();
	afx_msg void OnDestroy();
private:
	bool m_bShutdownThread;
	bool m_bUpTimeShutdownThread;
	bool m_bAlarmThread;
protected:
	virtual void OnCancel();
public:
	void ShutdownWindows(void);
	afx_msg void OnBnClickedSetturnoff2();
	afx_msg void OnBnClickedCancelturnoff2();
	afx_msg void OnBnClickedRemoveturnoff();
	afx_msg void OnBnClickedCancelshutdown();
	afx_msg void OnBnClickedCancelalarm();
	afx_msg void OnBnClickedMute();
	afx_msg void OnTimer(UINT_PTR nIDEvent);
	void CalcTime(void);
	afx_msg void OnBnClickedSetturnoff3();
	afx_msg void OnBnClickedCancelshutdown2();
};

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
President
Iran (Islamic Republic of) Iran (Islamic Republic of)
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions