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 General Discussion » CExtFlatRichEdit Collapse All
Subject Author Date
Ganesan Umanesan Mar 15, 2005 - 12:18 AM

Is it possible to have a flat border as in CExtFlatRichEdit without killing the scrollbars?

Technical Support Mar 15, 2005 - 3:31 AM

Yes, it is. Just use a slightly modified class:

class CExtFlatRichEdit : public CRichEditCtrl 
{
protected:
    virtual LRESULT WindowProc( UINT message, WPARAM wParam, LPARAM lParam )
    {
        switch( message )
        {
        case WM_NCPAINT:
            {
                DefWindowProc(
                    WM_NCPAINT,
                    wParam,
                    lParam
                    );
 
                CRect rcInBarWnd, rcInBarClient;
                GetWindowRect( &rcInBarWnd );
                GetClientRect( &rcInBarClient );
                ClientToScreen( &rcInBarClient );
                if( rcInBarWnd == rcInBarClient )
                    return 0;
 
                CPoint ptDevOffset = -rcInBarWnd.TopLeft();
                rcInBarWnd.OffsetRect( ptDevOffset );
                rcInBarClient.OffsetRect( ptDevOffset );
                
                CWindowDC dc( this );
                ASSERT( dc.GetSafeHdc() != NULL );
 
                const int cx = ::GetSystemMetrics(SM_CXVSCROLL);
                const int cy = ::GetSystemMetrics(SM_CYHSCROLL);
            
                bool bHasVerticalSB = 
                    ( rcInBarWnd.Width() - rcInBarClient.Width() ) >= cx;
                bool bHasHorizontalSB = 
                    ( rcInBarWnd.Height() - rcInBarClient.Height() ) >= cy;
            
                if( bHasVerticalSB && bHasHorizontalSB )
                {
                    dc.FillSolidRect(
                        rcInBarWnd.right - cx - 4,
                        rcInBarWnd.bottom - cy - 4,
                        cx,
                        cy,
                        g_PaintManager->GetColor(COLOR_WINDOW)
                        );
                }
 
                CRect rcExclude( rcInBarClient );
                if( bHasVerticalSB )
                    rcExclude.right += cx;
                if( bHasHorizontalSB )
                    rcExclude.bottom += cy;
                dc.ExcludeClipRect( &rcExclude );
                
                dc.FillSolidRect(
                    &rcInBarWnd, 
                    g_PaintManager->GetColor(COLOR_WINDOW)
                    );
                
                g_PaintManager->PaintResizableBarChildNcAreaRect(
                    dc,
                    rcInBarWnd,
                    this
                    );
    
                return 0;
            } // case WM_NCPAINT
        }; // switch( message )
        return CRichEditCtrl::WindowProc( message, wParam, lParam );
    };
};