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 » CExtSliderWnd background bug Collapse All
Subject Author Date
Offer Har Nov 20, 2006 - 3:39 PM

Hi,

This class does not paint its background correct.
If you use it with themed process, the background color is not painted correctly, both in ES_PROFUIS or ES_SYSTEM style.
If the transparent flag of the control is false in the properties, the result are event worse, when grading the slider, there is a left-over shadow.

Please fix for next version.

Technical Support Nov 21, 2006 - 4:34 AM

The only way to fix this bug is to code a new slider from scratch. As you know CExtSliderWnd is derived from the MFC’s CSliderWnd and the background painting in the latter is based on the WM_CTLCOLOR message. This message is not sent when the background needs to be repainted. To workaroubd this, you can use the CExtSliderWnd::UpdateSliderWnd() method to invalidate the background manually:

void CChildView::OnSize(UINT nType, int cx, int cy) 
{
    CFormView::OnSize(nType, cx, cy);
    if( m_wndSlider.GetSafeHwnd() != NULL )
        m_wndSlider.UpdateSliderWnd();
}

Offer Har Nov 21, 2006 - 4:44 AM

The problem is not only in the sizing.

I use the 2007 themes, they have a gradient background depending on the dialog’s location.
When i grad the dialog to the right, the slider’s color does not change, bur the dialog’s background color does - which looks very bad.

How to solve this problem?

Technical Support Nov 21, 2006 - 11:38 AM

We can only recommend you using a slider painted from the scratch like that specially coded for the AdoRecordsetView sample:

class CInplaceSliderWnd : public CSliderCtrl
{
protected:
virtual LRESULT WindowProc(
    UINT message,
    WPARAM wParam,
    LPARAM lParam
       )
   {
    ASSERT_VALID( this );
    if( message == WM_ERASEBKGND )
        return TRUE;
    if( message == WM_NCCALCSIZE )
        return 0L;
    if( message == WM_PAINT )
       {
        CPaintDC dcPaint( this );
        CExtPaintManager::
            stat_ExcludeChildAreas(
                   dcPaint.GetSafeHdc(),
                GetSafeHwnd()
                   );
        CRect rcClient;
        GetClientRect(
               &rcClient
               );
        CExtMemoryDC dc(
               &dcPaint,
               &rcClient
               );
        if( g_PaintManager ->
                 GetCb2DbTransparentMode(this)
               )
            g_PaintManager->PaintDockerBkgnd(
                true,
                dc,
                this
                   );
        else
            dc.FillSolidRect(
                   &rcClient,
                g_PaintManager->GetColor(
                    CExtPaintManager::
                        CLR_3DFACE_OUT,
                    this
                       )
                   );
        DWORD dwWndStyle =
            GetStyle();
        bool bHorz =
               ( (dwWndStyle&TBS_VERT) != 0 )
                   ? false : true;
        COLORREF clrFace =
            g_PaintManager->GetColor(
                COLOR_3DFACE,
                this
                   );
        COLORREF clrHilight =
            g_PaintManager->GetColor(
                COLOR_3DHILIGHT,
                this
                   );
        COLORREF clrShadow =
            g_PaintManager->GetColor(
                COLOR_3DSHADOW,
                this
                   );
        CRect rcChannel;
        rcChannel = rcClient;
        CRect rcThumb;
        CSliderCtrl::GetThumbRect(
               &rcThumb
               );
        if( bHorz )
           {
            rcChannel.top =
                rcThumb.top;
            rcChannel.bottom =
                rcThumb.bottom;
            rcChannel.DeflateRect(
                rcThumb.Width(),
                   ( rcChannel.Height()
                       - rcThumb.Width()
                       ) / 2
                   );
           } // if( bHorz )
        else
           {
            rcChannel.left =
                rcThumb.left;
            rcChannel.right =
                rcThumb.right;
            rcChannel.DeflateRect(
                   ( rcChannel.Width()
                       - rcThumb.Height()
                       ) / 2,
                rcThumb.Height()
                   );
           } // else from if( bHorz )
        dc.FillSolidRect(
               &rcChannel,
            clrFace
               );
        dc.Draw3dRect(
               &rcChannel,
            clrShadow,
            clrHilight
                );
        dc.FillSolidRect(
               &rcThumb,
            clrFace
               );
        dc.Draw3dRect(
               &rcThumb,
            clrHilight,
            clrShadow
               );
        return TRUE;
       } // if( message == WM_PAINT )
    LRESULT lResult =
        CSliderCtrl::WindowProc(
            message,
            wParam,
            lParam
                );
    return lResult;
   }
}; // class CInplaceSliderWnd

Offer Har Nov 21, 2006 - 12:46 PM

I think that part of the library should be a fully working slider control.
Currently, all my controls, including my custom controls support the themes of ProfUI, and your own controls do not.

This does not seems right, especially when the only problem of the control is the background painting.

Technical Support Nov 22, 2006 - 11:03 AM

This is a problem of the standard slider control and its "custom drawn" mechanism. A slider painted from the scratch is in our TO-DO list.