Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS Tech Support » CExtLabel not respecting some CStatic styles ? Collapse All
Subject Author Date
Pawel Kalinowski Aug 27, 2007 - 7:38 AM

Hi!

Is there a way to make CExtLabel handle the End/Word Ellipsis or Simple properties of CStatic controls? As far as I can tell the CExtLabel will always do multiline if its text doesn’t fit in a single line but there is enough space vertically.

I would also like to know when can we expect a release fixing the ribbon problems I reported some time ago?

Regards

Technical Support Aug 28, 2007 - 1:15 PM

Thank you for reporting the problem. To fix it, please update the CExtLabel::DoPaint() method using the code below and recompile the library.

void CExtLabel::DoPaint( 
    CDC * pDC,
    CRect & rcClient
    )
{
    ASSERT_VALID( this );
    ASSERT_VALID( pDC );
CExtMemoryDC dc(
        pDC,
        &rcClient
        );
CRgn rgnClient;
    if( rgnClient.CreateRectRgnIndirect( &rcClient ) )
        dc.SelectClipRgn( &rgnClient );

    OnEraseBackground( dc, rcClient );

DWORD dwWndStyle = GetStyle();
DWORD dwWndType = (dwWndStyle&SS_TYPEMASK);
    if( dwWndType == SS_ICON )
    {
        HICON hIcon = GetIcon();
        if( hIcon != NULL )
        {
            CExtCmdIcon _icon;
            _icon.AssignFromHICON( hIcon, true );
            CSize szIcon = _icon.GetSize();
            bool bCenterImage = ( (dwWndStyle&SS_CENTERIMAGE) != 0 );
            int nOffsetX = bCenterImage ? (rcClient.Width() - szIcon.cx) / 2 : 0;
            int nOffsetY = bCenterImage ? (rcClient.Height() - szIcon.cy) / 2 : 0;
            _icon.Paint(
                PmBridge_GetPM(),
                dc.GetSafeHdc(),
                 rcClient.left + nOffsetX,
                 rcClient.top + nOffsetY,
                -1,
                -1
                );
        }    
    }
    else
    {
        CExtSafeString strText;
        int nTextLen = GetWindowTextLength();
        if( nTextLen > 0 )
        {
            GetWindowText( strText.GetBuffer( nTextLen + 2 ), nTextLen + 1 );
            strText.ReleaseBuffer();
        }

        if( strText.GetLength() > 0 )
        {
            DWORD dwDrawTextFlags = 0;
            switch( dwWndType )
            {
            case SS_RIGHT:
                dwDrawTextFlags = DT_RIGHT; 
                break; 
            case SS_CENTER:
                dwDrawTextFlags = DT_CENTER;
                break;
            case SS_LEFTNOWORDWRAP:
                dwDrawTextFlags = DT_LEFT; 
                break;
            default: 
                // all the other types assumed as left
                dwDrawTextFlags = DT_LEFT; 
                break;
            } // switch( dwWndType )

            // do tabs expanding
            if( strText.Find( _T(’\t’) ) != -1 ) 
                dwDrawTextFlags |= DT_EXPANDTABS;

            bool bSingleLine = 
                ( strText.Find( _T("\r\n") ) >= 0 ) ? false : true;

            if( ( dwWndStyle&SS_CENTERIMAGE ) != 0 )
            {
                bSingleLine = true;
                dwDrawTextFlags |= DT_VCENTER;
            }

            if(        ( ! bSingleLine )
                &&    dwWndType != SS_LEFTNOWORDWRAP
                )
            {
                dwDrawTextFlags |= DT_WORDBREAK;
            }
            else
            {
                dwDrawTextFlags |= DT_SINGLELINE;

                if( (dwWndStyle&SS_ENDELLIPSIS) != 0 )
                    dwDrawTextFlags |= DT_END_ELLIPSIS;
                if( (dwWndStyle&SS_PATHELLIPSIS) != 0 )
                    dwDrawTextFlags |= DT_PATH_ELLIPSIS;
            }

            bool bEnabled = IsWindowEnabled() ? true : false;
            OnDrawLabelText(
                dc,
                rcClient,
                strText,
                dwDrawTextFlags,
                bEnabled
                );
        } // if( strText.GetLength() > 0 )
    }
    PmBridge_GetPM()->OnPaintSessionComplete( this );
    if( rgnClient.GetSafeHandle() != NULL )
        dc.SelectClipRgn( &rgnClient );    
}