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 » CExtEdit: idea (problem?) Collapse All
Subject Author Date
Dmitry Dulepov Jun 16, 2004 - 7:50 AM

Disabled CExtEdit does not have a border in dialogs when mouse is not over it. This happens even if I set various styles (WS_BORDER,  WS_EX_CLIENT_EDGE) to the control. As a result it does not look good together with spin control (especially, on . Imagine: spin alone and static control on the left of it. This is how it looks now. It would be good if border is painted around disabled edit control...

Technical Support Jun 21, 2004 - 8:27 AM

Dear Dmitry,

We are sorry for the delay in replying to you. We wrote a CExtFlatEdit class, which provides the edit control with a thin border painted with the current color of the paint manager:

class CExtFlatEdit : public CExtEditBase 
{
public:
    CExtFlatEdit::CExtFlatEdit()
        : CExtEditBase()
        , m_bNcCalcSize(false)
    {
    }
    
protected:
    bool m_bNcCalcSize;
    
    virtual LRESULT WindowProc( 
        UINT message, 
        WPARAM wParam, 
        LPARAM lParam
        )
    {
        switch( message )
        {
        case WM_NCCALCSIZE:
            {
                DefWindowProc(
                    WM_NCCALCSIZE,
                    wParam,
                    lParam
                    );
                
                NCCALCSIZE_PARAMS * pNCCSP =
                    reinterpret_cast < NCCALCSIZE_PARAMS * > ( lParam );
                ASSERT( pNCCSP != NULL );
                CRect rcInBarWnd( pNCCSP->rgrc[0] );
                rcInBarWnd.DeflateRect(
                    2, 2, 2, 2
                    );
                ::CopyRect( &(pNCCSP->rgrc[0]), rcInBarWnd );
                m_bNcCalcSize = true;
                return 0;
            } // case WM_NCCALCSIZE
            
        case WM_NCPAINT:
            {
                DefWindowProc(
                    WM_NCPAINT,
                    wParam,
                    lParam
                    );

                CRect rcInBarWnd, rcInBarClient;
                GetWindowRect( &rcInBarWnd );
                GetClientRect( &rcInBarClient );
                if( !m_bNcCalcSize ){
                    SetWindowPos(
                        NULL, 0, 0, 0, 0,
                        SWP_NOMOVE|SWP_NOSIZE 
                        |SWP_NOZORDER|SWP_NOOWNERZORDER|SWP_FRAMECHANGED
                        );
                }
                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 );
                
                static const TCHAR szEditBox[] = _T("EDIT");
                TCHAR szCompare[sizeof(szEditBox)/sizeof(szEditBox[0])+1];
                ::GetClassName( 
                    GetSafeHwnd(), 
                    szCompare, 
                    sizeof(szCompare)/sizeof(szCompare[0]) 
                );
                if( !lstrcmpi( szCompare, szEditBox ) ){
                    bool bReadOnly = 
                        ( (GetStyle() & ES_READONLY) != 0 ) ? true : false;
                    dc.FillSolidRect(
                        &rcInBarWnd, 
                        bReadOnly 
                        ? ::GetSysColor(COLOR_3DFACE)
                        : g_PaintManager->GetColor(COLOR_WINDOW)
                        );
                }
                
                g_PaintManager->PaintResizableBarChildNcAreaRect(
                    dc,
                    rcInBarWnd,
                    this
                    );
    
                return 0;
            } // case WM_NCPAINT
        }; // switch( message )
        return CExtEditBase::WindowProc( message, wParam, lParam );
    };
};

Dmitry Dulepov Jun 22, 2004 - 12:39 AM

Looking forward to see it in 2.25 too! :)

Technical Support Jun 23, 2004 - 7:59 AM

Probably we will include this class into Prof-UIS, but anyway you can find it in the Prof-UIS Controls sample now.