예제 #1
0
BOOL COXMonthCalCtrl::GetMonthFitCount(CSize& szMonthFit) const
{
	ASSERT(::IsWindow(m_hWnd));

	CRect rectMin;
	if(!GetMinReqRect(rectMin))
		return FALSE;

	CRect rect;
	GetClientRect(rect);

	int nWidth=rect.Width();
	int nWidthMin=rectMin.Width();
	int nHorzFit=nWidth/nWidthMin;
	if(nHorzFit!=0)
	{
		nWidth-=ID_MCHORZGAP*(nHorzFit-1);
		nHorzFit=nWidth/nWidthMin;
	}
	nHorzFit=(nHorzFit>1 ? nHorzFit : 1);


	int nHeight=rect.Height();
	int nHeightMin=rectMin.Height();
	int nVertFit=nHeight/nHeightMin;
	if(nVertFit!=0)
	{
		CFont* pFont=GetFont();
		ASSERT(pFont!=NULL);
		LOGFONT lf;
		VERIFY(pFont->GetLogFont(&lf));
		nHeight+=abs(lf.lfHeight)*(nVertFit);

		nVertFit=nHeight/nHeightMin;
	}
	nVertFit=(nVertFit>1 ? nVertFit : 1);

	if(nHorzFit>ID_MAXMONTHCOUNT)
	{
		nHorzFit=ID_MAXMONTHCOUNT;
		nVertFit=1;
	}
	else if(nHorzFit*nVertFit>ID_MAXMONTHCOUNT)
		nVertFit=ID_MAXMONTHCOUNT/nHorzFit;

	
	szMonthFit.cx=nHorzFit;
	szMonthFit.cy=nVertFit;

	return TRUE;
}
예제 #2
0
BOOL CMonthCalCtrl::SizeMinReq(BOOL bRepaint /* = TRUE */)
{
    CRect rect;
    BOOL bRetVal = FALSE;
    if (GetMinReqRect(rect))
    {
        DWORD dwFlags = SWP_NOZORDER | SWP_NOREPOSITION | SWP_NOMOVE | SWP_NOACTIVATE;
        if (!bRepaint)
            dwFlags |= SWP_NOREDRAW;
        SetWindowPos(NULL, 0, 0, rect.Width(), rect.Height(), dwFlags);
        bRetVal = TRUE;
    }

    return bRetVal;
}