예제 #1
0
static void toggleCalendar(HWND hDlg)
{
	if (monthcal == NULL) {
		INITCOMMONCONTROLSEX icex;
		icex.dwSize = sizeof(icex);
		icex.dwICC = ICC_DATE_CLASSES;
		InitCommonControlsEx(&icex);
		monthcal = CreateWindowEx(0, MONTHCAL_CLASS, _T(""), WS_BORDER | WS_POPUP, 0, 0, 0, 0, hDlg, NULL, NULL, NULL);
		/* subclass month calendar, so that it hides when looses focus */
		monthcalOriginalWndProc = (WNDPROC) SetWindowLongPtr(monthcal, GWLP_WNDPROC, (LONG_PTR) MonthCalWndProc);
	}
	if (IsWindowVisible(monthcal))
		ShowWindow(monthcal, SW_HIDE);
	else {
		RECT rc;
		int x;
		int y;
		SYSTEMTIME st;
		GetWindowRect(GetDlgItem(hDlg, IDC_PICKDATE), &rc);
		x = rc.left;
		y = rc.bottom;
		MonthCal_GetMinReqRect(monthcal, &rc);
		SetWindowPos(monthcal, NULL, x, y, rc.right, rc.bottom, SWP_SHOWWINDOW | SWP_NOZORDER);
		y = ASAPInfo_GetYear(edited_info);
		if (y > 0) {
			DWORD view;
			int month = ASAPInfo_GetMonth(edited_info);
			st.wYear = y;
			if (month > 0) {
				int day = ASAPInfo_GetDayOfMonth(edited_info);
				st.wMonth = month;
				if (day > 0) {
					st.wDay = day;
					view = MCMV_MONTH;
				}
				else {
					st.wDay = 1;
					view = MCMV_YEAR;
				}
			}
			else {
				st.wMonth = 1;
				st.wDay = 1;
				view = MCMV_DECADE;
			}
			(void) MonthCal_SetCurSel(monthcal, &st);
			(void) MonthCal_SetCurrentView(monthcal, view);
		}
		SetFocus(monthcal);
	}
}
예제 #2
0
bool wxCalendarCtrl::SetDate(const wxDateTime& dt)
{
    wxCHECK_MSG( dt.IsValid(), false, "invalid date" );

    SYSTEMTIME st;
    dt.GetAsMSWSysDate(&st);
    if ( !MonthCal_SetCurSel(GetHwnd(), &st) )
    {
        wxLogDebug(wxT("DateTime_SetSystemtime() failed"));

        return false;
    }

    m_date = dt.GetDateOnly();

    return true;
}
예제 #3
0
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp) {
	RECT rect0, rect1;
	SYSTEMTIME time;

	switch (msg) {
	case WM_COMMAND:
		if (!HIWORD(wp) && LOWORD(wp)) DestroyWindow(hwnd);
		break;
	case WM_APP_NOTIFYCALLBACK:
		switch (LOWORD(lp)) {
		case WM_CONTEXTMENU:
			if (!hsubmenu) break;
			SetForegroundWindow(hwnd);
			TrackPopupMenuEx(hsubmenu, 0, LOWORD(wp), HIWORD(wp), hwnd, NULL);
			break;
		case NIN_KEYSELECT:
		case NIN_SELECT:
			if (hidden) {
				SystemParametersInfo(SPI_GETWORKAREA, 0, &rect0, 0);
				GetClientRect(hwnd, &rect1);
				SetWindowPos(hwnd, NULL, rect0.right - rect1.right, rect0.bottom - rect1.bottom, 0, 0, SWP_NOZORDER | SWP_NOSIZE | SWP_SHOWWINDOW);
				hidden = FALSE;
				MonthCal_GetToday(hcal, &time);
				MonthCal_SetCurSel(hcal, &time);
				MonthCal_SetCurrentView(hcal, MCMV_MONTH);
				SetForegroundWindow(hcal);
			} else {
				ShowWindow(hwnd, SW_HIDE);
				hidden = TRUE;
			}
			break;
		}
		break;
	case WM_DESTROY:
		tti.exit = TRUE;
		SetEvent(tti.hnotify);
		PostQuitMessage(0);
		break;
	default:
		if (msg == WM_TASKBARCREATED) SetEvent(tti.hnotify);
		else return DefWindowProc(hwnd, msg, wp, lp);
	}
	return 0;
}
예제 #4
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);
}
예제 #5
0
void
CalendarCtrl::InitCalendarValues()
{
	wyString temp,temp2;
	m_row = CustomGrid_GetCurSelRow(m_hwndparent);
	m_col = CustomGrid_GetCurSelCol(m_hwndparent);
	wyChar tempchar[5]= "";
	
	
	if(m_orgdata.Substr(0,4)==NULL)
		strcpy(tempchar,"0");
	else
		strcpy(tempchar,m_orgdata.Substr(0,4));
	temp.Add(tempchar);
	m_datetime.wYear=temp.GetAsUInt32();
	temp.Clear();
	
	
	if(m_orgdata.Substr(5,2)==NULL)
		strcpy(tempchar,"0");
	else
		strcpy(tempchar,m_orgdata.Substr(5,2));
	temp.Add(tempchar);
	m_datetime.wMonth=temp.GetAsUInt32();
	temp.Clear();
	
	if(m_orgdata.Substr(8,2)==NULL)
		strcpy(tempchar,"0");
	else
		strcpy(tempchar,m_orgdata.Substr(8,2));
	temp.Add(tempchar);
	m_datetime.wDay=temp.GetAsUInt32();
	temp.Clear();
		
	
	if(m_orgdata.Substr(11,2)==NULL)
		strcpy(tempchar,"0");
	else
		strcpy(tempchar,m_orgdata.Substr(11,2));
	temp.Add(tempchar);
	m_datetime.wHour=temp.GetAsUInt32();
	temp.Clear();
	
	
	if(m_orgdata.Substr(14,2)==NULL)
		strcpy(tempchar,"0");
	else
		strcpy(tempchar,m_orgdata.Substr(14,2));
	temp.Add(tempchar);

			m_datetime.wMinute=temp.GetAsUInt32();
			temp.Clear();

			
	if(m_orgdata.Substr(17,2)==NULL)
		strcpy(tempchar,"0");
	else
		strcpy(tempchar,m_orgdata.Substr(17,2));
	temp.Add(tempchar);
	m_datetime.wSecond=temp.GetAsUInt32();
	m_datetime.wMilliseconds=0;
	
	
	MonthCal_SetCurSel(GetDlgItem(m_hwnd,IDC_MONTHCALENDAR1), &m_datetime);
	if(!m_isDate)
	{
		DateTime_SetFormat(GetDlgItem(m_hwnd,IDC_DATETIMEPICKER1), L"HH:mm:ss");
		DateTime_SetSystemtime(GetDlgItem(m_hwnd,IDC_DATETIMEPICKER1),GDT_VALID, &m_datetime);
	}
}