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 » FormEditor - drawing "under" dialog Collapse All
Subject Author Date
Suhai Gyorgy Dec 22, 2006 - 6:26 AM

Dear Support,

In your FormEditor sample there is a little drawing mistake:
When I have a control on the form and I select the control, there are eight little gripboxes drawn to the sides and corners of the control. I open any dialog over the application, which covers the control partially or fully. When I close the dialog, the grip boxes that were under the dialog get drawn to wrong places. The same happens when I’m moving the dialog fast over the control. Also the caption and the borders of the form is drawn a little shattered with some of the themes, when the dialog is moved or closed over it. Could you advise, please?

Thank you,
Chris.

Technical Support Dec 22, 2006 - 10:35 AM

Thank you for reporting the problem. You can fix it by updating the source code of the following method:

void CFormEditorView::OnDraw( CDC * pDC )
{
    ASSERT_VALID( this );
    if( pDC->IsPrinting() )
        return;
#if ( ! defined __FORM_EDITOR_INVISIBLE_MODE__ )
CWnd * pWnd = GetWindow( GW_CHILD );
    for( ; pWnd != NULL; pWnd = pWnd->GetWindow( GW_HWNDNEXT ) )
    {
        CRect rc;
        pWnd->GetWindowRect( &rc );
        ScreenToClient( &rc );
        pDC->DPtoLP( &rc );
        pDC->ExcludeClipRect( &rc );
    }
#endif
CRect rcClient;
    GetClientRect( &rcClient );
CPoint ptScrollPos(
        GetScrollPos( SB_HORZ ),
        GetScrollPos( SB_VERT )
        );
CExtMemoryDC dc(
    pDC,
    &rcClient,
    CExtMemoryDC::MDCOPT_TO_MEMORY
        |CExtMemoryDC::MDCOPT_NO_COPY_OPT
    );
CRect rcMrg = CalcActualViewRect();
    rcMrg.OffsetRect( -ptScrollPos );
CExtPaintManager * pPM = g_PaintManager.GetPM();
    ASSERT_VALID( pPM );
COLORREF clr3dHilight = pPM->GetColor( COLOR_3DHILIGHT, this );
COLORREF clr3dFace = pPM->GetColor( COLOR_3DFACE, this );
COLORREF clr3dShadow = pPM->GetColor( COLOR_3DSHADOW, this );
COLORREF clr3dDkShadow = pPM->GetColor( COLOR_3DDKSHADOW, this );
bool bNcFrameSupported = false;
INT nCaptionHeight = 23;
    if( pPM->NcFrame_IsSupported( this ) )
    {
        bNcFrameSupported = true;
        nCaptionHeight = pPM->NcFrame_GetCaptionHeight( true, ::AfxGetMainWnd() ) + 4;
    }
CRect rcFrame( &rcMrg );
    rcFrame.InflateRect( 3, nCaptionHeight, 3, 0 );
    pPM->PaintDocumentClientAreaBkgnd( dc, this );
CRect rcDesignerWindowBk = rcFrame;
    rcDesignerWindowBk.OffsetRect( ptScrollPos );
CRect rcDesignerClient( rcFrame );
    if( bNcFrameSupported )
    {
        CRect rcClientReal;
        GetClientRect( &rcClientReal );
        rcDesignerClient.top = rcMrg.top - 1;
        HRGN hRgn = pPM->NcFrame_GenerateSkinFrameRGN( rcFrame, ::AfxGetMainWnd() );
        if( hRgn != NULL )
            ::SelectClipRgn( dc.m_hDC, hRgn );
        if( ! pPM->PaintDockerBkgnd( true, dc, this ) )
            dc.FillSolidRect( &rcFrame, clr3dFace );
        CRect rcIcon( 0, 0, 0, 0 );
        CRect rcText( 0, 0, 0, 0 );
        CRect rcHelp( 0, 0, 0, 0 );
        CRect rcMinimize( 0, 0, 0, 0 );
        CRect rcMaximizeRestore( 0, 0, 0, 0 );
        CRect rcClose( 0, 0, 0, 0 );
        CExtPaintManager::e_nc_button_state_t eStateButtonHelp = CExtPaintManager::__ENCBS_NORMAL;
        CExtPaintManager::e_nc_button_state_t eStateButtonMinimize = CExtPaintManager::__ENCBS_NORMAL;
        CExtPaintManager::e_nc_button_state_t eStateButtonMaximizeRestore = CExtPaintManager::__ENCBS_NORMAL;
        CExtPaintManager::e_nc_button_state_t eStateButtonClose = CExtPaintManager::__ENCBS_NORMAL;
        pPM->NcFrame_Paint(
            dc,
            NULL,
            _T(""),
            0,
            rcFrame,
            rcDesignerClient,
            rcIcon,
            rcText,
            rcHelp,
            rcMinimize,
            rcMaximizeRestore,
            rcClose,
            true,
            true,
            false,
            eStateButtonHelp,
            eStateButtonMinimize,
            eStateButtonMaximizeRestore,
            eStateButtonClose,
            ::AfxGetMainWnd()
            );
        if( hRgn != NULL )
        {
            ::SelectClipRgn( dc.m_hDC, NULL );
            ::DeleteObject( hRgn );
        }
    }
    else
    {
        if( ! pPM->PaintDockerBkgnd( true, dc, this ) )
            dc.FillSolidRect( &rcFrame, clr3dFace );
        CRect rcCaption( rcFrame );
        rcCaption.bottom = rcMrg.top - 1;
        rcCaption.DeflateRect( 3, 3, 2, 2 );
        dc.Draw3dRect(
            &rcFrame,
            clr3dHilight,
            clr3dShadow
            );
        rcFrame.InflateRect( 1, 1 );
        dc.Draw3dRect(
            &rcFrame,
            clr3dFace,
            clr3dDkShadow
            );
#ifdef COLOR_GRADIENTACTIVECAPTION
        ASSERT( (COLOR_GRADIENTACTIVECAPTION) == 27 );
#endif
        CExtPaintManager::stat_PaintGradientRect(
            dc,
            &rcCaption,
            pPM->GetColor( COLOR_ACTIVECAPTION, this ),
            pPM->GetColor( 27, this )
            );
    }
CPoint ptStart = rcMrg.TopLeft();
CPoint ptEnd = rcMrg.BottomRight();
CPoint ptCurr;
COLORREF clrDot = pPM->GetColor( COLOR_BTNTEXT, this );
    for( ptCurr.x = ptStart.x; ptCurr.x < ptEnd.x; ptCurr.x += m_sizeGridStep.cx )
    {
        for( ptCurr.y = ptStart.y; ptCurr.y < ptEnd.y; ptCurr.y += m_sizeGridStep.cy )
            dc.SetPixel( ptCurr, clrDot );
    }
#if ( defined __FORM_EDITOR_INVISIBLE_MODE__ )
HDC hChildDC = NULL;
HWND hWndChild = ::GetWindow(m_hWnd,GW_CHILD);
    for(    ;
            hWndChild != NULL;
            hWndChild = ::GetWindow(hWndChild,GW_HWNDNEXT)
        )
    {
        ASSERT( hWndChild != NULL );
        ASSERT( ::IsWindow(hWndChild) );
        HWND hWnd = ::GetWindow(hWndChild,GW_CHILD);
        if( hWnd == NULL )
            continue;
        CRect rc;
        ::GetWindowRect( hWnd, &rc );
        if( rc.right <= rc.left || rc.bottom <= rc.top )
            continue;
        ScreenToClient( &rc );
        HBITMAP hBmp =
            CExtPaintManager::stat_PrintWnd(
                hWnd,
                WM_PRINT,
                PRF_NONCLIENT|PRF_CLIENT|PRF_ERASEBKGND|PRF_CHILDREN,
                dc.m_hDC,
                &rc
                );
        if( hBmp == NULL )
            continue;
        if( hChildDC == NULL )
        {
            hChildDC = ::CreateCompatibleDC( dc.m_hDC );
            if( hChildDC == NULL )
                break;
        }
        HGDIOBJ hOldBmpInChildDC = ::SelectObject( hChildDC, (HGDIOBJ)hBmp );
        ::BitBlt(
            dc.m_hDC,
            rc.left,
            rc.top,
            rc.Width(),
            rc.Height(),
            hChildDC,
            0,
            0,
            SRCCOPY
            );
        ::SelectObject( hChildDC, hOldBmpInChildDC );
        ::DeleteObject( hBmp );
    }
    if( hChildDC != NULL )
    {
        ::DeleteDC( hChildDC );
    }
#endif
    if( (!m_bTabOrderMode) && m_mapSelection.GetCount() > 0 )
    {
        COLORREF clrGripBoxOuter = pPM->GetColor( COLOR_3DDKSHADOW, this );
        COLORREF clrGripBoxInner =
            pPM->GetColor(
                    (m_mapSelection.GetCount() == 1)
                        ? COLOR_WINDOW
                        : COLOR_3DDKSHADOW
                        ,
                    this
                    );
        POSITION pos = m_mapSelection.GetStartPosition();
        for( ; pos != NULL; )
        {
            HWND hWndChild;
            int nTmp;
            m_mapSelection.GetNextAssoc(pos,hWndChild,nTmp);
            ASSERT( hWndChild != NULL );
            ASSERT( ::IsWindow(hWndChild) );
            CRect rc;
            if( !::GetWindowRect(hWndChild,&rc) )
                continue;
            ScreenToClient( &rc );
            dc.DPtoLP( &rc );
            CRect rcGripBoxes[8];
            CalcGripBoxes( rc, rcGripBoxes );
            for( int i = 0;  i < 8; i++ )
            {
                dc.FillSolidRect(
                    rcGripBoxes[i],
                    clrGripBoxInner
                    );
                dc.Draw3dRect(
                    rcGripBoxes[i],
                    clrGripBoxOuter,
                    clrGripBoxOuter
                    );
            }
        }
    }
    if( m_bTabOrderMode )
    {
        COLORREF clrTabNoBk =
            pPM->GetColor( COLOR_HIGHLIGHT, this );
        COLORREF clrTabNoText =
            pPM->GetColor( COLOR_HIGHLIGHTTEXT, this );
        int nIndex = 0;
        CFont * pOldFont =
            dc.SelectObject( &pPM->m_FontBold );
        int nOldBkMode = dc.SetBkMode(OPAQUE);
        COLORREF clrOldBkColor = dc.SetBkColor( clrTabNoBk );
        COLORREF clrOldTextColor = dc.SetTextColor( clrTabNoText );
        for(    HWND hWndChild = ::GetWindow(m_hWnd,GW_CHILD);
                hWndChild != NULL;
                hWndChild = ::GetWindow(hWndChild,GW_HWNDNEXT),
                    nIndex++
            )
        {
            ASSERT( hWndChild != NULL );
            ASSERT( ::IsWindow(hWndChild) );
            CString sTabText = GetTabText( nIndex+1 );
            CRect rcText = CalcTabNoRect( hWndChild, nIndex+1, true );
            dc.FillSolidRect(
                rcText,
                clrTabNoBk
                );
            dc.DrawText(
                sTabText,
                rcText,
                DT_SINGLELINE|DT_CENTER|DT_VCENTER
                );
        }
        dc.SetTextColor( clrOldTextColor );
        dc.SetBkColor( clrOldBkColor );
        dc.SetBkMode(nOldBkMode);
        dc.SelectObject( pOldFont );
    }
    if( ! m_rcLastDropArea.IsRectEmpty() )
    {
        CRect rect( &m_rcLastDropArea );
        dc.DrawFocusRect( &rect );
        rect.DeflateRect( 1, 1 );
        dc.DrawFocusRect( &rect );
        rect.DeflateRect( 1, 1 );
        dc.DrawFocusRect( &rect );
    }
}