示例#1
0
BOOL COXMonthCalCtrl::SetRange(const COleDateTime* pMinRange,
	const COleDateTime* pMaxRange)
{
	ASSERT(::IsWindow(m_hWnd));
	ASSERT(pMinRange == NULL || pMinRange->GetStatus() != COleDateTime::invalid);
	ASSERT(pMaxRange == NULL || pMaxRange->GetStatus() != COleDateTime::invalid);

	SYSTEMTIME sysTimes[2];
	WPARAM wFlags = 0;

	if (pMinRange != NULL && pMinRange->GetStatus() != COleDateTime::null)
	{
		if (GetAsSystemTime(*pMinRange,sysTimes[0]))
			wFlags |= GDTR_MIN;
	}

	if (pMaxRange != NULL && pMaxRange->GetStatus() != COleDateTime::null)
	{
		if (GetAsSystemTime(*pMaxRange,sysTimes[1]))
			wFlags |= GDTR_MAX;
	}

	return (BOOL)
		::SendMessage(m_hWnd, MCM_SETRANGE, wFlags, (LPARAM) &sysTimes);
}
示例#2
0
BOOL COXMonthCalCtrl::SetRange(const CTime* pMinRange, const CTime* pMaxRange)
{
	ASSERT(::IsWindow(m_hWnd));

	SYSTEMTIME sysTimes[2];
	WPARAM wFlags = 0;
	if (pMinRange != NULL && GetAsSystemTime(*pMinRange,sysTimes[0]))
		wFlags |= GDTR_MIN;

	if (pMaxRange != NULL && GetAsSystemTime(*pMaxRange,sysTimes[1]))
		wFlags |= GDTR_MAX;

	return (BOOL)
		::SendMessage(m_hWnd, MCM_SETRANGE, wFlags, (LPARAM) &sysTimes);
}
示例#3
0
void CDateTime::Archive(CArchive& ar)
{
    if (ar.IsStoring())
    {
        ar<<(int)m_state;
        if (m_state==valid)
        {
            SYSTEMTIME st;
            GetAsSystemTime(st);
            ar<<st;
        }
    }
    else
    {
        Reset();
        int state;
        ar >> (int &)state;
        m_state = CDateTime::STATE(state);
        if (m_state==valid)
        {
            SYSTEMTIME st;
            ar>>st;
            ToFileTime(st, m_time);
        }
    }
示例#4
0
BOOL COXMonthCalCtrl::SetSelRange(const CTime& refMinRange,
								  const CTime& refMaxRange)
{
	// control must have multiple select
	ASSERT((GetStyle() & MCS_MULTISELECT));
	ASSERT(::IsWindow(m_hWnd));

	SYSTEMTIME sysTimes[2];
	BOOL bResult = FALSE;

	if (GetAsSystemTime(refMinRange,sysTimes[0]) &&
		GetAsSystemTime(refMaxRange,sysTimes[1]))
	{
		bResult = (BOOL)
			::SendMessage(m_hWnd, MCM_SETSELRANGE, 0, (LPARAM)sysTimes);
	}

	return bResult;
}
void CXTPPropertyGridItemDate::OnInplaceButtonDown(CXTPPropertyGridInplaceButton* pButton)
{
	if (m_pGrid->SendNotifyMessage(XTP_PGN_INPLACEBUTTONDOWN, (LPARAM)pButton) == TRUE)
		return;

	if (!OnRequestEdit())
		return;

	CXTPPropertyGridInplaceMonthCal* pMonthCtrl = new CXTPPropertyGridInplaceMonthCal(this);


#if _MSC_VER < 1200 // MFC 5.0
	INITCOMMONCONTROLSEX icex;
	icex.dwSize = sizeof(icex);
	icex.dwICC = ICC_DATE_CLASSES;
	VERIFY(InitCommonControlsEx(&icex));
#else
	VERIFY(AfxDeferRegisterClass(AFX_WNDCOMMCTL_DATE_REG));
#endif // _MSC_VER < 1200


	CRect rect(0, 0, 0, 0);
	pMonthCtrl->CreateEx(WS_EX_TOPMOST | (m_pGrid->GetExStyle() & WS_EX_LAYOUTRTL), MONTHCAL_CLASS, NULL, WS_BORDER | WS_POPUP | WS_VISIBLE, rect, m_pGrid, 0);

	SYSTEMTIME sysTime;
	if (GetAsSystemTime(sysTime))
		pMonthCtrl->SendMessage(MCM_SETCURSEL, 0, (LPARAM) &sysTime);

	if (pMonthCtrl->GetMinReqRect(rect))
	{
		CRect rcItem = GetItemRect();
		rect.SetRect(rcItem.right - rect.Width(), rcItem.bottom, rcItem.right, rcItem.bottom + rect.Height());

		m_pGrid->ClientToScreen(&rect);

		CRect rcWork = XTPMultiMonitor()->GetWorkArea(rect);
		if (rect.bottom > rcWork.bottom && rect.top > rcWork.CenterPoint().y)
			rect.OffsetRect(0, - rect.Height() - rcItem.Height() - 1);

		if (rect.left < rcWork.left)
			rect.OffsetRect(rcWork.left - rect.left, 0);

		if (rect.right > rcWork.right)
			rect.OffsetRect(rcWork.right - rect.right, 0);

		pMonthCtrl->SetWindowPos(NULL, rect.left, rect.top, rect.Width(), rect.Height(), SWP_NOZORDER | SWP_NOACTIVATE);
	}


	pMonthCtrl->SetOwner(m_pGrid);
	pMonthCtrl->SetFocus();
}
示例#6
0
BOOL COXMonthCalCtrl::SetCurSel(const CTime& refTime)
{
	ASSERT(::IsWindow(m_hWnd));

	SYSTEMTIME sysTime;
	BOOL bRetVal = FALSE;

	if (GetAsSystemTime(refTime,sysTime))
	{
		bRetVal = (BOOL)
			::SendMessage(m_hWnd, MCM_SETCURSEL, 0, (LPARAM) &sysTime);
	}

	return bRetVal;
}
示例#7
0
BOOL COXMonthCalCtrl::SetCurSel(const COleDateTime& refTime)
{
	ASSERT(::IsWindow(m_hWnd));

	SYSTEMTIME sysTime;
	BOOL bRetVal = FALSE;

	// if the passed time is null or out of range,
	// we'll set the control to NULL

	if (GetAsSystemTime(refTime,sysTime) &&
		refTime.GetStatus() == COleDateTime::valid)
	{
		bRetVal = (BOOL)
			::SendMessage(m_hWnd, MCM_SETCURSEL, 0, (LPARAM) &sysTime);
	}

	return bRetVal;
}
示例#8
0
BOOL UpdateMonthDay(COleDateTime &refDate, int nMonthDay)
{
    if (nMonthDay > 28)
    {
        int nMaxDay = GetMaxMonthDay(refDate);
        if (!nMaxDay)
        {
            return FALSE;
        }
        nMonthDay = min(nMonthDay, nMaxDay);
    }

    SYSTEMTIME sysDate;
    if (!GetAsSystemTime(refDate, sysDate))
        return FALSE;

    int nRes = refDate.SetDate(sysDate.wYear, sysDate.wMonth, nMonthDay);
    return nRes == 0;
}
示例#9
0
int GetMaxMonthDay(COleDateTime dtDate)
{
    SYSTEMTIME sysDate;
    if (!GetAsSystemTime(dtDate, sysDate))
        return 0;

    // days per month  -     _  jan feb mar apr may jun   jul aug sep oct nov dec
    static int arDays[13] = {0, 31, 28, 31, 30, 31, 30,   31, 31, 30, 31, 30, 31};
    if (sysDate.wMonth == 2 && sysDate.wYear % 4 == 0)
    {
        if (sysDate.wYear % 100 != 0 || sysDate.wYear % 400 == 0)
            return 29;
        else
            return 28;
    }
    else
    {
        return arDays[sysDate.wMonth];
    }
}
示例#10
0
void COXMonthCalCtrl::SetToday(const CTime* pDateTime)
{
	ASSERT(::IsWindow(m_hWnd));
	ASSERT_VALID(this);

	// if the passed time is NULL, we'll set the
	// control to NULL

	WPARAM wParam = GDT_NONE;
	LPSYSTEMTIME pSysTime = NULL;
	SYSTEMTIME sysTime;

	if (pDateTime != NULL && GetAsSystemTime(*pDateTime,sysTime))
	{
		wParam = GDT_VALID;
		pSysTime = &sysTime;
	}

	if (::IsWindow(m_hWnd))
 		::SendMessage(m_hWnd, MCM_SETTODAY, wParam, (LPARAM) pSysTime);
}
示例#11
0
void COXMonthCalCtrl::SetToday(const COleDateTime& refTime)
{
	ASSERT_VALID(this);

	// make sure the time isn't invalid
	ASSERT(refTime.GetStatus() != COleDateTime::invalid);
	ASSERT(::IsWindow(m_hWnd));

	SYSTEMTIME sysTime;
	LPSYSTEMTIME pSysTime = NULL;
	WPARAM wParam = GDT_NONE;

	// if the passed time is null or out of range,
	// we'll set the control to NULL

	if (GetAsSystemTime(refTime,sysTime))
	{
		pSysTime = &sysTime;
		wParam = GDT_VALID;
	}

	if (::IsWindow(m_hWnd))
		::SendMessage(m_hWnd, MCM_SETTODAY, wParam, (LPARAM) pSysTime);
}
示例#12
0
BOOL ShiftDate_Month(COleDateTime &refDate, int nMonthCount)
{
    SYSTEMTIME sysDate;
    if (!GetAsSystemTime(refDate, sysDate))
        return FALSE;

    int nYearNew = sysDate.wYear + nMonthCount / 12;
    int nMonthNew = sysDate.wMonth + nMonthCount % 12;

    if (nMonthNew > 12)
    {
        nMonthNew -= 12 * (nMonthCount / abs(nMonthCount));
        nYearNew++;
    }
    else if (nMonthNew <= 0)
    {
        nYearNew--;
        nMonthNew += 12;

        DXASSERT(nMonthNew >= 1 && nMonthNew <= 12);
    }

    return COleDateTime::valid == refDate.SetDate(nYearNew, nMonthNew, 1);
}