コード例 #1
0
ファイル: wndproc.c プロジェクト: meizhitu/TClockLight
/*------------------------------------------------
  subclass procedure of the clock
--------------------------------------------------*/
LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	switch(message) // for tooltip
	{
		case WM_MOUSEMOVE:
		case WM_LBUTTONDOWN:
		case WM_RBUTTONDOWN:
		case WM_MBUTTONDOWN:
		case WM_LBUTTONUP:
		case WM_RBUTTONUP:
		case WM_MBUTTONUP:
#if TC_ENABLE_WHEEL
		case WM_MOUSEWHEEL:
#endif
			OnTooltipMouseMsg(hwnd, message, wParam, lParam);
			break;
	}
	
	switch(message)
	{
		/* -------- drawing & sizing ------------- */
		
		case WM_PAINT:
		{
			PAINTSTRUCT ps;
			HDC hdc;
			if(g_bNoClock) break;
			hdc = BeginPaint(hwnd, &ps);
			OnPaint(hwnd, hdc, NULL);
			EndPaint(hwnd, &ps);
			return 0;
		}
		case WM_ERASEBKGND:
			break;
		
		case (WM_USER+100):        // a message requesting for clock size
			if(g_bNoClock) break;  // sent from parent window
			return OnCalcRect(hwnd);
		
		case WM_WINDOWPOSCHANGING:  // size arrangement
			if(g_bNoClock) break;
			OnWindowPosChanging(hwnd, (LPWINDOWPOS)lParam);
			break;
		
		case WM_SIZE:
			if(g_bNoClock) break;
			CreateClockDC(hwnd);    // create offscreen DC
			return 0;
		case WM_SYSCOLORCHANGE:
		case WM_THEMECHANGED:
			if(g_bNoClock) break;
			CreateClockDC(hwnd);   // create offscreen DC
			InvalidateRect(hwnd, NULL, FALSE);
#if TC_ENABLE_DESKTOPICON
			SetDesktopIcons();		// desktop.c
#endif
			return 0;
		case WM_WININICHANGE:
		case WM_TIMECHANGE:
		case (WM_USER+101):
		case WM_SETFOCUS:
		case WM_KILLFOCUS:
			if(g_bNoClock) break;
			InvalidateRect(hwnd, NULL, FALSE);
			return 0;
		
		/* -------- Timers ------------- */
		
		case WM_TIMER:
			switch (wParam)
			{
				case IDTIMER_MAIN:
					OnTimerMain(hwnd); return 0;
#if TC_ENABLE_SYSINFO
				case IDTIMER_SYSINFO:
					OnTimerSysInfo();		// sysinfo.c
#if TC_ENABLE_DESKTOPICON
					SetDesktopIcons();		// desktop.c
#endif
					return 0;
#endif
			}
			if(g_bNoClock) break;
			return 0;
		
		/* -------- Mouse messages ------------- */
		
		case WM_LBUTTONDOWN:   // mouse button is down
		case WM_RBUTTONDOWN:
		case WM_MBUTTONDOWN:
		case WM_XBUTTONDOWN:
			return OnMouseDown(hwnd, message, wParam, lParam);
		
		case WM_LBUTTONUP:    // mouse button is up
		case WM_RBUTTONUP:
		case WM_MBUTTONUP:
		case WM_XBUTTONUP:
			return OnMouseUp(hwnd, message, wParam, lParam);
		
		case WM_MOUSEMOVE:
			return 0;
		case WM_NCRBUTTONUP:
			return 0;
		case WM_CONTEXTMENU:
			PostMessage(g_hwndTClockMain, WM_CONTEXTMENU, wParam, lParam);
			return 0;
		case WM_NCHITTEST:     // not to pass to g_oldWndProc
			return DefWindowProc(hwnd, message, wParam, lParam);
		case WM_MOUSEACTIVATE:
			return MA_ACTIVATE;
#if TC_ENABLE_MOUSEDROP
		case WM_DROPFILES:     // files are dropped
			PostMessage(g_hwndTClockMain, WM_DROPFILES, wParam, lParam);
			return 0;
#endif
#if TC_ENABLE_WHEEL
		case WM_MOUSEWHEEL:  // the mouse wheel is rotated
			PostMessage(g_hwndTClockMain, WM_MOUSEWHEEL, wParam, lParam);
			return 0;
#endif
		
		case WM_NOTIFY: // tooltip
		{
			LRESULT res;
			if(OnTooltipNotify(hwnd, &res, (LPNMHDR)lParam)) return res;
			break;
		}
		
		/* messages sent from other program */
		
		case CLOCKM_EXIT:   // clean up all
			EndClock(hwnd);
			return 0;
		case CLOCKM_REFRESHCLOCK: // refresh the clock
			OnRefreshClock(hwnd);
			return 0;
		case CLOCKM_DELUSRSTR:    // clear user strings
			InitUserStr();
			return 0;
#if TC_ENABLE_TASKBAR
		case CLOCKM_REFRESHTASKBAR: // refresh other elements than clock
			OnRefreshTaskbar(hwnd);
			return 0;
#endif
#if TC_ENABLE_STARTMENU
		case CLOCKM_REFRESHSTARTMENU: // refresh Start menu
			OnRefreshStartMenu(hwnd);
			return 0;
#endif
		case CLOCKM_REFRESHTOOLTIP: // refresh tooltip
			OnRefreshTooltip(hwnd);
			return 0;
		case CLOCKM_BLINK: // blink the clock
			g_nBlink = 2;
			m_nBlinkSec = lParam;
			if(lParam) m_nBlinkTick = GetTickCount();
			return 0;
		case CLOCKM_COPY: // copy format to clipboard
			OnCopy(hwnd, NULL);
			return 0;
#if TC_ENABLE_VOLUME
		case CLOCKM_VOLCHANGE:
			OnVolumeChange(hwnd);
			return 0;
#endif
		
		case WM_COPYDATA:
			OnCopyData(hwnd, (HWND)wParam, (COPYDATASTRUCT*)lParam);
			return 0;
		
		/* WM_DESTROY is sent only when Win95+IE4/98/Me is shut down */
		
		case WM_DESTROY:
			OnDestroy(hwnd); // main2.c
			break;
	}
	
	return CallWindowProc(g_oldWndProc, hwnd, message, wParam, lParam);
}
コード例 #2
0
 virtual LPARAM OnNotify(int id, NMHDR * pnmh) {
     if (pnmh->hwndFrom == hwnd_tooltip)
         return OnTooltipNotify(id, pnmh);
     return T::OnNotify(id, pnmh);
 }