示例#1
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;
}
示例#2
0
void __cdecl main()
{
	int screenshot = 0;
	InitialiseD3D();
	g_pGamePads = new c_GamePads();
	g_pWorld = new c_World(g_pD3DDevice, g_pGamePads);

	D3DVIEWPORT8 viewport;

	viewport.Height = 5000;
	viewport.Width = 5000;
	viewport.X = 0;
	viewport.Y = 0;
	viewport.MinZ = 0.0f;
	viewport.MaxZ = 1.0f;

	DWORD WinnerColor = D3DCOLOR_XRGB(0, 0, 100);


	g_pWorld->pPlayer[0]->Dead = 1;
	g_pWorld->pPlayer[1]->Dead = 1;

	//DWORD musicresult = 0;
	//CWMAFileStream music;
	//music.Initialize("D:\\song1.wma");


	//XVideo video;

	//video.LoadVideo("D:\\test.xmv");
	//video.PlayVideo();

	if(g_pWorld->pPlayer[0]->Dead != 0 && g_pWorld->pPlayer[1]->Dead != 0)
	{
		WinnerColor = D3DCOLOR_XRGB(150, 0, 0);
		g_pWorld->pPlayer[0]->Dead = 0;
		g_pWorld->pPlayer[0]->TransX = 2.5f;
		g_pWorld->pPlayer[0]->TransY = 5.0f;
		g_pWorld->pPlayer[0]->Theta = 3.1415f/2.0f;
		g_pWorld->pPlayer[0]->Phi = 3.1415f/2.0f;
		g_pWorld->pPlayer[0]->Firing = 0;


		g_pWorld->pPlayer[1]->Dead = 0;
		g_pWorld->pPlayer[1]->TransX = 2.5f;
		g_pWorld->pPlayer[1]->TransY = 80.0f - 5.0f;
		g_pWorld->pPlayer[1]->Theta = -3.1415f/2.0f;
		g_pWorld->pPlayer[1]->Phi = 3.1415f/2.0f;
		g_pWorld->pPlayer[1]->Firing = 0;

		g_pWorld->pPlayer[2]->Dead = 0;
		g_pWorld->pPlayer[2]->TransX = 180.0f - 2.5f;
		g_pWorld->pPlayer[2]->TransY = 5.0f;
		g_pWorld->pPlayer[2]->Theta = 3.1415f/2.0f;
		g_pWorld->pPlayer[2]->Phi = 3.1415f/2.0f;
		g_pWorld->pPlayer[2]->Firing = 0;

		g_pWorld->pPlayer[3]->Dead = 0;
		g_pWorld->pPlayer[3]->TransX = 180.0f - 2.5f;
		g_pWorld->pPlayer[3]->TransY = 80.0f - 5.0f;
		g_pWorld->pPlayer[3]->Theta = -3.1415f/2.0f;
		g_pWorld->pPlayer[3]->Phi = 3.1415f/2.0f;
		g_pWorld->pPlayer[3]->Firing = 0;

		g_pWorld->bfirstblood = 0;

		g_pWorld->rumble->Play(0);

		for(int i=0; i<150; i++)
		{
			g_pWorld->Balls[i].State = 0;
		}
		g_pWorld->wait = 1200;
	}
	while(true)
	{
		//music.Process(&musicresult);
		//DirectSoundDoWork();

		g_pGamePads->GetInput();

		if(	(g_pGamePads->pGP1->wButtons &  XINPUT_GAMEPAD_START) &&
			(g_pGamePads->pGP1->wButtons &  XINPUT_GAMEPAD_BACK) )
			ReBoot();

		if(g_pGamePads->pGP1->wButtons & XINPUT_GAMEPAD_DPAD_DOWN)
		{
			if(screenshot == 0)
			{
				screenshot = 1;
				CaptureScreen(g_pD3DDevice, "D:\\screen.bmp"); 
			}
		}
		if(g_pWorld->pPlayer[0]->Dead != 0 && g_pWorld->pPlayer[1]->Dead != 0)
		{
			WinnerColor = D3DCOLOR_XRGB(150, 0, 0);
			g_pWorld->pPlayer[0]->Dead = 0;
			g_pWorld->pPlayer[0]->TransX = 2.5f;
			g_pWorld->pPlayer[0]->TransY = 5.0f;
			g_pWorld->pPlayer[0]->Theta = 3.1415f/2.0f;
			g_pWorld->pPlayer[0]->Phi = 3.1415f/2.0f;
			g_pWorld->pPlayer[0]->Firing = 0;

			g_pWorld->pPlayer[1]->Dead = 0;
			g_pWorld->pPlayer[1]->TransX = 2.5f;
			g_pWorld->pPlayer[1]->TransY = 80.0f - 5.0f;
			g_pWorld->pPlayer[1]->Theta = -3.1415f/2.0f;
			g_pWorld->pPlayer[1]->Phi = 3.1415f/2.0f;
			g_pWorld->pPlayer[1]->Firing = 0;

			g_pWorld->pPlayer[2]->Dead = 0;
			g_pWorld->pPlayer[2]->TransX = 180.0f - 2.5f;
			g_pWorld->pPlayer[2]->TransY = 5.0f;
			g_pWorld->pPlayer[2]->Theta = 3.1415f/2.0f;
			g_pWorld->pPlayer[2]->Phi = 3.1415f/2.0f;
			g_pWorld->pPlayer[2]->Firing = 0;

			g_pWorld->pPlayer[3]->Dead = 0;
			g_pWorld->pPlayer[3]->TransX = 180.0f - 2.5f;
			g_pWorld->pPlayer[3]->TransY = 80.0f - 5.0f;
			g_pWorld->pPlayer[3]->Theta = -3.1415f/2.0f;
			g_pWorld->pPlayer[3]->Phi = 3.1415f/2.0f;
			g_pWorld->pPlayer[3]->Firing = 0;

			g_pWorld->bfirstblood = 0;

			g_pWorld->redwins->Play(0);
			(g_pWorld->CurrLevel)++;
			if(g_pWorld->CurrLevel == 5)
				g_pWorld->CurrLevel = 0;
			(g_pWorld->Boards) = &((g_pWorld->BoardsAll)[g_pWorld->CurrLevel][0]);

			for(int i=0; i<150; i++)
			{
				g_pWorld->Balls[i].State = 0;
			}
			g_pWorld->wait = 800;
		}
		
		if(g_pWorld->pPlayer[2]->Dead != 0 && g_pWorld->pPlayer[3]->Dead != 0)
		{
			WinnerColor = D3DCOLOR_XRGB(0, 0, 150);
			g_pWorld->pPlayer[0]->Dead = 0;
			g_pWorld->pPlayer[0]->TransX = 2.5f;
			g_pWorld->pPlayer[0]->TransY = 5.0f;
			g_pWorld->pPlayer[0]->Theta = 3.1415f/2.0f;
			g_pWorld->pPlayer[0]->Phi = 3.1415f/2.0f;
			g_pWorld->pPlayer[0]->Firing = 0;

			g_pWorld->pPlayer[1]->Dead = 0;
			g_pWorld->pPlayer[1]->TransX = 2.5f;
			g_pWorld->pPlayer[1]->TransY = 80.0f - 5.0f;
			g_pWorld->pPlayer[1]->Theta = -3.1415f/2.0f;
			g_pWorld->pPlayer[1]->Phi = 3.1415f/2.0f;
			g_pWorld->pPlayer[1]->Firing = 0;

			g_pWorld->pPlayer[2]->Dead = 0;
			g_pWorld->pPlayer[2]->TransX = 180.0f - 2.5f;
			g_pWorld->pPlayer[2]->TransY = 5.0f;
			g_pWorld->pPlayer[2]->Theta = 3.1415f/2.0f;
			g_pWorld->pPlayer[2]->Phi = 3.1415f/2.0f;
			g_pWorld->pPlayer[2]->Firing = 0;

			g_pWorld->pPlayer[3]->Dead = 0;
			g_pWorld->pPlayer[3]->TransX = 180.0f - 2.5f;
			g_pWorld->pPlayer[3]->TransY = 80.0f - 5.0f;
			g_pWorld->pPlayer[3]->Theta = -3.1415f/2.0f;
			g_pWorld->pPlayer[3]->Phi = 3.1415f/2.0f;
			g_pWorld->pPlayer[3]->Firing = 0;

			g_pWorld->bfirstblood = 0;

			g_pWorld->bluewins->Play(0);
		
			(g_pWorld->CurrLevel)++;
			if(g_pWorld->CurrLevel == 5)
				g_pWorld->CurrLevel = 0;
			(g_pWorld->Boards) = &((g_pWorld->BoardsAll)[g_pWorld->CurrLevel][0]);

			for(int i=0; i<150; i++)
			{
				g_pWorld->Balls[i].State = 0;
			}
			g_pWorld->wait = 800;
		}

		g_pD3DDevice->SetViewport(&viewport);

		g_pD3DDevice->Clear(0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER, WinnerColor, 0.0f, 0);

		g_pD3DDevice->BeginScene();

		g_pWorld->UpdateWorld();

		g_pD3DDevice->EndScene();

		g_pD3DDevice->Present(NULL, NULL, NULL, NULL);
	}
}