예제 #1
0
파일: StopWatch.c 프로젝트: heicks/T-Clock
void StopWatch_TogglePause(HWND hDlg){
	if(m_paused){
		StopWatch_Resume(hDlg);
	}else{
		StopWatch_Pause(hDlg);
	}
}
예제 #2
0
//================================================================================================
//-----------------------------------------------------+++--> T-Clock Menu Command Message Handler:
LRESULT OnTClockCommand(HWND hwnd, WPARAM wParam)   //----------------------------------+++-->
{
	WORD wID = LOWORD(wParam);
	switch(wID) {
	case IDM_REFRESHTCLOCK:
		RefreshUs();
		break;
		
	case IDM_SHOWPROP:
		MyPropertySheet(-1);
		break;
	case IDM_PROP_ALARM:
		MyPropertySheet(1);
		break;
		
	case IDM_EXIT:
		SendMessage(hwnd,WM_CLOSE,0,0);
		break;
		
	case IDM_SHOWCALENDER:
		ToggleCalendar(1); // 1=own calendar
		break;
		
	case IDM_DISPLAYPROP:
		if(api.OS >= TOS_VISTA)
			api.Exec(L"::{26EE0668-A00A-44D7-9371-BEB064C98683}\\1\\::{C555438B-3C23-4769-A71F-B6D3D9B6053A}", NULL, NULL);
		else
			api.Exec(L"control", L"desk.cpl, display,1", NULL);
		break;
	case IDM_VOLUMECONTROL: //-------------------------------+++--> Volume Controls
		#ifndef _WIN64
		#	define OPEN_VOLUME L"SndVol32"
		#else
		#	define OPEN_VOLUME L"SndVol"
		#endif // _WIN64
		api.Exec(OPEN_VOLUME, NULL, NULL);
		break;
		
	case IDM_AUDIOPROP: //----------------------------------+++--> Audio settings / devices
		api.Exec(L"control", L"mmsys.cpl", NULL);
		break;
		
	case IDM_RECYCLEBIN:
		api.Exec(L"::{645FF040-5081-101B-9F08-00AA002F954E}", NULL, NULL);
		break;
		
	case IDM_RECYCLEBIN_PURGE:{
		SHQUERYRBINFO info = {sizeof(info)}; // Windows seriously asks :
		SHQueryRecycleBin(NULL, &info); // "are you sure to delete all items"
		if(info.i64NumItems > 0 || api.OS == TOS_2000) // when the recycle bin is actually empty...
			SHEmptyRecycleBin(g_hwndTClockMain, NULL, 0);
		break;}
		
	case IDM_MAPDRIVE: //----------------------------------+++--> Map Network Drive
		WNetConnectionDialog(hwnd, RESOURCETYPE_DISK);
		break;
		
	case IDM_DISCONNECT: //-------------------------+++--> Disconnect Network Drive
		WNetDisconnectDialog(hwnd, RESOURCETYPE_DISK);
		break;
		
	case IDM_TOGGLE_DT: //---------------------------+++--> Show / Hide the Desktop
		ToggleDesk();
		break;
		
	case IDM_QUICKY_WINEXP: { //-----------------//--+++--> Windows Explorer Opened
		api.Exec(L"Explorer", L"/e, ::{20D04FE0-3AEA-1069-A2D8-08002B30309D}", hwnd);
		break;}
		
	case IDM_QUICKY_DOS: { // Command Prompt
		api.Exec(L"cmd", L"/f:on /t:0a", hwnd);
		break;}
		
	case IDM_QUICKY_EMPTYRB:
		SHEmptyRecycleBin(0, NULL, SHERB_NOCONFIRMATION);
		break;
		
	case IDM_SHUTDOWN:
		if(!ShutDown())
			MessageBox(0, L"Shutdown Request Failed!", L"ERROR", MB_OK|MB_ICONERROR|MB_SETFOREGROUND);
		break;
		
	case IDM_REBOOT:
		if(!ReBoot())
			MessageBox(0, L"Reboot Request Failed!", L"ERROR", MB_OK|MB_ICONERROR|MB_SETFOREGROUND);
		break;
		
	case IDM_LOGOFF:
		if(!LogOff())
			MessageBox(0, L"Logoff Request Failed!", L"ERROR", MB_OK|MB_ICONERROR|MB_SETFOREGROUND);
		break;
		
	case IDM_FWD_CASCADE: case IDM_FWD_SIDEBYSIDE: case IDM_FWD_STACKED: case IDM_FWD_SHOWDESKTOP: case IDM_FWD_MINALL: case IDM_FWD_UNDO:
		g_undo=(wID!=IDM_FWD_UNDO);
		/* fall through */
	case IDM_FWD_DATETIME: case IDM_FWD_CUSTOMNOTIFYICONS:
	case IDM_FWD_TASKMAN:
	case IDM_FWD_LOCKTASKBAR: case IDM_FWD_LOCKALLTASKBAR:
	case IDM_FWD_TASKBARPROP: case IDM_FWD_RUNAPP: case IDM_FWD_EXITEXPLORER:{
		HWND hwndTray = FindWindowA("Shell_TrayWnd", NULL);
		if(hwndTray) PostMessage(hwndTray, WM_COMMAND, wID, 0);
		break;}
	case IDM_DATETIME_EX:{
		HWND hwnd1, hwnd2;
		int wait = 40;
		api.Exec(L"timedate.cpl", L"", 0);
		while((hwnd2=FindWindowA((char*)(uintptr_t)32770,"Date and Time"))==0 && wait--) Sleep(50);
		if(hwnd2){
			SetActiveWindow(hwnd2);
			wait = 10;
			while((hwnd1=FindWindowExA(hwnd2,NULL,(char*)(uintptr_t)32770,"Date and Time"))==0 && wait--) Sleep(50);
			if(hwnd1){
				hwnd2 = GetDlgItem(hwnd1,116);
				if(hwnd2) PostMessage(hwnd2,BM_CLICK,0,0);
			}
		}
		break;}
		
	case IDM_CHIME: /// Alarms
		AlarmChimeEnable(-1);
		break;
		
	case IDM_STOPWATCH: /// Timers
		DialogStopWatch();
		break;
	case IDM_STOPWATCH_START:
	case IDM_STOPWATCH_RESUME:
		if(!IsWindow(g_hDlgStopWatch))
			DialogStopWatch();
		StopWatch_Resume(g_hDlgStopWatch);
		break;
	case IDM_STOPWATCH_STOP:
	case IDM_STOPWATCH_PAUSE:
		if(IsWindow(g_hDlgStopWatch))
			StopWatch_Pause(g_hDlgStopWatch);
		break;
	case IDM_STOPWATCH_RESET:
		if(IsWindow(g_hDlgStopWatch))
			StopWatch_Reset(g_hDlgStopWatch);
		break;
	case IDM_STOPWATCH_LAP:
		if(IsWindow(g_hDlgStopWatch))
			StopWatch_Lap(g_hDlgStopWatch,0);
		break;
	case IDM_TIMER:
		DialogTimer(0);
		break;
	case IDM_TIMEWATCH:
		WatchTimer(0); // Shelter All the Homeless Timers.
		break;
	case IDM_TIMEWATCHRESET:
		WatchTimer(1); // Shelter All the Homeless Timers.
		break;
	case IDM_SNTP:{
		short just_elevated = HIWORD(wParam);
		if(!just_elevated || HaveSetTimePermissions()) {
			ReplyMessage(1);
			NetTimeConfigDialog(0);
			return 1; // handled
		} else {
			if(IsWindow(g_hDlgSNTP))
				SendMessage(g_hDlgSNTP, WM_CLOSE, 1, 0); // close window but safe changes
		}
		return 0;}
	case IDM_SYNCTIME:
	case IDM_SNTP_SYNC:{
		short just_elevated = HIWORD(wParam);
		int can_sync = HaveSetTimePermissions();
		if(!just_elevated || can_sync) {
			ReplyMessage(1);
			if(can_sync) {
				SyncTimeNow();
			} else {
				if(api.ExecElevated(GetClockExe(),L"/UAC /Sync",NULL) != 0) {
					MessageBox(0, L"T-Clock must be elevated to set your system time,\nbut elevation was canceled", L"Time Sync Failed", MB_OK|MB_ICONERROR|MB_SETFOREGROUND);
				}
			}
			return 1; // handled
		}
		return 0;}
	default:
		#ifdef _DEBUG
		DBGOUT("%s: unknown ID: %.5i(0x%.4x) (hwnd:%p)", __FUNCTION__, wID, wID, hwnd);
		#endif // _DEBUG
		break;
	}
	return 0;
}