/**************************************************************************\ * * * ROUTINE: AlarmDlgProc ( ) * * * * COMMENT: "Alarm..." dialog * * * * RETURNS: MRESULT, 0 or return value from WinDefDlgProc * * * \**************************************************************************/ MRESULT EXPENTRY AlarmDlgProc(HWND hwnd, ULONG usMsg, MPARAM mp1, MPARAM mp2) { switch (usMsg) { case WM_INITDLG: hAlarmTime = hwnd; /* Put in a global variable so all functions know we have already have an opened dialog box. */ InitAlarm(hwnd); break; case WM_COMMAND: switch (LOUSHORT(mp1)) { case DID_OK: AlarmSet(hwnd); case DID_CANCEL: hAlarmTime = NULLHANDLE; WinDismissDlg(hwnd, TRUE); } return NULL; case WM_CONTROL: break; case WM_VSCROLL: AlarmVScrolls(hwnd, HIUSHORT(mp2), mp1); break; } return WinDefDlgProc(hwnd, usMsg, mp1, mp2); }
/*------------------------------------------------ apply - save settings --------------------------------------------------*/ void OnApply(HWND hDlg) { int i, count, n_autoexec; PAUTOEXECSTRUCT pAS; n_autoexec = 0; if(curAutoExec < 0) { char name[40]; GetDlgItemText(hDlg, IDC_COMBOAUTOEXEC, name, 40); if(name[0] && IsDlgButtonChecked(hDlg, IDC_AUTOEXEC)) { pAS = malloc(sizeof(AUTOEXECSTRUCT)); if(pAS) { int index; GetAutoExecFromDlg(hDlg, pAS); index = CBAddString(hDlg, IDC_COMBOAUTOEXEC, (LPARAM)pAS->name); CBSetItemData(hDlg, IDC_COMBOAUTOEXEC, index, (LPARAM)pAS); curAutoExec = index; CBSetCurSel(hDlg, IDC_COMBOAUTOEXEC, index); EnableDlgItem(hDlg, IDC_DELAUTOEXEC, TRUE); } } } else { pAS = (PAUTOEXECSTRUCT)CBGetItemData(hDlg, IDC_COMBOAUTOEXEC, curAutoExec); if(pAS) GetAutoExecFromDlg(hDlg, pAS); } count = CBGetCount(hDlg, IDC_COMBOAUTOEXEC); for(i = 0; i < count; i++) { PAUTOEXECSTRUCT pAS; pAS = (PAUTOEXECSTRUCT)CBGetItemData(hDlg, IDC_COMBOAUTOEXEC, i); if(pAS) { SaveAutoExecToReg(pAS, n_autoexec); n_autoexec++; } } for(i = n_autoexec; ; i++) { char subkey[20]; wsprintf(subkey, "AutoExec%d", i + 1); if(GetMyRegLong(subkey, "Hour", -1) >= 0) DelMyRegKey(subkey); else break; } SetMyRegLong("", "AutoExecNum", n_autoexec); InitAlarm(); // alarm.c }
int main( void ) { InitVFD(); InitISD(); InitI2C(); InitADC(); InitRTC(); InitDS75(); InitKeys(); InitUART(); InitRFM(); InitAlarm(); sei(); wdt_enable(WDT_DEFAULT); UI(); return 0; }
//================================================================================================ //--------------------------------------------------+++--> The Main Application "Window" Procedure: LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) //--------+++--> { switch(message) { case WM_CREATE: InitAlarm(); // initialize alarms SetTimer(hwnd, IDTIMER_MAIN, 1000, NULL); InjectClockHook(hwnd); return 0; case WM_TIMER: if(wParam == IDTIMER_MAIN) OnTimerMain(hwnd); else if(wParam == IDTIMER_MOUSE) OnTimerMouse(hwnd); return 0; case WM_ENDSESSION: if(!wParam) break; /* fall through */ case WM_DESTROY: KillTimer(hwnd, IDTIMER_MAIN); if(g_hwndSheet && IsWindow(g_hwndSheet)) SendMessage(g_hwndSheet, WM_CLOSE, 0, 0); if(g_hDlgTimer && IsWindow(g_hDlgTimer)) SendMessage(g_hDlgTimer, WM_CLOSE, 0, 0); if(g_hDlgStopWatch && IsWindow(g_hDlgStopWatch)) SendMessage(g_hDlgStopWatch, WM_CLOSE, 0, 0); g_hwndSheet = g_hDlgTimer = g_hDlgStopWatch = NULL; EndAlarm(); EndAllTimers(); api.Exit(); // exit clock, remove injection if(message!=WM_ENDSESSION) PostQuitMessage(0); return 0; case WM_PAINT: { // HDC hdc; // PAINTSTRUCT ps; // hdc = BeginPaint(hwnd, &ps); // EndPaint(hwnd, &ps); return 0;} case WM_HOTKEY: // Feature Requested From eweoma at DonationCoder.com switch(wParam) { // And a Damn Fine Request it Was... :-) case HOT_WATCH: PostMessage(hwnd, WM_COMMAND, IDM_TIMEWATCH, 0); return 0; case HOT_TIMER: PostMessage(hwnd, WM_COMMAND, IDM_TIMER, 0); return 0; case HOT_STOPW: PostMessage(hwnd, WM_COMMAND, IDM_STOPWATCH, 0); return 0; case HOT_PROPR: PostMessage(hwnd, WM_COMMAND, IDM_SHOWPROP, 0); return 0; case HOT_CALEN: PostMessage(hwnd, WM_COMMAND, IDM_SHOWCALENDER, 0); return 0; case HOT_TSYNC: SyncTimeNow(); return 0; } return 0; //================================================== case MAINM_CLOCKINIT: // Messages sent/posted from TCDLL.dll g_hwndClock = (HWND)lParam; api.InjectFinalize(); // injected, now remove hook return 0; case MAINM_ERROR: // error InitError((int)lParam); SendMessage(hwnd, WM_CLOSE, 0, 0); return 0; case MAINM_EXIT: // exit SendMessage(hwnd, WM_CLOSE, 0, 0); return 0; case MAINM_BLINKOFF: // clock no longer blinks if(!g_bPlayingNonstop) StopFile(); return 0; case MM_MCINOTIFY: // stop playing or repeat mci file (all but .wav, .pcb) OnMCINotify(hwnd); return 0; case MM_WOM_DONE: // stop playing wave case MAINM_STOPSOUND: StopFile(); return 0; case WM_WININICHANGE: RefreshUs(); return 0; // inform clock about DWM color change case WM_DWMCOLORIZATIONCOLORCHANGED: api.On_DWMCOLORIZATIONCOLORCHANGED((unsigned)wParam, (BOOL)lParam); PostMessage(g_hwndClock, WM_DWMCOLORIZATIONCOLORCHANGED, wParam, lParam); return 0; // context menu case WM_COMMAND: OnTClockCommand(hwnd, LOWORD(wParam)); // menu.c return 0; case WM_LBUTTONDOWN: case WM_RBUTTONDOWN: case WM_MBUTTONDOWN: case WM_XBUTTONDOWN: if(!g_bPlayingNonstop) PostMessage(hwnd, MAINM_STOPSOUND, 0, 0); /* fall through */ case WM_LBUTTONUP: case WM_RBUTTONUP: case WM_MBUTTONUP: case WM_XBUTTONUP: OnMouseMsg(hwnd, message, wParam, lParam); // mouse.c return 0; case WM_WTSSESSION_CHANGE: switch(wParam) { case WTS_SESSION_LOCK: Sleep(500); // Eliminate user's interaction for 500 ms SendMessage(HWND_BROADCAST_nowarn, WM_SYSCOMMAND,SC_MONITORPOWER, 2); return 0; } break; default: if(message == g_WM_TaskbarCreated){ InjectClockHook(hwnd); } } return DefWindowProc(hwnd, message, wParam, lParam); }