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 » About the drawing of the non-client area Collapse All
Subject Author Date
tera tera Feb 13, 2009 - 11:05 PM

Hello.


I want to do the following drawing by Vista.





Because I am troubled, please teach it

Give my best regards

Technical Support Feb 16, 2009 - 12:12 PM

You should handle a WM_NCPAINT message. Painting on the non-client area in Windows Vista is same as in Windows XP. The difference is that Vista prepares a glass background and you are painting some content over it when in XP you yourself should draw a background. By default, painting over glass like window non-client area is disabled for all the windows running on Vista desktop. To enable non-client area access you should invoke the following code:

bool bDwmMode = g_PaintManager.m_DWM.IsCompositionEnabled() ? true : false;
            if( ! bDwmMode )
                        return . . . // we are not running on Vista or display mode is not 32-bit or DWM glass is disabled in desktop settings
HWND hWnd = . . .
CExtDWM::__EXT_DWMNCRENDERINGPOLICY ncrp = CExtDWM::__EXT_DWMNCRP_ENABLED;
HRESULT hr = g_PaintManager.m_DWM.DwmSetWindowAttribute( hWnd, CExtDWM::__EXT_DWMWA_NCRENDERING_POLICY, &ncrp, sizeof(ncrp) );
BOOL bAllow = TRUE;
            hr = g_PaintManager.m_DWM.DwmSetWindowAttribute( hWnd, CExtDWM::__EXT_DWMWA_ALLOW_NCPAINT, &bAllow, sizeof(bAllow) );
            hr;
After that, the hWnd window starts receiving the WM_NCPAINT messages and you can paint what you need. Your WM_NCPAINT message handler also should use the g_PaintManager.m_DWM.IsCompositionEnabled() code for detecting Vista glass painting mode.

tera tera Mar 9, 2009 - 2:21 AM

Hello.


A triangle is not drawn.

Backgrounds are always displayed with white.


Technical Support Mar 9, 2009 - 11:43 AM

Could you send us this test project?

tera tera Mar 9, 2009 - 2:24 AM



// ----------------------------------------------------------------------------

/**

 *  @brief   

 */

// ----------------------------------------------------------------------------

void CMuResizableDialog::OnSupportVista()

{

 bool bDwmMode = g_PaintManager.m_DWM.IsCompositionEnabled() ? true : false;

    if( ! bDwmMode ){

  return ;

 }


 HWND hWnd = m_hWnd;

 CExtDWM::__EXT_DWMNCRENDERINGPOLICY ncrp = CExtDWM::__EXT_DWMNCRP_ENABLED;


 HRESULT hr =

  g_PaintManager.m_DWM.DwmSetWindowAttribute(

   hWnd,

   CExtDWM::__EXT_DWMWA_NCRENDERING_POLICY,

   &ncrp, sizeof(ncrp)

  );

 BOOL bAllow = TRUE;

    hr = g_PaintManager.m_DWM.DwmSetWindowAttribute(

     hWnd, CExtDWM::__EXT_DWMWA_ALLOW_NCPAINT,

     &bAllow, sizeof(bAllow)

    );

    hr;

}


// ----------------------------------------------------------------------------

/**

 *  @brief   

 */

// ----------------------------------------------------------------------------

BOOL CMuResizableDialog::OnInitDialog()

{

    VERIFY( CExtResizableDialog ::OnInitDialog() );


 OnSupportVista();

    :

    :

    :

}


// ----------------------------------------------------------------------------

/**

 *  @brief    

 */

// ----------------------------------------------------------------------------

void CMuResizableDialog::OnNcPaint()

{

    CExtResizableDialog::OnNcPaint();

    ERPaint ( TRUE );

}


// ----------------------------------------------------------------------------

/**

 *  @brief   

 *  @param   

 */

// ----------------------------------------------------------------------------

void CMuResizableDialog::ERPaint( BOOL blActive )

{

    if ( m_blERBtnFlag == FALSE )

        return;

    ERSize();


    CDC    * pCDC;

    pCDC = this->GetWindowDC();

    CBrush brush;


   if ( m_blERHover == TRUE || blActive == FALSE ){

        brush.CreateSolidBrush( GetSysColor( COLOR_BTNFACE ) );

        pCDC->FillRect( &m_ERBtnRect , &brush );

        brush.DeleteObject();

    }else{

        brush.CreateSolidBrush( GetSysColor( COLOR_BTNFACE ) );

        pCDC->FillRect( &m_ERBtnRect , &brush );

        brush.DeleteObject();

    }


    CPen _pen;

    _pen.CreatePen( PS_SOLID , 1 , GetSysColor(COLOR_BTNHILIGHT) );

    CPen * pOldPen = pCDC->SelectObject( &_pen );

    pCDC->MoveTo( m_ERBtnRect.left , m_ERBtnRect.top );

    pCDC->LineTo( m_ERBtnRect.right, m_ERBtnRect.top );

    pCDC->MoveTo( m_ERBtnRect.left , m_ERBtnRect.top );

    pCDC->LineTo( m_ERBtnRect.left , m_ERBtnRect.bottom );

    _pen.DeleteObject();


    _pen.CreatePen( PS_SOLID , 1 , GetSysColor(COLOR_BTNSHADOW ) );

    pCDC->SelectObject( &_pen );


    pCDC->MoveTo( m_ERBtnRect.right    , m_ERBtnRect.bottom  );

    pCDC->LineTo( m_ERBtnRect.right    , m_ERBtnRect.top - 1 );

    pCDC->MoveTo( m_ERBtnRect.right    , m_ERBtnRect.bottom  );

    pCDC->LineTo( m_ERBtnRect.left - 1 , m_ERBtnRect.bottom  );


    pCDC->SelectObject( pOldPen );


    //--------------------------------------

    //

    int      ArrowCnt;

    int      iRec;

    CRgn     RgnArrow;

    POINT    ArrowPnt[100];

    int     iSpace = 2;


    if ( m_blERBtnWayFlag == FALSE ){

        //-------------------------------------------

        // 縮小矢印

        ArrowCnt = 3;

        ArrowPnt[0].x = iSpace;

        ArrowPnt[0].y = m_BtnSize - iSpace;

        ArrowPnt[1].x = m_BtnSize - iSpace;

        ArrowPnt[1].y = m_BtnSize - iSpace;


        ArrowPnt[2].x = m_BtnSize / 2;

        ArrowPnt[2].y = iSpace;

    }else{

        //-------------------------------------------

        // 拡大矢印

        ArrowCnt = 3;

        ArrowPnt[0].x = iSpace;

        ArrowPnt[0].y = iSpace;

        ArrowPnt[1].x = m_BtnSize - iSpace ;

        ArrowPnt[1].y = iSpace;


        ArrowPnt[2].x = m_BtnSize / 2;

        ArrowPnt[2].y = m_BtnSize - iSpace;


    }


    for ( iRec = 0 ; iRec < ArrowCnt ; iRec++){

        ArrowPnt[iRec].x = ArrowPnt[iRec].x + m_ERBtnRect.left;

        ArrowPnt[iRec].y = ArrowPnt[iRec].y + m_ERBtnRect.top;

    }

    if ( blActive == TRUE ){

        if ( m_blERHover == TRUE ){

            //brush.CreateSolidBrush( GetSysColor(COLOR_INACTIVECAPTION ) );

            brush.CreateSolidBrush( GetSysColor(COLOR_ACTIVECAPTION ) );

        }else{

            brush.CreateSolidBrush( GetSysColor(COLOR_ACTIVECAPTION ) );

        }

    }else{

        brush.CreateSolidBrush( GetSysColor(COLOR_BTNSHADOW ) );

    }


    VERIFY ( RgnArrow.CreatePolygonRgn( ArrowPnt , ArrowCnt , ALTERNATE ) );

    pCDC->FillRgn( &RgnArrow , &brush );

    brush.DeleteObject();


    this->ReleaseDC( pCDC );

}

tera tera Feb 17, 2009 - 1:28 AM

 


Thank you very much