Beispiel #1
0
LRESULT CALLBACK MsgOnlyProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	(void)wParam; (void)lParam;
	
	switch(message) {
	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;
	}
	return 0;
}
Beispiel #2
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);
}
Beispiel #3
0
/*-------------------------------------------
  dialog procedure
---------------------------------------------*/
INT_PTR CALLBACK DlgProcTimer(HWND hDlg, UINT message,
	WPARAM wParam, LPARAM lParam)
{
	switch(message)
	{
		case WM_INITDIALOG:
			OnInit(hDlg);
			return TRUE;
		case WM_COMMAND:
		{
			int id, code;
			id = LOWORD(wParam); code = HIWORD(wParam);
			switch(id)
			{
				case IDC_TIMERNAME:
					if(code == CBN_SELCHANGE)
						OnName(hDlg);
					else if(code == CBN_DROPDOWN)
						OnNameDropDown(hDlg);
					break;
				case IDC_TIMERADD:
					OnAdd(hDlg);
					break;
				case IDC_TIMERDEL:
					OnDelete(hDlg);
					break;
				case IDC_TIMERSANSHO:
					OnBrowse(hDlg);
					break;
				case IDC_TIMERTEST:
					OnTest(hDlg);
					break;
				case IDC_SHOWTIME:
					OnShowTime(hDlg);
					break;
				case IDC_SHOWWHOLE:
				case IDC_SHOWADD:
				case IDC_SHOWUSTR:
					OnUserStr(hDlg);
					break;
				case IDOK:
					OnOK(hDlg);
					break;
				case IDCANCEL:
					OnCancel(hDlg);
					break;
				case IDC_TIMERHELP:
					OnHelp(hDlg);
					break;
			}
			return TRUE;
		}
		// playing sound ended
		case MM_MCINOTIFY:
		case MM_WOM_DONE:
			if(message == MM_MCINOTIFY)
				OnMCINotify(hDlg, wParam, (LONG)lParam);
			else
				StopFile();
			m_bPlaying = FALSE;
			SendDlgItemMessage(hDlg, IDC_TIMERTEST,
				BM_SETIMAGE, IMAGE_ICON, (LPARAM)g_hIconPlay);
			return TRUE;
		case WM_DESTROY:
			OnDestroy(hDlg);
			break;
	}
	return FALSE;
}
Beispiel #4
0
//---------------------------------------------------------------------
LRESULT	Window::WindowProcedure(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) {

#ifdef	_DEBUG
	/*
	char	buf[20];
	sprintf(buf, "0x%x : ", hWnd);
	OutputDebugString(buf);
	*/
	PutWindowMessage(message, wParam, lParam);
#endif

	if ( message==WM_CREATE )
	{
		LPCREATESTRUCT	pc = (LPCREATESTRUCT)lParam;
		Window*	pw = (Window*)(pc->lpCreateParams);
		pw->mWnd = hWnd;
		::SetWindowLong(hWnd, 0, (long)pw);
		bool b = pw->OnCreate(pc);

		gTaskbarCreatedMessage = ::RegisterWindowMessage(TEXT("TaskbarCreated"));

		return	b ? 0 : -1;
	}

	// マウスホイール対応
	if ( message == msgMOUSEWHEEL ) {
		message = WM_MOUSEWHEEL;
		DbgStr("MouseWheel fwKeys:%04x, zDelta:%d, xPos:%d, yPos:%d",
			LOWORD(wParam), (short)HIWORD(wParam),
			(short)LOWORD(lParam), (short)HIWORD(lParam) );
	}

	Window*	p=(Window*)(::GetWindowLong(hWnd, 0));
	if ( p == NULL )
		return	::DefWindowProc(hWnd, message, wParam, lParam);

	if ( message >= WM_USER && message <= 0x7FFF )
		return	p->OnUser(message, wParam, lParam);
	if ( message == gTaskbarCreatedMessage )
		return  p->OnTaskbarRestart();

	switch ( message ) {

	case WM_PAINT:
		{
			PAINTSTRUCT	thePS;
			HDC			theDC = ::BeginPaint(hWnd, &thePS);
			if (theDC != NULL) {
				p->OnPaint(theDC);
				::EndPaint(hWnd, &thePS);
			}
		}
		return	0;

	case WM_NCHITTEST:
		return	p->OnNCHitTest(MAKEPOINT(lParam));

	Handle(WM_ACTIVATE, OnActivate(LOWORD(wParam), HIWORD(wParam), (HWND)lParam));
	Handle(WM_ACTIVATEAPP, OnActivateApp(BOOL(wParam), (DWORD)lParam));
	Handle(WM_DISPLAYCHANGE, OnDisplayChange(LOWORD(lParam), HIWORD(lParam), wParam));
	/*case WM_DISPLAYCHANGE:
		p->OnDisplayChange(LOWORD(lParam), HIWORD(lParam), wParam);
		break;*/


	Handle(WM_COMMAND, OnCommand(HIWORD(wParam), LOWORD(wParam), (HWND)lParam));
	Handle(WM_INITMENU, OnInitMenu(HMENU(wParam)));
	Handle(WM_CLOSE, OnClose());
	Handle(WM_DESTROY, OnDestroy());

	Handle(MM_MCINOTIFY, OnMCINotify(WORD(wParam), LONG(lParam)));

	Handle(WM_LBUTTONDOWN, OnLButtonDown(MAKEPOINT(lParam), wParam));
	Handle(WM_MBUTTONDOWN, OnMButtonDown(MAKEPOINT(lParam), wParam));
	Handle(WM_RBUTTONDOWN, OnRButtonDown(MAKEPOINT(lParam), wParam));
	Handle(WM_LBUTTONUP, OnLButtonUp(MAKEPOINT(lParam), wParam));
	Handle(WM_MBUTTONUP, OnMButtonUp(MAKEPOINT(lParam), wParam));
	Handle(WM_RBUTTONUP, OnRButtonUp(MAKEPOINT(lParam), wParam));
	Handle(WM_LBUTTONDBLCLK, OnLButtonDoubleClick(MAKEPOINT(lParam), wParam));
	Handle(WM_MBUTTONDBLCLK, OnMButtonDoubleClick(MAKEPOINT(lParam), wParam));
	Handle(WM_RBUTTONDBLCLK, OnRButtonDoubleClick(MAKEPOINT(lParam), wParam));
	Handle(WM_MOUSEMOVE, OnMouseMove(MAKEPOINT(lParam), wParam));
	Handle(WM_MOUSEWHEEL, OnMouseWheel(LOWORD(wParam), (short)HIWORD(wParam), (short)LOWORD(lParam), (short)HIWORD(lParam)));
	Handle(WM_NCLBUTTONDBLCLK, OnNCLButtonDoubleClick(wParam, MAKEPOINT(lParam)));

	Handle(WM_KEYDOWN, OnKeyDown((int)wParam, (long)lParam));
	Handle(WM_KEYUP, OnKeyUp((int)wParam, (long)lParam));
	Handle(WM_DROPFILES, OnDropFiles(HDROP(wParam)));
	
	Handle(WM_TIMER, OnTimer(wParam, (TIMERPROC*)lParam));

	Handle(WM_DRAWCLIPBOARD, OnDrawClipboard());
	Handle(WM_CHANGECBCHAIN, OnChangeCBChain((HWND)wParam, (HWND)lParam));

	default:
		break;
	}
	return	::DefWindowProc(hWnd, message, wParam, lParam);
}