Beispiel #1
0
//================================================================================================
// -------------------------------------------//+++--> Initialize Timer View/Watch Dialog Controls:
void OnInitTimeView(HWND hDlg)   //---------------------------------------------+++-->
{
	LVCOLUMN lvCol;
	HWND hList=GetDlgItem(hDlg,IDC_LIST);
	SendMessage(hDlg, WM_SETICON, ICON_SMALL,(LPARAM)g_hIconTClock);
	SendMessage(hDlg, WM_SETICON, ICON_BIG,(LPARAM)g_hIconTClock);
	
	ListView_SetExtendedListViewStyle(hList, LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES|LVS_EX_DOUBLEBUFFER);
	SetXPWindowTheme(hList,L"Explorer",NULL);
	
	lvCol.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
	lvCol.cx = 125;		 // Column Width
	lvCol.iSubItem = 0;      // Column Number
	lvCol.fmt = LVCFMT_CENTER; // Column Alignment
	lvCol.pszText = TEXT("Timer"); // Column Header Text
	ListView_InsertColumn(hList, 0, &lvCol);
	
	lvCol.cx = 150;
	lvCol.iSubItem = 1;
	lvCol.fmt = LVCFMT_LEFT;
	lvCol.pszText = TEXT("Remaining");
	ListView_InsertColumn(hList, 1, &lvCol);
}
Beispiel #2
0
LRESULT CALLBACK Window_Calendar(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	switch(uMsg) {
	case WM_CREATE:{
		int iMonths,iMonthsPast;
		DWORD dwCalStyle;
		RECT rc; HWND hCal;
		size_t idx;
		size_t dirty = 0;
		
		iMonths = api.GetIntEx(L"Calendar", L"ViewMonths", 3);
		iMonthsPast = api.GetIntEx(L"Calendar", L"ViewMonthsPast", 1);
		
		if(api.GetInt(L"Calendar", L"ShowDayOfYear", 1)) {
			wchar_t szTitle[32];
			GetDayOfYearTitle(szTitle,iMonths);
			SetWindowText(hwnd,szTitle);
		}
		
		dwCalStyle = WS_CHILD|WS_VISIBLE;
		if(api.GetInt(L"Calendar",L"ShowWeekNums",0))
			dwCalStyle|=MCS_WEEKNUMBERS;
		
		hCal = CreateWindowEx(0, MONTHCAL_CLASS, L"", dwCalStyle, 0,0,0,0, hwnd, NULL, NULL, NULL);
		if(!hCal) return -1;
		
		for(idx=0; idx<CALENDAR_COLOR_NUM; ++idx){
			unsigned color = api.GetInt(L"Calendar", g_calendar_color[idx].reg, TCOLOR(TCOLOR_DEFAULT));
			if(color != TCOLOR(TCOLOR_DEFAULT)){
				dirty |= (1<<idx);
				MonthCal_SetColor(hCal, g_calendar_color[idx].mcsc, api.GetColor(color,0));
			}
		}
		if(dirty&~1)
			SetXPWindowTheme(hCal, NULL, L"");
		
		MonthCal_GetMinReqRect(hCal,&rc);//size for a single month
		if(iMonths>1){
			#define CALBORDER 4
			#define CALTODAYTEXTHEIGHT 13
			rc.right+=CALBORDER;
			rc.bottom-=CALTODAYTEXTHEIGHT;
			if(api.OS == TOS_2000){
				rc.right+=2;
				rc.bottom+=2;
			}
			switch(iMonths){
			/*case 1:*/ case 2: case 3:
			case 4: case 5:
				rc.right*=iMonths;
				break;
			case 6:
				rc.bottom*=3;
				/* fall through */
			case 7: case 8:
				rc.right*=2;
				if(iMonths!=6) rc.bottom*=4;
				break;
			case 9:
				rc.bottom*=3;
			case 11: case 12:
				rc.right*=3;
				if(iMonths!=9) rc.bottom*=4;
				break;
			case 10:
				rc.right*=5;
				rc.bottom*=2;
				break;
			}
			rc.right-=CALBORDER;
			rc.bottom+=CALTODAYTEXTHEIGHT;
			if(api.OS >= TOS_VISTA)
				MonthCal_SizeRectToMin(hCal,&rc);//removes some empty space.. (eg at 4 months)
		}else{
			if(rc.right<(LONG)MonthCal_GetMaxTodayWidth(hCal))
				rc.right=MonthCal_GetMaxTodayWidth(hCal);
		}
		SetWindowPos(hCal,HWND_TOP,0,0,rc.right,rc.bottom,SWP_NOZORDER|SWP_NOACTIVATE);
		if(iMonthsPast){
			SYSTEMTIME st,stnew; MonthCal_GetCurSel(hCal,&st); stnew=st;
			stnew.wDay=1;
			if(iMonthsPast>=stnew.wMonth){ --stnew.wYear; stnew.wMonth+=12; }
			stnew.wMonth-=(short)iMonthsPast;
			if(stnew.wMonth>12){ ++stnew.wYear; stnew.wMonth-=12; }  // in case iMonthsPast is negative
			MonthCal_SetCurSel(hCal,&stnew);
			MonthCal_SetCurSel(hCal,&st);
		}
		SetFocus(hCal);
		AdjustWindowRectEx(&rc,WS_CAPTION|WS_POPUP|WS_SYSMENU|WS_VISIBLE,FALSE,0);
		SetWindowPos(hwnd,HWND_TOP,0,0, rc.right-rc.left,rc.bottom-rc.top, SWP_NOMOVE);//force to be on top
		if(m_bTopMost)
			SetWindowPos(hwnd,HWND_TOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE);
		api.PositionWindow(hwnd, (api.OS<TOS_WIN10 && api.OS>=TOS_WIN7 ? 11 : 0));
		if(m_bAutoClose && GetForegroundWindow()!=hwnd)
			PostMessage(hwnd,WM_CLOSE,0,0);
		return 0;}
	case WM_ACTIVATE:
		if(!m_bTopMost){
			if(LOWORD(wParam)==WA_ACTIVE || LOWORD(wParam)==WA_CLICKACTIVE){
				SetWindowPos(hwnd,HWND_TOPMOST_nowarn,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE);
			}else{
				SetWindowPos(hwnd,HWND_NOTOPMOST_nowarn,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE);
				// actually it should be lParam, but that's "always" NULL for other process' windows
				SetWindowPos(GetForegroundWindow(),HWND_TOP,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE);
			}
		}
		if(m_bAutoClose){
			if(LOWORD(wParam)!=WA_ACTIVE && LOWORD(wParam)!=WA_CLICKACTIVE){
				PostMessage(hwnd,WM_CLOSE,0,0);//adds a little more delay which is good
			}
		}
		break;
	case WM_DESTROY:
		Sleep(50);//we needed more delay... 50ms looks good (to allow T-Clock's FindWindow to work) 100ms is slower then Vista's native calendar
		PostQuitMessage(0);
		break;
	}
	return DefWindowProc(hwnd, uMsg, wParam, lParam);
}
Beispiel #3
0
static INT_PTR CALLBACK Window_CalendarColorConfigDlg(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam){
	switch(msg){
	case WM_INITDIALOG:{
		ColorBox colors[6];
		HWND calendar = GetDlgItem(hDlg, IDC_CAL_PREVIEW);
		HWND preset_cb = GetDlgItem(hDlg, IDC_CAL_PRESET);
		int idx;
		m_calendar_dirty = 0;
		for(idx=0; idx<GROUP_CALENDAR_COLOR_NUM; ++idx){
			unsigned color_id = GROUP_CALENDAR_COLOR + (idx * 2);
			colors[idx].hwnd = GetDlgItem(hDlg, color_id);
			colors[idx].color = api.GetInt(L"Calendar", g_calendar_color[idx].reg, TCOLOR(TCOLOR_DEFAULT));
			m_calendar_preset[0].color[idx] = (COLORREF)MonthCal_GetColor(calendar, g_calendar_color[idx].mcsc);
			if(colors[idx].color != TCOLOR(TCOLOR_DEFAULT)){
				m_calendar_dirty |= (1<<idx);
				MonthCal_SetColor(calendar, g_calendar_color[idx].mcsc, api.GetColor(colors[idx].color,0));
			}
		}
		ColorBox_Setup(colors, 6);
		for(idx=0; idx<CALENDAR_PRESETS; ++idx)
			ComboBox_AddString(preset_cb, m_calendar_preset[idx].name);
		ComboBox_AddString(preset_cb, L"custom colors");
		m_calendar_dirty ^= 1; // toggle bit to force refresh
		SendMessage(hDlg, WM_COMMAND, MAKEWPARAM(IDC_CAL_OUTER,CBN_SELCHANGE), (LPARAM)GetDlgItem(hDlg,IDC_CAL_OUTER));
		return TRUE;}
	case WM_MEASUREITEM:
		return ColorBox_OnMeasureItem(wParam, lParam);
	case WM_DRAWITEM:
		return ColorBox_OnDrawItem(wParam, lParam);
	case WM_COMMAND:{
		unsigned control_id = LOWORD(wParam);
		unsigned control_notify = HIWORD(wParam);
		switch(control_id){
		case IDC_CAL_PREVIEW:
			break;
		case IDC_CAL_PRESET:{
			HWND calendar = GetDlgItem(hDlg, IDC_CAL_PREVIEW);
			HWND preset_cb = GetDlgItem(hDlg, IDC_CAL_PRESET);
			int preset = ComboBox_GetCurSel(preset_cb);
			int idx;
			if(preset == CALENDAR_PRESETS)
				break;
			for(idx=0; idx<GROUP_CALENDAR_COLOR_NUM; ++idx){
				unsigned color_id = GROUP_CALENDAR_COLOR + (idx * 2);
				HWND color_cb = GetDlgItem(hDlg, color_id);
				if(preset == 0)
					ColorBox_SetColor(color_cb, TCOLOR(TCOLOR_DEFAULT));
				else
					ColorBox_SetColor(color_cb, m_calendar_preset[preset].color[idx]);
				MonthCal_SetColor(calendar, g_calendar_color[idx].mcsc, api.GetColor(m_calendar_preset[preset].color[idx],0));
			}
			if(preset == 0)
				m_calendar_dirty = 0;
			else
				m_calendar_dirty = 0x01|0x02|0x04|0x08|0x10|0x20;
			SetXPWindowTheme(GetDlgItem(hDlg,IDC_CAL_PREVIEW), NULL, (m_calendar_dirty ? L"" : NULL));
			break;}
		case IDC_CAL_OUTER: case IDC_CAL_FORE: case IDC_CAL_BACK: case IDC_CAL_TITLE: case IDC_CAL_TITLE_BG: case IDC_CAL_TRAIL:
			if(control_notify == CBN_SELCHANGE){
				unsigned id = (control_id - GROUP_CALENDAR_COLOR) / 2;
				unsigned color = ColorBox_GetColorRaw((HWND)lParam);
				char dirty = m_calendar_dirty;
				if(color == TCOLOR(TCOLOR_DEFAULT))
					dirty &= ~(1<<id);
				else
					dirty |= 1<<id;
				if(dirty != m_calendar_dirty){
					m_calendar_dirty = dirty;
					SetXPWindowTheme(GetDlgItem(hDlg,IDC_CAL_PREVIEW), NULL, (dirty&~1 ? L"" : NULL));
				}
				ComboBox_SetCurSel(GetDlgItem(hDlg,IDC_CAL_PRESET), (dirty ? CALENDAR_PRESETS : 0));
				if(color == TCOLOR(TCOLOR_DEFAULT))
					color = m_calendar_preset[0].color[id];
				else
					color = api.GetColor(color, 0);
				MonthCal_SetColor(GetDlgItem(hDlg,IDC_CAL_PREVIEW), g_calendar_color[id].mcsc, color);
			}
			break;
		case IDOK:
			{int idx;
			for(idx=0; idx<GROUP_CALENDAR_COLOR_NUM; ++idx){
				unsigned color_id = GROUP_CALENDAR_COLOR + (idx * 2);
				HWND color_cb = GetDlgItem(hDlg, color_id);
				api.SetInt(L"Calendar", g_calendar_color[idx].reg, ColorBox_GetColorRaw(color_cb));
			}}
			/* fall through */
		case IDCANCEL:
			EndDialog(hDlg, control_id);
			break;
		default:
			ColorBox_ChooseColor((HWND)lParam);
		}
		return TRUE;}
	}
	return FALSE;
}
Beispiel #4
0
//================================================================================================
// ----------------------------------------------------+++--> Initialize Stopwatch Dialog Controls:
static void OnInit(HWND hDlg)   //-----------------------------------------------------------------+++-->
{
	RECT rc;
	LVCOLUMN lvCol;
	HWND hList = GetDlgItem(hDlg,IDC_SW_LAPS);
	/// basic init
	m_paused = 1;
	m_start.QuadPart = 0;
	QueryPerformanceFrequency(&m_frequency);
	SendMessage(hDlg, WM_SETICON, ICON_SMALL,(LPARAM)g_hIconTClock);
	SendMessage(hDlg, WM_SETICON, ICON_BIG,(LPARAM)g_hIconTClock);
	/// init resize info
	GetWindowRect(hDlg, &rc);
	m_rezCX = rc.right-rc.left;
	m_rezCY = rc.bottom-rc.top;
	GetWindowRect(GetDlgItem(hDlg,IDC_SW_START), &rc);
	ScreenToClient(hDlg, (POINT*)&rc);
	m_rezYcontrols = rc.top;
	GetWindowRect(hList, &rc);
	m_rezCYlist = rc.bottom-rc.top;
	m_rezCXlist = rc.right-rc.left;
	rc.bottom = api.GetInt(L"Timers", L"SwSize", 0);
	if(rc.bottom){
		SetWindowPos(hDlg, HWND_TOP, 0,0, m_rezCX, rc.bottom, SWP_NOMOVE|SWP_NOZORDER);
	}
	/// init list view
	ListView_SetExtendedListViewStyle(hList, (LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES|LVS_EX_DOUBLEBUFFER));
	SetXPWindowTheme(hList, L"Explorer", NULL);
	
	lvCol.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
	lvCol.cx = 65; // Column Width
	lvCol.iSubItem = 0;
	lvCol.fmt = LVCFMT_CENTER;
	lvCol.pszText = TEXT("Lap");
	ListView_InsertColumn(hList,0,&lvCol);
	
	lvCol.cx = 85;
	lvCol.iSubItem = 1;
	lvCol.fmt = LVCFMT_LEFT;
	lvCol.pszText = TEXT("Time");
	ListView_InsertColumn(hList,1,&lvCol);
	
	lvCol.cx = 85;
	lvCol.iSubItem = 2;
	lvCol.fmt = LVCFMT_LEFT;
	lvCol.pszText = TEXT("Total");
	ListView_InsertColumn(hList,2,&lvCol);
	/// init font
	{
		LOGFONT logfont;
		HFONT hfont;
		hfont=(HFONT)SendMessage(hDlg,WM_GETFONT,0,0);
		GetObject(hfont,sizeof(LOGFONT),&logfont);
		logfont.lfHeight=logfont.lfHeight*145/100;
		logfont.lfWeight=FW_BOLD;
		hfont=CreateFontIndirect(&logfont);
		SendDlgItemMessage(hDlg,IDC_SW_ELAPSED,WM_SETFONT,(WPARAM)hfont,0);
		hfont=(HFONT)SendMessage(hDlg,WM_GETFONT,0,0);
		GetObject(hfont,sizeof(LOGFONT),&logfont);
		logfont.lfHeight=logfont.lfHeight*160/100;
		hfont=CreateFontIndirect(&logfont);
		SendDlgItemMessage(hDlg,IDC_SW_START,WM_SETFONT,(WPARAM)hfont,0);
		SendDlgItemMessage(hDlg,IDC_SW_RESET,WM_SETFONT,(WPARAM)hfont,0);
	}
	SetDlgItemText(hDlg, IDC_SW_ELAPSED, TIMETEXT_DEFAULT);
}