Пример #1
0
void SMenuODWnd::MeasureItem( LPMEASUREITEMSTRUCT lpMeasureItemStruct )
{
    if(lpMeasureItemStruct->CtlType != ODT_MENU) return;

    SMenuItemData *pdmmi=(SMenuItemData*)lpMeasureItemStruct->itemData;
    if(pdmmi)
    {
        //menu item
        lpMeasureItemStruct->itemHeight = m_nItemHei;
        lpMeasureItemStruct->itemWidth = m_szIcon.cx+m_nIconMargin*2;

        CAutoRefPtr<IRenderTarget> pRT;
        GETRENDERFACTORY->CreateRenderTarget(&pRT,0,0);
        CAutoRefPtr<IFont> oldFont;
        pRT->SelectObject(m_hFont,(IRenderObj**)&oldFont);
        SIZE szTxt;
        pRT->MeasureText(pdmmi->itemInfo.strText,pdmmi->itemInfo.strText.GetLength(),&szTxt);
        lpMeasureItemStruct->itemWidth += szTxt.cx+m_nTextMargin*2;
        pRT->SelectObject(oldFont);
    }
    else
    {
        // separator
        lpMeasureItemStruct->itemHeight = m_pSepSkin?m_pSepSkin->GetSkinSize().cy:3;
        lpMeasureItemStruct->itemWidth=0;
    }

}
Пример #2
0
    void SScrollText::UpdateScrollInfo(CSize size)
    {
        CAutoRefPtr<IRenderTarget> pRT;
        GETRENDERFACTORY->CreateRenderTarget(&pRT,0,0);
        BeforePaintEx(pRT);
        SIZE sz;
        pRT->MeasureText(m_strText,m_strText.GetLength(),&sz);

        if(sz.cx - size.cx>0)
        {
            m_nScrollWidth = sz.cx;
			if (m_nRollType==1)
			{
				m_nOffset=-size.cx;
			}
			OnShowWindow(IsVisible(TRUE), 0);
        }
        else
        {
            m_nOffset = 0;
            m_nScrollWidth = 0;
        }
    }