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 » Sliders in resizable control bars Collapse All
Subject Author Date
Emil Pop Jan 29, 2004 - 8:08 PM

Hi,

 

I try to create a resizable control bar containing a dialog box with several sliders. Everything seems OK in XP and 2K look and feel but for the 2003 look and feel the sliders do not seem to update properly (I e-mailed a snapshot). Is there an issue with the code or am I missing something (control transparency, etc.).

 

Thanks,

 

Emil

Gettica Inc.

 

Technical Support Feb 2, 2004 - 3:39 AM

Dear Emil,

There are two ways to avoid flickering slider controls in resizable windows.

1) Adding the WS_CLIPCHILDREN style to your dialog allows all sliders in the dialog to have their own background. In other words this style clips all other overlapped child windows out of the region of the dialog to be updated. This method is not very good because it causes some other controls (e.g. a static control) to flicker.

2) Repainting the slider control would be much better:

class CCustomPaintedSliderCtrl : 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( dc, this );
    else
     dc.FillSolidRect(
      &rcClient,
      g_PaintManager->GetColor(
       CExtPaintManager::CLR_3DFACE_OUT
       )
      );
    DWORD dwWndStyle = GetStyle();
    bool bHorz = ( (dwWndStyle&TBS_VERT) != 0 ) ? false : true;
    COLORREF clrFace = g_PaintManager->GetColor( COLOR_3DFACE );
    COLORREF clrHilight = g_PaintManager->GetColor( COLOR_3DHILIGHT );
    COLORREF clrShadow = g_PaintManager->GetColor( COLOR_3DSHADOW );
    CRect rcChannel;
    //CSliderCtrl::GetChannelRect( &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 CCustomPaintedSliderCtrl
You can add the CCustomPaintedSliderCtrl class to your project and use it inside your dialog (instead of CSliderCtrl). Of course, if a new look of the slider control does not fit your requirements, we can modify it.