功能点:
- 定时消息提醒
- 定时音乐提醒
- 定时关机
- 获取开机时间
截图:
源代码:
[cpp] view plain copy print ?
- #include <windows.h>
- #include <WindowsX.h>
- #include <CommCtrl.h>
- #include "resource.h"
- #include "mmsystem.h"
- #pragma comment(lib,"winmm.lib")
- #define Method_AlertMessage 50000
- #define Method_ShutDown 50001
- #define Method_AlertMusic1 50002
- #define Method_AlertMusic2 50003
- #define IDT_TIME1 101
- // Data
- HICON g_hIconLarge;
- HICON g_hIconSmall;
- BSTR g_strStarTime; //get Start Computer Time
- BSTR g_strSpaceTime; // set the alert Time
- BSTR g_strAlertMessage; //the alert message variable
- NOTIFYICONDATA g_pnid; //the notify icon data variable
- HWND g_hWndBegin, g_hWndStop, g_hWndSet,g_hWndMessage; // take turns the HWND begin, stop, set, Dialog
- HINSTANCE g_hInstance; // the instance of the Main Windows
- HWND g_hWndMain; // the HWND of the Main Windows
- int g_iSpaceTime,g_iSpaceTimeForTimer,g_iAlertMethod; //take turns is the space time, space time for Timer, alert method
- HWND hWndSetSpTime,hWndAlertMetod; // the the set Dialog two combobox HWND
- LRESULT CALLBACK DialogProc(HWND ,UINT,WPARAM,LPARAM) ;
- BOOL CALLBACK SetDlgProc(HWND ,UINT,WPARAM,LPARAM);
- void OnInitDialog(HWND hDlg);
- void WMSet(HWND hDlg); //设置
- void WMBegin(HWND hDlg); //开始
- void WMStop(HWND hDlg); //停止
- void ToOurTray(HWND hDlg); //托盘最小化
- void DeleteOurTray(HWND hDlg); //删除托盘最小化
- void ShutDown(HWND hDlg); //关机
- void AlertMessageFunc(int ); //消息提醒
- int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
- {
- g_hIconLarge = static_cast<HICON>(LoadImage(hInstance, TEXT("IDI_ICON1"), IMAGE_ICON, //set large ico
- GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CXICON), 0));
- g_hIconSmall = static_cast<HICON>(LoadImage(hInstance, TEXT("IDI_ICON1"), IMAGE_ICON, //set small ico
- GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CXSMICON), 0));
- g_hInstance = hInstance;
- MSG msg;
- HWND hwnd = CreateDialog(hInstance, MAKEINTRESOURCE(IDD_DIALOG1), NULL, (DLGPROC)DialogProc);
- g_hWndMain = hwnd;
- ShowWindow(hwnd, SW_SHOW);
- Up