当前位置: 首页>>代码示例>>C++>>正文


C++ CEdit::GetClientRect方法代码示例

本文整理汇总了C++中CEdit::GetClientRect方法的典型用法代码示例。如果您正苦于以下问题:C++ CEdit::GetClientRect方法的具体用法?C++ CEdit::GetClientRect怎么用?C++ CEdit::GetClientRect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CEdit的用法示例。


在下文中一共展示了CEdit::GetClientRect方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: CreatePropertyInterfaceForIndex

HRESULT CPropertyEditWindow::CreatePropertyInterfaceForIndex(DWORD dwPropertyInfoIndex, DWORD dwIndex, RECT& labelRect)
{
    HRESULT hr = S_OK;
    
    LPWSTR strName = NULL;
    LPWSTR strValue = NULL;
    VARTYPE vt;

    ITedPropertyInfo* pPropertyInfo = m_arrPropertyInfo[dwPropertyInfoIndex];
    PropertyInfoDisplay* pDisplay = m_arrPropertyInfoDisplay[dwPropertyInfoIndex];
    
    RECT clientRect;
    GetClientRect(&clientRect);
    DWORD dwViewWidth = clientRect.right - clientRect.left - ms_MarginWidth;

    IFC( pPropertyInfo->GetProperty(dwIndex, &strName, &strValue) );
    IFC( pPropertyInfo->GetPropertyType(dwIndex, &vt) );

    IFC( CreatePropertyLabel(dwPropertyInfoIndex, strName, labelRect) );

    labelRect.left = labelRect.right + ms_MarginWidth;
    labelRect.right = dwViewWidth - ms_MarginWidth;

    bool fReadOnly = false;
    if(vt == VT_EMPTY || vt == VT_UNKNOWN || vt == (VT_VECTOR | VT_UI1))
    {
        fReadOnly = true;
    }

    IFC( CreatePropertyEdit(dwPropertyInfoIndex, strValue, labelRect, fReadOnly) );

    RECT rectEditClient;
    CEdit* pEditWnd =  pDisplay->m_arrEdits.GetAt(pDisplay->m_arrEdits.GetCount() - 1);
    pEditWnd->GetClientRect(&rectEditClient);
    IFC( CreatePropertyTooltip(dwPropertyInfoIndex, pEditWnd->m_hWnd, GetTextForVartype(vt), rectEditClient) ); 
    pEditWnd->SetToolTipControl(pDisplay->m_arrTooltips.GetAt(pDisplay->m_arrTooltips.GetCount() -1));
    
    m_arrPropertyInfoDisplay[dwPropertyInfoIndex]->m_arrVartypes.Add(vt);

    labelRect.left = ms_MarginWidth;
    labelRect.right = labelRect.left + dwViewWidth / 2;
    labelRect.top += ms_LabelHeight;
    labelRect.bottom += ms_LabelHeight;

    m_lastRect = labelRect;

Cleanup:
    if(strName) CoTaskMemFree(strName);
    if(strValue) CoTaskMemFree(strValue);    

    // If there was a failure, roll back changes to the property displays
    if(FAILED(hr))
    {
        PropertyInfoDisplay* pDisplay = m_arrPropertyInfoDisplay[dwPropertyInfoIndex];
        if(pDisplay->m_arrVartypes.GetCount() < pDisplay->m_arrEdits.GetCount())
        {
            DWORD dwIndex = DWORD( pDisplay->m_arrEdits.GetCount() - 1 );
            pDisplay->m_arrEdits[dwIndex]->DestroyWindow();
            delete pDisplay->m_arrEdits[dwIndex];
            pDisplay->m_arrEdits.RemoveAt(pDisplay->m_arrEdits.GetCount() - 1);
        }
        
        if(pDisplay->m_arrVartypes.GetCount() < pDisplay->m_arrTooltips.GetCount())
        {
            pDisplay->m_arrTooltips.RemoveAt(pDisplay->m_arrTooltips.GetCount() - 1);
        }
        
        if(pDisplay->m_arrVartypes.GetCount() < pDisplay->m_arrLabels.GetCount())
        {
            DWORD dwIndex = DWORD( pDisplay->m_arrLabels.GetCount() - 1 );
            pDisplay->m_arrLabels[dwIndex]->DestroyWindow();
            delete pDisplay->m_arrLabels[dwIndex];
            pDisplay->m_arrLabels.RemoveAt(pDisplay->m_arrLabels.GetCount() - 1);
        }
        
        labelRect = m_lastRect;
    }
    
    return hr;
}
开发者ID:Essjay1,项目名称:Windows-classic-samples,代码行数:80,代码来源:PropertyView.cpp


注:本文中的CEdit::GetClientRect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。