Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Skin Framework
  New Posts New Posts RSS Feed - SliderCtrl:missing selection highlight
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

SliderCtrl:missing selection highlight

 Post Reply Post Reply
Author
Message
collabear View Drop Down
Newbie
Newbie


Joined: 13 September 2007
Status: Offline
Points: 3
Post Options Post Options   Thanks (0) Thanks(0)   Quote collabear Quote  Post ReplyReply Direct Link To This Post Topic: SliderCtrl:missing selection highlight
    Posted: 13 September 2007 at 6:51am

Slider ctrl missing selection highlight when apply a skin, how to add it?
Back to Top
Ark42 View Drop Down
Senior Member
Senior Member
Avatar

Joined: 20 October 2003
Status: Offline
Points: 291
Post Options Post Options   Thanks (0) Thanks(0)   Quote Ark42 Quote  Post ReplyReply Direct Link To This Post Posted: 28 September 2007 at 12:50pm

You must code it yourself when using Windows XP themes or Office 2007 skin with Codejock - it's not a Codejock issue really, but a design choice of Windows XP.

Without Codejock, you can just derive from CSliderCtrl to fix this:

void CMySliderCtrl::OnCustomDraw(NMHDR *pNotifyStruct, LRESULT *result)
{
    NMCUSTOMDRAW *pNmcd = (NMCUSTOMDRAW *)pNotifyStruct;

    switch( pNmcd->dwDrawStage ) {
    case CDDS_PREPAINT:
        if( GetStyle() & TBS_ENABLESELRANGE ) {
            *result = CDRF_NOTIFYITEMDRAW;
        }
        break;
    case CDDS_ITEMPREPAINT:
        switch( pNmcd->dwItemSpec ) {
        case TBCD_CHANNEL: {
            CDC *pDC = CDC::FromHandle(pNmcd->hdc);
            CRect rcChannel;
            GetChannelRect(&rcChannel);
            rcChannel.DeflateRect(6, 3);

            int min, max, selmin, selmax;
            GetRange(min, max);
            GetSelection(selmin, selmax);
            max -= min;
            selmin = (int)(((double)(selmin - min) / max * rcChannel.Width()) + 0.5) + rcChannel.left;
            selmax = (int)(((double)(selmax - min) / max * rcChannel.Width()) + 0.5) + rcChannel.left;
            rcChannel.left = selmin;
            rcChannel.right = selmax;

            pDC->FillSolidRect(rcChannel, static_cast<CXTPMDIFrameWnd *>(AfxGetMainWnd())->GetCommandBars()->GetPaintManager()->GetXtremeColor(COLOR_HIGHLIGHT));
            pDC->ExcludeClipRect(rcChannel);
            *result = CDRF_DODEFAULT | CDRF_NOTIFYPOSTPAINT;
            break; }
        }
        break;
    case CDDS_ITEMPOSTPAINT:
        switch( pNmcd->dwItemSpec ) {
        case TBCD_CHANNEL: {
            CDC *pDC = CDC::FromHandle(pNmcd->hdc);
            pDC->SelectClipRgn(NULL);
            break; }
        }
        break;
    }
}

But with Office 2007 skin and such, Codejock does not support CDRF_NOTIFYITEMDRAW in 11.2.  A patch for 11.2.1 adds support though.


Back to Top
collabear View Drop Down
Newbie
Newbie


Joined: 13 September 2007
Status: Offline
Points: 3
Post Options Post Options   Thanks (0) Thanks(0)   Quote collabear Quote  Post ReplyReply Direct Link To This Post Posted: 01 October 2007 at 11:33pm
Thank you very much!
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.125 seconds.